Skip to content

Commit

Permalink
merge-one-file: remove empty directories
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Nov 20, 2005
1 parent 22a06b3 commit 397c766
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-merge-one-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
;;
Expand Down

0 comments on commit 397c766

Please sign in to comment.