git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Christoph Hellwig <hch@lst.de>, Paul Mackerras <paulus@samba.org>,
	linuxppc64-dev@ozlabs.org, Git Mailing List <git@vger.kernel.org>,
	Fredrik Kuivinen <freku045@student.liu.se>
Subject: [PATCH] merge-one-file: remove empty directories
Date: Sat, 19 Nov 2005 20:14:37 -0800	[thread overview]
Message-ID: <7v4q683qhe.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: Pine.LNX.4.64.0511190957320.13959@g5.osdl.org

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>

---
    Linus Torvalds <torvalds@osdl.org> writes:

    > [ Junio, Fredrik, you're cc'd because the "merge-one-file" logic doesn't 
    >   clean up empty directories after removing a file in merge ]

    Here is the one for merge-one-file that is used by 'git pull
    -s resolve'.  Next patch will be the merge-recursive one.

 git-merge-one-file.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

applies-to: fbe4060a1b8ba894be5767ffc27402f94f356882
397c76697f898e0341699fba8ef783f3342329c7
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index b08597d..b285990 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -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"
 	;;
---
0.99.9.GIT

  reply	other threads:[~2005-11-20  4:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <17279.1674.22992.607091@cargo.ozlabs.ibm.com>
     [not found] ` <20051119140736.GA24901@lst.de>
2005-11-19 18:24   ` please pull powerpc-merge.git Linus Torvalds
2005-11-20  4:14     ` Junio C Hamano [this message]
2005-11-20 17:17       ` [PATCH] merge-one-file: remove empty directories Linus Torvalds
2005-11-20 18:08         ` H. Peter Anvin
2005-11-21 14:22           ` Alex Riesen
2005-11-21  0:00         ` Johannes Schindelin
2005-11-20  4:14     ` [PATCH] merge-recursive::removeFile: " Junio C Hamano
2005-11-20 11:51       ` Fredrik Kuivinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v4q683qhe.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=freku045@student.liu.se \
    --cc=git@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linuxppc64-dev@ozlabs.org \
    --cc=paulus@samba.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).