Skip to content

Commit 397c766

Browse files
author
Junio C Hamano
committed
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>
1 parent 22a06b3 commit 397c766

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-merge-one-file.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ case "${1:-.}${2:-.}${3:-.}" in
2525
echo "Removing $4"
2626
fi
2727
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
2934
fi &&
3035
exec git-update-index --remove -- "$4"
3136
;;

0 commit comments

Comments
 (0)