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

Re: [SCRIPT/RFC 0/3] git-commit --onto-parent (three-way merge, no working tree file changes)

From
Alexei Lozovsky <a.lozovsky@gmail.com>
Date
Dec 9, 2017, 02:18 UTC
Message-ID
<D842B04A-9331-4F26-8F19-B61F6F13FC79@gmail.com>
In-Reply-To
<a3510c14-23e9-d1d9-0847-b60451f8e15d@gmail.com>
On Dec 9, 2017, at 01:54, Igor Djordjevic wrote:
Show 11 quoted lines
> On 08/12/2017 17:24, Junio C Hamano wrote:
>> I'd rather do a quick fix-up on top (which ensures that at least the
>> fix-up works in the context of the tip), and then "rebase -i" to
>> move it a more appropriate place in the history (during which I have
>> a chance to ensure that the fix-up works in the context it is
>> intended to apply to).
> 
> Chris reported in this very topic[1] that sometimes, due to conflicts 
> with later commits, "checkout > commit > [checkout >] rebase --onto" 
> is "much easier to do", where "commit --fixup > rebase -i" "breaks" 
> (does not apply cleanly).

It was more of a rant about conflict resolution by rebase rather than a concern about modification time of files. While I'd prefer git to not touch the source tree unnecessarily, it's not really a big deal for me if it does and some parts of the project need to be rebuilt.

The situations which tend to cause conflicts for me usually look like this.

  ---A---B
Say, a file has this line added somewhere in commit A:
  +int some_function(); 
Then commit B adds another line:
   int some_function(); 
  +int another_function();

Then I realize that I would like to have commit A to introduce some other_function() as well, so I add a fixup:

  ---A---B---f!A
with the following diff:
   int some_function(); 
  +int other_function();
   int another_function();

And then I often find that "rebase -i --autosquash" fails to apply the commit B because it expects slightly different context around the changed lines.

However, sometimes I see that if I do this:
  ---A---B
      \
       f!A

then "rebase --onto f!A A B" succeeds, nicely resolving the conflict without bothering me. No idea why. I kinda hoped that you may know this magic and incorporate it into "commit --onto" which will allow to immediately get to the result of the rebase:

  ---A---f!A---B'
without spelling it all manually.

(And yeah, I'm actually Alexei, not Chris. That was my MUA being dumb and using an old pseudonym than Google insists I'm called by.)

Previous: Igor DjordjevicNext: Igor Djordjevic
Message 16 of 26 in “[SCRIPT/RFC 0/3] git-commit --onto-parent (three-way merge, no working tree file changes)”
  1. Igor DjordjevicNov 26, 2017
  2. 1/3 setup.shIgor Djordjevic, Nov 26, 2017
  3. 3/3 git-commit--onto-parent.shIgor Djordjevic, Nov 26, 2017
  4. 2/3 git-merge-one-file--cachedIgor Djordjevic, Nov 26, 2017
  5. Johannes SixtNov 27, 2017
  6. Igor DjordjevicNov 28, 2017
  7. Johannes SixtNov 29, 2017
  8. Igor DjordjevicNov 29, 2017
  9. Johannes SixtDec 1, 2017
  10. Igor DjordjevicDec 4, 2017
  11. Johannes SixtDec 6, 2017
  12. Junio C HamanoDec 6, 2017
  13. Igor DjordjevicDec 8, 2017
  14. Junio C HamanoDec 8, 2017
  15. Igor DjordjevicDec 8, 2017
  16. Alexei LozovskyDec 9, 2017
  17. Igor DjordjevicDec 9, 2017
  18. Phillip WoodDec 9, 2017
  19. Igor DjordjevicDec 10, 2017
  20. Phillip WoodDec 10, 2017
  21. Igor DjordjevicDec 10, 2017
  22. Alexei LozovskyDec 11, 2017
  23. Alexei LozovskyDec 11, 2017
  24. Phillip WoodDec 9, 2017
  25. Chris NerwertNov 30, 2017
  26. Igor DjordjevicDec 3, 2017

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.