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

Re: [PATCH 2/8] revert: decouple sequencer actions from builtin commands

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 10, 2012, 18:38 UTC
Message-ID
<20120110183857.GC22184@burratino>
In-Reply-To
<1326212039-13806-3-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra wrote:
Show 5 quoted lines
> Currently, 'git cherry-pick' fills up the '.git/sequencer/todo'
> instruction sheet with "pick" actions, while 'git revert' fills it up
> with "revert" actions.  Inspired by the way 'rebase -i' works, we
> would like to permit mixing arbitrary actions in the same instruction
> sheet.
Ok.
>        To do this, we first have to decouple the notion of an action
> in the instruction sheet from builtin commands.
Wha?

I guess at this point I get lost because you are using jargon. What is the difference between an action in the instruction sheet and a builtin command? How does being a busybox-style hard link to the main "git" binary as opposed to a separate binary (which is what "builtin" means) have anything to do with this at all?

And I don't have any sense of the impact. Will this change the behavior of "git cherry-pick"? Will it avoid some confusion on the part of future people modifying the code? Is it a necessary step before some future change we want? Does it just make the code prettier, and help the sanity of future readers in the process (which is definitely valuable, too)? The above doesn't make it clear to me.

> --- a/builtin/revert.c
> +++ b/builtin/revert.c
[...]
Show 7 quoted lines
> @@ -52,7 +57,7 @@ enum replay_subcommand {
>  };
>  
>  struct replay_opts {
> -	enum replay_action action;
> +	enum replay_command command;
>  	enum replay_subcommand subcommand;

This part seems to be renaming "action" to "command". A cosmetic change, which I don't have an immediate opinion about either way.

[...]
> -static const char *action_name(const struct replay_opts *opts)
> +static const char *command_name(struct replay_opts *opts)

This part does a similar renaming, and drops a const while at it for no intelligible reason.

[...]
Show 6 quoted lines
> @@ -142,7 +147,7 @@ static void verify_opt_mutually_compatible(const char *me, ...)
>  static void parse_args(int argc, const char **argv, struct replay_opts *opts)
>  {
>  	const char * const * usage_str = revert_or_cherry_pick_usage(opts);
> -	const char *me = action_name(opts);
> +	const char *me = command_name(opts);
The rest is stuff like this, which follows from the first part.

Stepping back, I think the idea is that "enum replay_action" is not a good way to identify the command name in error messages like

	fatal: cherry-pick: --abort cannot be used with --continue

So you introduce a _new_ enum to represent the command name. Why not just use a string, so commands using the nice and generic sequencer library do not have to register themselves in a global callers list to use it?

Plus the renaming of the ->action field and action_name() function feel gratuitous, and drowned out the actual changes in the noise.

Does that clarify?

I guess I agree with the problem you are solving, but I don't agree with the solution at all.

Thanks, Jonathan

Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 37 of 64 in “The move to sequencer.c”
  1. 0/6 The move to sequencer.cRamkumar Ramachandra, Jan 8, 2012
  2. 1/6 revert: move replay_action, replay_subcommand to headerRamkumar Ramachandra, Jan 8, 2012
  3. Jonathan NiederJan 8, 2012
  4. 2/6 revert: decouple sequencer actions from builtin commandsRamkumar Ramachandra, Jan 8, 2012
  5. Jonathan NiederJan 8, 2012
  6. Ramkumar RamachandraJan 8, 2012
  7. Jonathan NiederJan 8, 2012
  8. Ramkumar RamachandraJan 8, 2012
  9. Jonathan NiederJan 8, 2012
  10. 3/6 revert: don't let revert continue a cherry-pickRamkumar Ramachandra, Jan 8, 2012
  11. Jonathan NiederJan 8, 2012
  12. Ramkumar RamachandraJan 8, 2012
  13. Jonathan NiederJan 8, 2012
  14. Ramkumar RamachandraJan 8, 2012
  15. Jonathan NiederJan 8, 2012
  16. 4/6 revert: allow mixing "pick" and "revert" actionsRamkumar Ramachandra, Jan 8, 2012
  17. Jonathan NiederJan 8, 2012
  18. Ramkumar RamachandraJan 8, 2012
  19. Jonathan NiederJan 8, 2012
  20. Jonathan NiederJan 8, 2012
  21. Ramkumar RamachandraJan 10, 2012
  22. 5/6 revert: report fine-grained error messages from insn parserRamkumar Ramachandra, Jan 8, 2012
  23. Jonathan NiederJan 8, 2012
  24. Ramkumar RamachandraJan 8, 2012
  25. Jonathan NiederJan 8, 2012
  26. Ramkumar RamachandraJan 10, 2012
  27. 6/6 sequencer: factor code out of revert builtinRamkumar Ramachandra, Jan 8, 2012
  28. Jonathan NiederJan 8, 2012
  29. Ramkumar RamachandraJan 10, 2012
  30. Jonathan NiederJan 8, 2012
  31. Ramkumar RamachandraJan 8, 2012
  32. Jonathan NiederJan 8, 2012
  33. 0/8 The move to sequencer.cRamkumar Ramachandra, Jan 10, 2012
  34. 1/8 revert: prepare to move replay_action to headerRamkumar Ramachandra, Jan 10, 2012
  35. Jonathan NiederJan 10, 2012
  36. 2/8 revert: decouple sequencer actions from builtin commandsRamkumar Ramachandra, Jan 10, 2012
  37. Jonathan NiederJan 10, 2012
  38. Ramkumar RamachandraJan 11, 2012
  39. Ramkumar RamachandraJan 11, 2012
  40. Jonathan NiederJan 11, 2012
  41. Ramkumar RamachandraJan 11, 2012
  42. Ramkumar RamachandraJan 11, 2012
  43. Jonathan NiederJan 11, 2012
  44. Ramkumar RamachandraJan 11, 2012
  45. Jonathan NiederJan 11, 2012
  46. Ramkumar RamachandraJan 11, 2012
  47. Jonathan NiederJan 11, 2012
  48. Jonathan NiederJan 11, 2012
  49. Ramkumar RamachandraJan 11, 2012
  50. Jonathan NiederJan 11, 2012
  51. Ramkumar RamachandraJan 11, 2012
  52. 0/2 The move to sequencer.cRamkumar Ramachandra, Jan 11, 2012
  53. 1/2 revert: prepare to move replay_action to headerRamkumar Ramachandra, Jan 11, 2012
  54. 2/2 sequencer: factor code out of revert builtinRamkumar Ramachandra, Jan 11, 2012
  55. Jonathan NiederJan 11, 2012
  56. 3/8 revert: allow mixing "pick" and "revert" actionsRamkumar Ramachandra, Jan 10, 2012
  57. 4/8 revert: separate out parse errors logicallyRamkumar Ramachandra, Jan 10, 2012
  58. Jonathan NiederJan 10, 2012
  59. Ramkumar RamachandraJan 11, 2012
  60. 5/8 revert: report fine-grained errors from insn parserRamkumar Ramachandra, Jan 10, 2012
  61. Jonathan NiederJan 11, 2012
  62. 6/8 sha1_name: introduce getn_sha1() to take lengthRamkumar Ramachandra, Jan 10, 2012
  63. 7/8 revert: use getn_sha1() to simplify insn parsingRamkumar Ramachandra, Jan 10, 2012
  64. 8/8 sequencer: factor code out of revert builtinRamkumar Ramachandra, Jan 10, 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.