merge-one-file: remove empty directories

When the last file in a directory is removed as the result of a
merge, try to rmdir the now-empty directory.

[jc: We probably could use "rmdir -p", but for now we do that by
hand for portability.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2005-11-19 19:50:44 -08:00
parent 22a06b3c47
commit 397c76697f

View File

@ -25,7 +25,12 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "Removing $4"
fi
if test -f "$4"; then
rm -f -- "$4"
rm -f -- "$4" &&
dn="$4" &&
while dn=$(expr "$dn" : '\(.*\)/') && rmdir "$dn" 2>/dev/null
do
:;
done
fi &&
exec git-update-index --remove -- "$4"
;;