aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-05-10 17:10:11 +0200
committerJunio C Hamano <gitster@pobox.com>2013-05-10 10:24:17 -0700
commit6c374008b1a4e3b66469168aace47003e9771e2d (patch)
tree8707e3249bb3398b6231423d7e6784eb3a048881 /diff.c
parent4bd52d0956f5ba2a922968057cabd77a98f6da5c (diff)
downloadgit-6c374008b1a4e3b66469168aace47003e9771e2d.tar.gz
git-6c374008b1a4e3b66469168aace47003e9771e2d.tar.xz
diff_opt: track whether flags have been set explicitly
The diff_opt infrastructure sets flags based on defaults and command line options. It is impossible to tell whether a flag has been set as a default or on explicit request. Update the structure so that this detection is possible: * Add an extra "opt->touched_flags" that keeps track of all the fields that have been touched by DIFF_OPT_SET and DIFF_OPT_CLR. * You may continue setting the default values to the flags, like commands in the "log" family do in cmd_log_init_defaults(), but after you finished setting the defaults, you clear the touched_flags field; * And then you let the usual callchain call diff_opt_parse(), allowing the opt->flags be set or unset, while keeping track of which bits the user touched; * There is an optional callback "opt->set_default" that is called at the very beginning to let you inspect touched_flags and update opt->flags appropriately, before the remainder of the diffcore machinery is set up, taking the opt->flags value into account. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index f0b3e7cfe..7c248726a 100644
--- a/diff.c
+++ b/diff.c
@@ -3213,6 +3213,9 @@ void diff_setup_done(struct diff_options *options)
{
int count = 0;
+ if (options->set_default)
+ options->set_default(options);
+
if (options->output_format & DIFF_FORMAT_NAME)
count++;
if (options->output_format & DIFF_FORMAT_NAME_STATUS)