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

Re: [PATCH v2 3/4] reset: add option "--merge-safe" to "git reset"

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2009, 05:23 UTC
Message-ID
<7veiq6kuv3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<200909170554.49416.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 11 quoted lines
> But I think that it can be usefull in case like:
>
> $ "hack something"
> $ git commit ...
> $ "hack something else"
> $ git add "some of the files"
> $ "find out previous commit was crap"
> $ git reset --merge-safe HEAD^
>
> Here using "--merge-safe" can be usefull because you don't want to lose 
> stuff in your current index and work tree.

That depends on the reason why you are resetting away the "crap commit" and what your next move is.

If you are going to run "git commit", perhaps after some further edit, in order to fix what the "crap commit" did not quite do right, what your new option does is actively a wrong thing to do. "Some of the files" you added after that "crap commit" are about "hack something else", i.e. not part of the work to fix the "crap commit", and their changes should not be included in the amended commit, no?

In general, "reset" should be about matching the index entries to the named commit, so that you can start from the clean, known slate to redo the commit you wanted to make on top of it. You would need a very good use case to deviate from it and leave the index entry different from that of the commit you are switching to; otherwise you would greatly confuse the end users.

Previous: Christian CouderNext: Christian Couder
Message 7 of 8 in “"git reset --merge" related improvements”
  1. 0/4 "git reset --merge" related improvementsChristian Couder, Sep 16, 2009
  2. 1/4 reset: add a few tests for "git reset --merge"Christian Couder, Sep 16, 2009
  3. 2/4 reset: use "unpack_trees()" directly instead of "git read-tree"Christian Couder, Sep 16, 2009
  4. 3/4 reset: add option "--merge-safe" to "git reset"Christian Couder, Sep 16, 2009
  5. Junio C HamanoSep 16, 2009
  6. Christian CouderSep 17, 2009
  7. Junio C HamanoSep 17, 2009
  8. 4/4 reset: add test cases for "--merge-safe" optionChristian Couder, Sep 16, 2009

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.