@matheusbsbs / matheus-bagliano / commits / 397c76697f
Fork 0

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>

Junio C Hamano committed Nov 19, 2005 at 19:50 UTC 397c76697f898e0341699fba8ef783f3342329c7
1 file changed +6 -1
git-merge-one-file.sh
+6 -1
@@ -25,7 +25,12 @@ case "${1:-.}${2:-.}${3:-.}" in
25 echo "Removing $4"
26 fi
27 if test -f "$4"; then
28 - rm -f -- "$4"
28 + rm -f -- "$4" &&
29 + dn="$4" &&
30 + while dn=$(expr "$dn" : '\(.*\)/') && rmdir "$dn" 2>/dev/null
31 + do
32 + :;
33 + done
34 fi &&
35 exec git-update-index --remove -- "$4"
36 ;;