Mmm, de hecho, en caso de que sea un directorio no deberíamos agregar recursivamente... debería ser así:
#!/usr/bin/env bash
# file: safa-add
# --------------------------------------------------------------
# This file is part of SAFA
#
# SAFA is free software: you can redistribute it and/or modify
# it under the terms of the version 3 of the GNU General Public
# License as published by the Free Software Foundation
#
# SAFA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SAFA. If not, see <
http://www.gnu.org/licenses/>.
. safa-shelllib
NR_CHANGES=0
if test $# -lt 1; then
echo "incorrect usage"
echo "usage: safa-add <file 1> ... <file n>"
else
for myFile in $@; do
if test -f "$myFile" || test -d; then
if test -f '.safa/HEAD'; then
# verify if the file changed from the last tree
DEBUG_print 'safa-check-from-commit --perm --quiet $(safa-resolve-ref HEAD) "$myFile"'
safa-check-from-commit --perm --quiet $(safa-resolve-ref HEAD) "$myFile"
CHECK_VS_HEAD=$?
if test $CHECK_VS_HEAD -eq 0; then
echo " 0 $myFile"
DEBUG_print "nothing changed"
else
if $(grep "$myFile" .safa/addindex)
if test $CHECK_VS_HEAD -eq 1; then
echo " M $myFile"
echo "$myFile" >> .safa/addindex
NR_CHANGES=$(($NR_CHANGES+1))
fi
if test $CHECK_VS_HEAD -eq 2; then
echo " A $myFile"
echo "$myFile" >> .safa/addindex
NR_CHANGES=$(($NR_CHANGES+1))
fi
fi
fi
fi
done
echo ""
echo "$NR_CHANGES files changed"
fi
Y safa-check-from-commit debe admitir directorios y verificar permisos y existencia. Entonces podemos agregar directorios vacíos y trackear estructuras, como estaba previsto en el modelo de TREE.
Saludos
--
Dario