From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org, Martin Waitz <tali@admingilde.org>
Subject: Re: git reset --hard not removing some files
Date: Sat, 03 Jun 2006 01:48:10 -0700 [thread overview]
Message-ID: <7vy7we8w1h.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vhd33d2q2.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Fri, 02 Jun 2006 07:57:57 -0700")
Junio C Hamano <junkio@cox.net> writes:
> I would agree in the reproduction recipe Martin gave there is no
> problem but feature, but at the same time I suspect the recent
> "reset --hard simplification" has introduced a true regression.
> ...
> $ git ls-files -u
> 100644 b1b716105590454bfc4c0247f193a04088f39c7f 1 file1
> 100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 3 file1
> $ ls
> file0 file1 file2
> $ git reset --hard
> $ ls
> file0 file1 file2
>
> We used to remove file1 from the working tree in this case. One
> of the most important reason to use "git reset --hard" is to
> recover from a conflicted, failed merge.
I think this patch fixes the regression. Comments?
-- >8 --
read-tree --reset: update working tree file for conflicted paths.
The earlier "git reset --hard" simplification stopped removing
leftover working tree files from a failed automerge, when
switching back to the HEAD version that does not have the
paths.
This patch, instead of removing the unmerged paths from the
index, drops them down to stage#0 but marks them with mode=0
(the same "to be deleted" marker we internally use for paths
deleted by the merge). one_way_merge() function and the
functions it calls already know what to do with them -- if the
tree we are reading has the path the working tree file is
overwritten, and if it doesn't the working tree file is
removed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
builtin-read-tree.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 716f792..71edaf6 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -753,6 +753,8 @@ static int read_cache_unmerged(void)
{
int i, deleted;
struct cache_entry **dst;
+ int unmerged = 0;
+ struct cache_entry *last = NULL;
read_cache();
dst = active_cache;
@@ -760,16 +762,22 @@ static int read_cache_unmerged(void)
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce)) {
- deleted++;
+ unmerged++;
+ if (last && !strcmp(ce->name, last->name)) {
+ deleted++;
+ continue;
+ }
invalidate_ce_path(ce);
- continue;
+ last = ce;
+ ce->ce_mode = 0;
+ ce->ce_flags &= ~htons(CE_STAGEMASK);
}
if (deleted)
*dst = ce;
dst++;
}
active_nr -= deleted;
- return deleted;
+ return unmerged;
}
static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
@@ -850,7 +858,10 @@ int cmd_read_tree(int argc, const char *
continue;
}
- /* This differs from "-m" in that we'll silently ignore unmerged entries */
+ /* This differs from "-m" in that we'll silently ignore
+ * unmerged entries and overwrite working tree files that
+ * correspond to them.
+ */
if (!strcmp(arg, "--reset")) {
if (stage || merge)
usage(read_tree_usage);
next prev parent reply other threads:[~2006-06-03 8:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-01 16:00 git reset --hard not removing some files Martin Waitz
[not found] ` <20060601121304.9bae1806.seanlkml@sympatico.ca>
2006-06-01 16:13 ` Sean
2006-06-01 17:21 ` Jakub Narebski
[not found] ` <20060601152152.35ce04a5.seanlkml@sympatico.ca>
2006-06-01 19:21 ` Sean
2006-06-02 8:16 ` Jakub Narebski
2006-06-01 16:21 ` Linus Torvalds
2006-06-02 9:37 ` Martin Waitz
[not found] ` <20060602060820.8eebe391.seanlkml@sympatico.ca>
2006-06-02 10:08 ` Sean
2006-06-02 14:17 ` Martin Waitz
2006-06-02 14:57 ` Junio C Hamano
2006-06-03 8:48 ` Junio C Hamano [this message]
2006-06-03 15:11 ` Linus Torvalds
2006-06-04 9:16 ` Martin Waitz
2006-06-04 9:31 ` Junio C Hamano
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=7vy7we8w1h.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=tali@admingilde.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).