Re: diff.defaultOptions implementation design [was diff.primer]
- From
Jeff King <peff@peff.net>
- Date
- Feb 17, 2009, 19:56 UTC
- Message-ID
- <20090217195658.GC16067@coredump.intra.peff.net>
- In-Reply-To
- <alpine.GSO.2.00.0902162312030.17111@kiwi.cs.ucla.edu>
On Mon, Feb 16, 2009 at 11:24:33PM -0800, Keith Cascio wrote:
> I like the idea of using parse-options to handle diff options and I > too would like all switches negatable. I will come back to the other > ideas you mention if necessary. You laid it all out nicely.
If you are interested in parse-optification of diff options, search the archive for messages from Pierre Habouzit on the topic in the last 6 months or so. It was discussed at the GitTogether, and he had some preliminary patches.
Show 5 quoted lines
> diff_setup(). But diff_setup() must still ascertain at least one
> runtime fact: whether or not we are running one of the commands that
> respects default options {diff, log, show}. Is there an elegant way
> to ascertain that fact from inside diff_setup()? How do you
> recommend? (BTW I believe my design achieves this elegantly).You can impact the argument parsing by touching the diffopt struct before doing the parsing. I.e., something like:
/* we generally get diff options from a rev_info structure */ struct rev_info rev; /* initialize the structures */ init_revisions(&rev, prefix); /* now set any preferences specific to this command */ DIFF_OPT_SET(&rev.diffopt, ALLOW_DEFAULT_CONFIG); /* and then actually parse */ setup_revisions(argc, argv, rev, "HEAD");
See for example how cmd_whatchanged does it in builtin-log.c. Any porcelains which wanted this feature would opt in to it.
-Peff