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

Re: [RFC PATCH 4/7] merge-recursive: fix assumption that head tree being merged is HEAD

From
Elijah Newren <newren@gmail.com>
Date
Jun 11, 2018, 16:15 UTC
Message-ID
<CABPp-BFhneCqGBRT3qtS_d2eUdjgj+5PWsyWJ7XGHBD6dxunqQ@mail.gmail.com>
In-Reply-To
<CABPp-BERW3VtKxwKZ=-K6=pdVZydHRRKKGce2S=sttqfcDeRDA@mail.gmail.com>
On Tue, Jun 5, 2018 at 12:14 AM, Elijah Newren <newren@gmail.com> wrote:
Show 36 quoted lines
> On Sun, Jun 3, 2018 at 8:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Elijah Newren <newren@gmail.com> writes:
>>
>>> `git merge-recursive` does a three-way merge between user-specified trees
>>> base, head, and remote.  Since the user is allowed to specify head, we can
>>> not necesarily assume that head == HEAD.
>>>
>>> We modify index_has_changes() to take an extra argument specifying the
>>> tree to compare the index to.  If NULL, it will compare to HEAD.  We then
>>> use this from merge-recursive to make sure we compare to the
>>> user-specified head.
>>>
>>> Signed-off-by: Elijah Newren <newren@gmail.com>
>>> ---
>>>
>>> I'm really unsure where the index_has_changes() declaration should go;
>>> I stuck it in tree.h, but is there a better spot?
>>
>> I think I saw you tried to lift an assumption that we're always
>> working on the_index in a separate patch recently.  Should that
>> logic apply also to this part of the codebase?  IOW, shouldn't
>> index_has_changes() take a pointer to istate (as opposed to a
>> function that uses the implicit the_index that should be named as
>> "cache_has_changes()" or something?)
>>
>> I tend to think this function as part of the larger read-cache.c
>> family whose definitions are in cache.h and accompanied by macros
>> that are protected by NO_THE_INDEX_COMPATIBILITY_MACROS so if we
>> were to move it elsewhere, I'd keep the header part as-is and
>> implementation to read-cache.c to keep it together with the family,
>> but I do not see a huge issue with the current placement, either.
>
> That's good point; the goal to lift assumptions on the_index should
> probably also apply here.  I'll make the change.
> (And it was actually Duy's patch that I was reviewing, but close
> enough.)   I'll take a look at moving it to read-cache.c as well.

Making it not depend on the_index will require changes to make diff-lib.c not depend on the_index first, so this is going to have to wait for Duy's changes mentioned at https://public-inbox.org/git/CACsJy8Ba74iSPf4_zFxuV=_uNJgL6Z2QunOvAvi3qab-6EWi5g@mail.gmail.com/. I'll re-roll this series on top of Duy's when it comes out.

Previous: Elijah NewrenNext: Elijah Newren
Message 14 of 30 in “merge requirement: index matches head”
  1. 0/7 merge requirement: index matches headElijah Newren, Jun 3, 2018
  2. 3/7 merge-recursive: make sure when we say we abort that we actually abortElijah Newren, Jun 3, 2018
  3. 2/7 t6044: add a testcase for index matching head, when head doesn't match HEADElijah Newren, Jun 3, 2018
  4. 5/7 t6044: add more testcases with staged changes before a merge is invokedElijah Newren, Jun 3, 2018
  5. 6/7 merge-recursive: enforce rule that index matches head before mergingElijah Newren, Jun 3, 2018
  6. 7/7 merge: fix misleading pre-merge check documentationElijah Newren, Jun 3, 2018
  7. Elijah NewrenJun 7, 2018
  8. 4/7 merge-recursive: fix assumption that head tree being merged is HEADElijah Newren, Jun 3, 2018
  9. Ramsay JonesJun 3, 2018
  10. brian m. carlsonJun 3, 2018
  11. Ramsay JonesJun 4, 2018
  12. Junio C HamanoJun 4, 2018
  13. Elijah NewrenJun 5, 2018
  14. Elijah NewrenJun 11, 2018
  15. 1/7 t6044: verify that merges expected to abort actually abortElijah Newren, Jun 3, 2018
  16. 0/9 Fix merge issues with index not matching HEADElijah Newren, Jul 1, 2018
  17. 1/9 read-cache.c: move index_has_changes() from merge.cElijah Newren, Jul 1, 2018
  18. 2/9 index_has_changes(): avoid assuming operating on the_indexElijah Newren, Jul 1, 2018
  19. Junio C HamanoJul 3, 2018
  20. 3/9 t6044: verify that merges expected to abort actually abortElijah Newren, Jul 1, 2018
  21. 4/9 t6044: add a testcase for index matching head, when head doesn't match HEADElijah Newren, Jul 1, 2018
  22. SZEDER GáborJul 10, 2018
  23. Elijah NewrenJul 11, 2018
  24. 8/9 merge-recursive: enforce rule that index matches head before mergingElijah Newren, Jul 1, 2018
  25. Junio C HamanoJul 3, 2018
  26. 5/9 merge-recursive: make sure when we say we abort that we actually abortElijah Newren, Jul 1, 2018
  27. 6/9 merge-recursive: fix assumption that head tree being merged is HEADElijah Newren, Jul 1, 2018
  28. Junio C HamanoJul 3, 2018
  29. 7/9 t6044: add more testcases with staged changes before a merge is invokedElijah Newren, Jul 1, 2018
  30. 9/9 merge: fix misleading pre-merge check documentationElijah Newren, Jul 1, 2018

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.