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

Re: [PATCH 0/2] Add "git rebase --show-patch"

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 27, 2018, 01:45 UTC
Message-ID
<CACsJy8A=SDPEK7qeLRi_eLM+L5zszWWSiEQtbmQVuG1E2ENBig@mail.gmail.com>
In-Reply-To
<87372s78zo.fsf@passepartout.tim-landscheidt.de>
On Sat, Jan 27, 2018 at 1:47 AM, Tim Landscheidt <tim@tim-landscheidt.de> wrote:
Show 50 quoted lines
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>
>> When a conflict happens during a rebase, you often need to look at the
>> original patch to see what the changes are. This requires opening your
>> favourite pager with some random path inside $GIT_DIR.
>
>> This series makes that experience a bit better, by providing a command
>> to read the patch. This is along the line of --edit-todo and --quit
>> where you can just tell git what to do and not bother with details.
>
>> My main focus is "git rebase", but because rebase uses "git am" behind
>> the scene, "git am" gains --show-patch option too.
>
>> There was something more I wanted to do, like coloring to the patch.
>> But that probably will come later. I'll try to merge these two
>> 21-months-old patches first.
>
>> […]
>
> I dislike the approach to use a separate command/option.
> The nice thing about rebase-apply/original-commit is that
> you can use it in /any/ git command, i. e. you can do "git
> log $whatever..rebase-apply/original-commit".
>
> What I would do instead is (besides documenting it :-)) to
> provide an alias that is more in line with ORIG_HEAD,
> FETCH_HEAD, etc.; i. e. something along the lines of (pseudo
> code, will probably not work):
>
> | --- a/builtin/am.c
> | +++ b/builtin/am.c
> | @@ -1110,6 +1110,7 @@ static void am_next(struct am_state *state)
> |
> |         oidclr(&state->orig_commit);
> |         unlink(am_path(state, "original-commit"));
> | +       delete_ref(NULL, "ORIG_COMMIT", NULL, 0);
> |
> |         if (!get_oid("HEAD", &head))
> |                 write_state_text(state, "abort-safety", oid_to_hex(&head));
> | @@ -1441,6 +1442,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
> |
> |         oidcpy(&state->orig_commit, &commit_oid);
> |         write_state_text(state, "original-commit", oid_to_hex(&commit_oid));
> | +       update_ref_oid("am", "ORIG_COMMIT", &commit_oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
> |
> |         return 0;
> |  }
>
> This (when working) would allow to use ORIG_COMMIT in place
> of the mouthful rebase-apply/original-commit.

Interesting. Taken out of context, I don't think it really works for "git am" because the source patches are in text form and "git am" only fails when it can't apply the patch (and won't be able to create a commit). But for rebase I can see how this is a good thing. Thanks. Let me sleep on it for a bit. It works for cherry-pick too.

-- 
Duy
Previous: Tim LandscheidtNext: Ævar Arnfjörð Bjarmason
Message 10 of 40 in “Add "git rebase --show-patch"”
  1. 0/2 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 26, 2018
  2. 1/2 am: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  3. 2/2 rebase: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  4. Phillip WoodJan 26, 2018
  5. Duy NguyenJan 26, 2018
  6. Phillip WoodJan 30, 2018
  7. Eric SunshineJan 26, 2018
  8. Duy NguyenJan 27, 2018
  9. Tim LandscheidtJan 26, 2018
  10. Duy NguyenJan 27, 2018
  11. Ævar Arnfjörð BjarmasonJan 27, 2018
  12. Johannes SchindelinJan 29, 2018
  13. Duy NguyenJan 30, 2018
  14. Johannes SchindelinJan 30, 2018
  15. Junio C HamanoJan 30, 2018
  16. Tim LandscheidtFeb 1, 2018
  17. 0/3 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 31, 2018
  18. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  19. Eric SunshineJan 31, 2018
  20. Junio C HamanoJan 31, 2018
  21. Duy NguyenFeb 2, 2018
  22. Eric SunshineFeb 2, 2018
  23. Duy NguyenFeb 2, 2018
  24. Junio C HamanoFeb 2, 2018
  25. gitignore.txt: elaborate shell glob syntaxNguyễn Thái Ngọc Duy, Jan 31, 2018
  26. Junio C HamanoJan 31, 2018
  27. Duy NguyenFeb 1, 2018
  28. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  29. 3/3 rebase: introduce and use pseudo-ref ORIG_COMMITNguyễn Thái Ngọc Duy, Jan 31, 2018
  30. Junio C HamanoJan 31, 2018
  31. Duy NguyenFeb 1, 2018
  32. Junio C HamanoFeb 2, 2018
  33. Phillip WoodFeb 1, 2018
  34. 0/3 Add "git rebase --show-current-patch"Nguyễn Thái Ngọc Duy, Feb 11, 2018
  35. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  36. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  37. 3/3 rebase: introduce and use pseudo-ref REBASE_HEADNguyễn Thái Ngọc Duy, Feb 11, 2018
  38. Junio C HamanoFeb 22, 2018
  39. Tim LandscheidtFeb 22, 2018
  40. Duy NguyenFeb 23, 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.