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

Re: [PATCH 03/11] revert: Introduce a struct to parse command-line options into

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 11, 2011, 21:41 UTC
Message-ID
<7vmxjwtqhz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1302448317-32387-4-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>

Again, "In later steps, a new API that takes a single commit and replays it in forward (cherry-pick) or backward (revert) direction will be introduced, and will take this structure as a parameter to tell it what to do" is missing from the above description.

More importantly, the primary purpose of these variables is _not_ "to parse command line options into". It is to actively affect what happens in the code, and "parse command line" is merely a way to assign the initial values to them. So I'd rather see this patch described perhaps like this:

    cherry-pick/revert: introduce "struct replay_options"
    The current code uses a set of file-scope static variables to instruct
    the cherry-pick/revert machinery how to replay the changes, and
    initialises them by parsing the command line arguments. In later steps
    in this series, we would like to introduce an API function that calls
    into this machinery directly and have a way to tell it what to do.
    Introduce a structure to group these variables, so that the API can
    take them as a single "replay_options" parameter.

I strongly prefer to see this patch also update the callchain to pass a pointer to the options struct as parameter. I can guess without reading the rest the series that at some later step you would do that, but I think it makes more sense to do the conversion at this step, as you will be touching lines that use the global variables in this patch anyway, like this:

- return action == REVERT ? revert_usage : cherry_pick_usage; + return cmd_opts.action == REVERT ? revert_usage : cherry_pick_usage;

which should eventually become something like:
	return opts->usage_message;

at the very last step when this codepath is _fully_ libified (I don't know if the final result of your series still is a "choose only from these two canned messages" API, or gives the ability to the caller to specify the usage message---I am just showing how it should look like at the end of a full libification). So it would make sense to see:

	return opts->action == REVERT ? revert_usage : cherry_pick_usage;
in this patch.
> @@ -268,17 +278,17 @@ static struct tree *empty_tree(void)
>  static int error_dirty_index()

It is probably a remnant of the earlier patches in this series, but this should start with:

	static int error_dirty_index(void)

Of course, you will actually be passing the options structure, so it would become:

	static int error_dirty_index(struct replay_options *opts)
        {
        	...
                if (opts->action == REVERT)
                	...
	}
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 12 of 36 in “Sequencer Foundations”
  1. 00/11 Sequencer FoundationsRamkumar Ramachandra, Apr 10, 2011
  2. 01/11 revert: Avoid calling die; return error insteadRamkumar Ramachandra, Apr 10, 2011
  3. Jonathan NiederApr 10, 2011
  4. Ramkumar RamachandraMay 8, 2011
  5. Junio C HamanoApr 11, 2011
  6. 02/11 revert: Lose global variables "commit" and "me"Ramkumar Ramachandra, Apr 10, 2011
  7. Christian CouderApr 11, 2011
  8. Ramkumar RamachandraApr 11, 2011
  9. 03/11 revert: Introduce a struct to parse command-line options intoRamkumar Ramachandra, Apr 10, 2011
  10. Jonathan NiederApr 10, 2011
  11. Ramkumar RamachandraMay 8, 2011
  12. Junio C HamanoApr 11, 2011
  13. Ramkumar RamachandraMay 8, 2011
  14. 04/11 revert: Separate cmdline argument handling from the functional codeRamkumar Ramachandra, Apr 10, 2011
  15. 05/11 revert: Catch incompatible command-line options earlyRamkumar Ramachandra, Apr 10, 2011
  16. Junio C HamanoApr 11, 2011
  17. Ramkumar RamachandraMay 8, 2011
  18. 06/11 revert: Implement parsing --continue, --abort and --skipRamkumar Ramachandra, Apr 10, 2011
  19. 07/11 revert: Handle conflict resolutions more elegantlyRamkumar Ramachandra, Apr 10, 2011
  20. 08/11 usage: Introduce error_errno correspoding to die_errnoRamkumar Ramachandra, Apr 10, 2011
  21. 09/11 revert: Write head, todo, done filesRamkumar Ramachandra, Apr 10, 2011
  22. 10/11 revert: Give noop a default value while argument parsingRamkumar Ramachandra, Apr 10, 2011
  23. 11/11 revert: Implement --abort processingRamkumar Ramachandra, Apr 10, 2011
  24. Daniel BarkalowApr 10, 2011
  25. Ramkumar RamachandraApr 11, 2011
  26. Jonathan NiederApr 10, 2011
  27. Daniel BarkalowApr 11, 2011
  28. Jonathan NiederApr 11, 2011
  29. Ramkumar RamachandraApr 11, 2011
  30. Christian CouderApr 11, 2011
  31. Ramkumar RamachandraApr 11, 2011
  32. Christian CouderApr 11, 2011
  33. Ramkumar RamachandraApr 11, 2011
  34. Daniel BarkalowApr 11, 2011
  35. Jonathan NiederApr 11, 2011
  36. Daniel BarkalowApr 11, 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.