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

Re: [PATCH 4/3] revert: write REVERT_HEAD pseudoref during conflicted revert

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Dec 1, 2011, 09:34 UTC
Message-ID
<CALkWK0mp4-nxLsf=wjDwHOhvoWFNzNz-Rc+Q+S_Er5rpFW2k=Q@mail.gmail.com>
In-Reply-To
<20111122111736.GE7399@elie.hsd1.il.comcast.net>
Hi,
Jonathan Nieder wrote:
Show 5 quoted lines
> [...]
> Set a REVERT_HEAD pseudoref when "git revert" does not make a commit,
> for cases like this.  This also makes it possible for scripts to
> distinguish between a revert that encountered conflicts and other
> sources of an unmerged index.

Sounds a lot like CHERRY_PICK_HEAD counterpart. Let's read ahead and see if there are any unexpected differences.

Show 24 quoted lines
> diff --git a/branch.c b/branch.c
> index d8098762..025a97be 100644
> --- a/branch.c
> +++ b/branch.c
> @@ -241,6 +241,7 @@ void create_branch(const char *head,
>  void remove_branch_state(void)
>  {
>        unlink(git_path("CHERRY_PICK_HEAD"));
> +       unlink(git_path("REVERT_HEAD"));
>        unlink(git_path("MERGE_HEAD"));
>        unlink(git_path("MERGE_RR"));
>        unlink(git_path("MERGE_MSG"));
> diff --git a/builtin/commit.c b/builtin/commit.c
> index c46f2d18..8f2bebec 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1514,6 +1514,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>        }
>
>        unlink(git_path("CHERRY_PICK_HEAD"));
> +       unlink(git_path("REVERT_HEAD"));
>        unlink(git_path("MERGE_HEAD"));
>        unlink(git_path("MERGE_MSG"));
>        unlink(git_path("MERGE_MODE"));
So far so good.  Behaves exactly like CHERRY_PICK_HEAD.
Show 33 quoted lines
> diff --git a/builtin/revert.c b/builtin/revert.c
> index 1d112e4c..f5ba67a5 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -289,7 +289,7 @@ static char *get_encoding(const char *message)
>        return NULL;
>  }
>
> -static void write_cherry_pick_head(struct commit *commit)
> +static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)
>  {
>        const char *filename;
>        int fd;
> @@ -297,7 +297,7 @@ static void write_cherry_pick_head(struct commit *commit)
>
>        strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
>
> -       filename = git_path("CHERRY_PICK_HEAD");
> +       filename = git_path(pseudoref);
>        fd = open(filename, O_WRONLY | O_CREAT, 0666);
>        if (fd < 0)
>                die_errno(_("Could not open '%s' for writing"), filename);
> @@ -597,7 +597,9 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
>         * write it at all.
>         */
>        if (opts->action == CHERRY_PICK && !opts->no_commit && (res == 0 || res == 1))
> -               write_cherry_pick_head(commit);
> +               write_cherry_pick_head(commit, "CHERRY_PICK_HEAD");
> +       if (opts->action == REVERT && ((opts->no_commit && res == 0) || res == 1))
> +               write_cherry_pick_head(commit, "REVERT_HEAD");
>
>        if (res) {
>                error(opts->action == REVERT

Interesting. This additional symmetry will probably make life much easier for my pending "New Sequencer Workflow! v2" series.

Show 5 quoted lines
> diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
> index cb45574a..ee1659c1 100755
> --- a/t/t3507-cherry-pick-conflict.sh
> +++ b/t/t3507-cherry-pick-conflict.sh
> [...]
And some tests.  Nice.
Thanks.
-- Ram
Previous: Thiago FarinaNext: Jonathan Nieder
Message 16 of 52 in “cherry-pick/revert error messages”
  1. Jonathan NiederNov 20, 2011
  2. Ramkumar RamachandraNov 20, 2011
  3. 0/3 Re: cherry-pick/revert error messagesJonathan Nieder, Nov 20, 2011
  4. 1/3 revert: rename --reset option to --quitJonathan Nieder, Nov 20, 2011
  5. Junio C HamanoNov 21, 2011
  6. Jakub NarebskiNov 21, 2011
  7. Jonathan NiederNov 21, 2011
  8. 2/3 revert: rearrange pick_revisions() for clarityJonathan Nieder, Nov 20, 2011
  9. 3/3 revert: improve error message for cherry-pick during cherry-pickJonathan Nieder, Nov 20, 2011
  10. 0/3 Re: cherry-pick/revert error messagesJonathan Nieder, Nov 22, 2011
  11. 1/3 revert: rename --reset option to --quitJonathan Nieder, Nov 22, 2011
  12. 2/3 revert: rearrange pick_revisions() for clarityJonathan Nieder, Nov 22, 2011
  13. 3/3 revert: improve error message for cherry-pick during cherry-pickJonathan Nieder, Nov 22, 2011
  14. 4/3 revert: write REVERT_HEAD pseudoref during conflicted revertJonathan Nieder, Nov 22, 2011
  15. Thiago FarinaNov 22, 2011
  16. Ramkumar RamachandraDec 1, 2011
  17. 5/3 revert: introduce --abort to cancel a failed cherry-pickJonathan Nieder, Nov 22, 2011
  18. Junio C HamanoNov 23, 2011
  19. Jonathan NiederNov 23, 2011
  20. Fix revert --abort on WindowsJohannes Sixt, Nov 23, 2011
  21. Jonathan NiederNov 23, 2011
  22. Johannes SixtNov 23, 2011
  23. 0/7 some sequencer loose ends (Re: Fix revert --abort on Windows)Jonathan Nieder, Dec 10, 2011
  24. 1/7 revert: give --continue handling its own functionJonathan Nieder, Dec 10, 2011
  25. Ramkumar RamachandraDec 14, 2011
  26. 2/7 revert: allow cherry-pick --continue to commit before resumingJonathan Nieder, Dec 10, 2011
  27. Ramkumar RamachandraDec 14, 2011
  28. Jonathan NiederDec 14, 2011
  29. 3/7 revert: pass around rev-list args in already-parsed formJonathan Nieder, Dec 10, 2011
  30. Ramkumar RamachandraDec 14, 2011
  31. 4/7 revert: allow single-pick in the middle of cherry-pick sequenceJonathan Nieder, Dec 10, 2011
  32. Ramkumar RamachandraDec 14, 2011
  33. Jonathan NiederDec 14, 2011
  34. Ævar Arnfjörð BjarmasonApr 5, 2012
  35. Jonathan NiederApr 5, 2012
  36. 5/7 revert: do not remove state until sequence is finishedJonathan Nieder, Dec 10, 2011
  37. Ramkumar RamachandraDec 14, 2011
  38. 6/7 Revert "reset: Make reset remove the sequencer state"Jonathan Nieder, Dec 10, 2011
  39. Ramkumar RamachandraDec 14, 2011
  40. 7/7 revert: stop creating and removing sequencer-old directoryJonathan Nieder, Dec 10, 2011
  41. Ramkumar RamachandraDec 14, 2011
  42. Jonathan NiederDec 11, 2011
  43. Junio C HamanoDec 12, 2011
  44. Junio C HamanoDec 12, 2011
  45. Jonathan NiederDec 14, 2011
  46. Alex RiesenNov 23, 2011
  47. Junio C HamanoNov 30, 2011
  48. 6/3 revert: remove --reset compatibility optionJonathan Nieder, Nov 22, 2011
  49. Junio C HamanoNov 22, 2011
  50. Jonathan NiederNov 22, 2011
  51. Junio C HamanoNov 22, 2011
  52. Jonathan NiederNov 22, 2011

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.