git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: Re: Simplify "git reset --hard"
Date: Mon, 15 May 2006 00:46:05 -0700	[thread overview]
Message-ID: <7vr72vvigy.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vwtcnvk76.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Mon, 15 May 2006 00:08:45 -0700")

Junio C Hamano <junkio@cox.net> writes:

> Junio C Hamano <junkio@cox.net> writes:
>
>>> Instead, just pass in "-u" to git-read-tree when we do a hard reset, and 
>>> depend on git-read-tree to update the working tree appropriately.
>>
>> Well, this is wrong.  Local modifications remain after your
>> version of "git-reset --hard HEAD". which is not what we want
>> from a hard reset.
>
> ... and attempting to paper it over in git-reset.sh is also
> wrong.  Keep your "--hard is noop" change in git-reset.sh and
> replace it with this would be the right fix.

-- >8 --
read-tree -u one-way merge fix to check out locally modified paths.

The "-u" flag means "update the working tree files", but to
other types of merges, it also implies "I want to keep my local
changes" -- because they prevent local changes from getting lost
by using verify_uptodate.  The one-way merge is different from
other merges in that its purpose is opposite of doing something
else while keeping unrelated local changes.  The point of
one-way merge is to nuke local changes.  So while it feels
somewhat wrong that this actively loses local changes, it is the
right thing to do.

The earlier one marked old->ce_flags to be updated
unconditionally, but that would cause 18,000 paths to be updated
when you have only a few paths different from the HEAD you are
switching to, which is far worse than what we used to do in
git-reset by hand.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * Third time lucky ;-)

diff --git a/read-tree.c b/read-tree.c
index 11157f4..d847c6f 100644
--- a/read-tree.c
+++ b/read-tree.c
@@ -686,6 +698,9 @@ static int oneway_merge(struct cache_ent
 	if (!a)
 		return deleted_entry(old, NULL);
 	if (old && same(old, a)) {
+		struct stat st;
+		if (lstat(old->name, &st) || ce_match_stat(old, &st, 1))
+			old->ce_flags |= htons(CE_UPDATE);
 		return keep_entry(old);
 	}
 	return merged_entry(a, NULL);

  reply	other threads:[~2006-05-15  7:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-14 17:43 Allow one-way tree merge to remove old files Linus Torvalds
2006-05-14 17:51 ` Junio C Hamano
2006-05-14 18:20 ` Simplify "git reset --hard" Linus Torvalds
2006-05-15  6:55   ` Junio C Hamano
2006-05-15  7:08     ` Junio C Hamano
2006-05-15  7:46       ` Junio C Hamano [this message]
2006-05-15 14:55         ` Linus Torvalds
2006-05-15 15:09           ` Linus Torvalds

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vr72vvigy.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).