git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Simplify "git reset --hard"

From
Junio C Hamano <junkio@cox.net>
Date
May 15, 2006, 07:08 UTC
Message-ID
<7vwtcnvk76.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v1wuvwzdv.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 6 quoted lines
>> 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 --
diff --git a/read-tree.c b/read-tree.c
index 11157f4..c135f08 100644
--- a/read-tree.c
+++ b/read-tree.c
@@ -686,6 +686,7 @@ static int oneway_merge(struct cache_ent
 	if (!a)
 		return deleted_entry(old, NULL);
 	if (old && same(old, a)) {
+		old->ce_flags |= htons(CE_UPDATE);
 		return keep_entry(old);
 	}
 	return merged_entry(a, NULL);
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “Allow one-way tree merge to remove old files”
  1. Linus TorvaldsMay 14, 2006
  2. Junio C HamanoMay 14, 2006
  3. Simplify "git reset --hard"Linus Torvalds, May 14, 2006
  4. Junio C HamanoMay 15, 2006
  5. Junio C HamanoMay 15, 2006
  6. Junio C HamanoMay 15, 2006
  7. Linus TorvaldsMay 15, 2006
  8. Linus TorvaldsMay 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.