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

Re: [RFC/PATCH] stash: Delete MERGE_RR before stash apply

From
Phil Hord <phil.hord@gmail.com>
Date
Jul 6, 2012, 23:18 UTC
Message-ID
<CABURp0oXhZ5ysm4b3Z=7o+2TB+3wFdMjj4oEwxafApjD4c7ozA@mail.gmail.com>
In-Reply-To
<7v7gugodzh.fsf@alter.siamese.dyndns.org>
On Fri, Jul 6, 2012 at 4:01 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 63 quoted lines
> Phil Hord <phil.hord@gmail.com> writes:
>
>>> Would an obvious alternative of running "git rerere" ourselves after
>>> running "git merge-recursive" in this script work?
>>>
>>>  git-stash.sh | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/git-stash.sh b/git-stash.sh
>>> index 4e2c7f8..bbefdf6 100755
>>> --- a/git-stash.sh
>>> +++ b/git-stash.sh
>>> @@ -469,6 +469,7 @@ apply_stash () {
>>>         else
>>>                 # Merge conflict; keep the exit status from merge-recursive
>>>                 status=$?
>>> +               git rerere
>>>                 if test -n "$INDEX_OPTION"
>>>                 then
>>>                         gettextln "Index was not unstashed." >&2
>>
>> Yes, except it needs "git rerere clear".  "git rerere" is not enough
>> to cause the clean-up to occur.
>
> Intuitively, it feels wrong to run "rerere clear" after an operation
> that potentially can create conflicts in the index and in the
> working tree.
>
> The point in the codepath where the above "git rerere" appears is
> immediately after we run merge-recursive backend.  Because the
> backend does not invoke rerere itself (which by the way probably is
> the correct thing not to; I haven't thought things through, though),
> we invoke it ourselves there, so that the user can ask rerere to
> replay an earlier conflict resolution.  Why can it be a good thing
> to discard potentially useful information with "git rerere clear"?
>
> I just tried this sequence (manually without any patch).
>
>     $ git init empty && cd empty
>     $ for i in a b c d e; do echo $i; done >file
>     $ git add file && git commit -m initial
>     $ for i in a b C d e; do echo $i; done >file ;# c to C
>     $ git stash
>
>     $ for i in a B c d e; do echo $i; done >file ;# b to B
>     $ git commit -a -m second
>
>     $ mkdir .git/rr-cache ;# enable rerere
>     $ git stash apply ;# conflicts
>     $ git rerere ;# records preimage
>
>     $ for i in a B C d e; do echo $i; done >file ;# c to C
>     $ git commit -a -m third ;# records resolution
>     $ git reset --hard HEAD^
>
>     $ git stash apply ;# conflicts
>     $ git rerere ;# replays
>
> I think the above "how about this" patch is equivalent to the two
> "git rerere" invocations I made manually with my experiment, and it
> seems to improve the end user experience (please try it yourself).
>
> What am I missing???

I thought the reason rerere was not supported was because of some limitation in the type of merge being completed. I didn't think it was possible to make rerere actually work with this situation.

I understand now.  I'll try again.
Phil
Previous: Junio C HamanoNext: Phil Hord
Message 5 of 13 in “stash: Delete MERGE_RR before stash apply”
  1. stash: Delete MERGE_RR before stash applyPhil Hord, Jul 5, 2012
  2. Junio C HamanoJul 5, 2012
  3. Phil HordJul 6, 2012
  4. Junio C HamanoJul 6, 2012
  5. Phil HordJul 6, 2012
  6. 0/2 stash: invoke rerere in case of conflictPhil Hord, Jul 7, 2012
  7. 1/2 test: git-stash conflict sets up rererePhil Hord, Jul 7, 2012
  8. Junio C HamanoJul 9, 2012
  9. Phil HordJul 9, 2012
  10. Junio C HamanoAug 16, 2012
  11. Phil HordAug 17, 2012
  12. Junio C HamanoAug 17, 2012
  13. 2/2 stash: invoke rerere in case of conflictPhil Hord, Jul 7, 2012

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.