From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Cc: Anders Melchiorsen <mail@cup.kalibalik.dk>,
"Shawn O. Pearce" <spearce@spearce.org>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Remove empty directories in recursive merge
Date: Thu, 25 Sep 2008 22:12:45 +0200 [thread overview]
Message-ID: <20080925201245.GB3959@blimp.localhost> (raw)
In-Reply-To: <87k5d1v71l.fsf@cup.kalibalik.dk>
The code was actually supposed to do that, but was accidentally broken.
Noticed by Anders Melchiorsen.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Anders Melchiorsen, Wed, Sep 24, 2008 18:32:22 +0200:
> I got an empty directory left over today, and have reduced the problem
> to this sequence. If I leave out the second add (so the merge is a
> fast forward), the directory is removed as I would expect.
Ach, an old bug. Thanks for reminding!
builtin-merge-recursive.c | 4 +---
t/t3030-merge-recursive.sh | 11 +++++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c
index dfb363e..a29b47f 100644
--- a/builtin-merge-recursive.c
+++ b/builtin-merge-recursive.c
@@ -444,10 +444,8 @@ static int remove_file(int clean, const char *path, int no_wd)
return -1;
}
if (update_working_directory) {
- unlink(path);
- if (errno != ENOENT || errno != EISDIR)
+ if (remove_path(path) && errno != ENOENT)
return -1;
- remove_path(path);
}
return 0;
}
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index de0cdb1..0de613d 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -535,4 +535,15 @@ test_expect_success 'reset and bind merge' '
'
+test_expect_success 'merge removes empty directories' '
+
+ git reset --hard master &&
+ git checkout -b rm &&
+ git rm d/e &&
+ git commit -mremoved-d/e &&
+ git checkout master &&
+ git merge -s recursive rm &&
+ test_must_fail test -d d
+'
+
test_done
--
1.6.0.2.328.g14651
next prev parent reply other threads:[~2008-09-25 20:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 16:32 [BUG] git merge does not prune empty directories Anders Melchiorsen
2008-09-25 20:12 ` Alex Riesen [this message]
2008-09-25 20:17 ` [PATCH] Cleanup remove_path Alex Riesen
2008-09-25 20:22 ` [PATCH] Fix memleak and the implementation of remove_file in builtin-rm.c Alex Riesen
2008-09-26 15:28 ` Shawn O. Pearce
2008-09-26 22:56 ` [PATCH] Add remove_path: a function to remove as much as possible of a path Alex Riesen
2008-09-26 22:59 ` [PATCH] Use remove_path from dir.c instead of own implementation Alex Riesen
2008-09-25 20:33 ` [PATCH] Remove empty directories in recursive merge Alex Riesen
2008-09-26 15:06 ` Shawn O. Pearce
2008-09-26 5:58 ` Johannes Sixt
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=20080925201245.GB3959@blimp.localhost \
--to=raa.lkml@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mail@cup.kalibalik.dk \
--cc=spearce@spearce.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).