path: root/Documentation
diff options
authorJunio C Hamano <>2013-05-10 15:10:11 (GMT)
committerJunio C Hamano <>2013-05-10 17:24:17 (GMT)
commit6c374008b1a4e3b66469168aace47003e9771e2d (patch)
tree8707e3249bb3398b6231423d7e6784eb3a048881 /Documentation
parent4bd52d0956f5ba2a922968057cabd77a98f6da5c (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation')
1 files changed, 9 insertions, 1 deletions
diff --git a/Documentation/technical/api-diff.txt b/Documentation/technical/api-diff.txt
index 2d2ebc0..8b001de 100644
--- a/Documentation/technical/api-diff.txt
+++ b/Documentation/technical/api-diff.txt
@@ -28,7 +28,8 @@ Calling sequence
* Call `diff_setup_done()`; this inspects the options set up so far for
internal consistency and make necessary tweaking to it (e.g. if
- textual patch output was asked, recursive behaviour is turned on).
+ textual patch output was asked, recursive behaviour is turned on);
+ the callback set_default in diff_options can be used to tweak this more.
* As you find different pairs of files, call `diff_change()` to feed
modified files, `diff_addremove()` to feed created or deleted files,
@@ -115,6 +116,13 @@ Notable members are:
operation, but some do not have anything to do with the diffcore
+ Records whether a flag has been changed due to user request
+ (rather than just set/unset by default).
+ Callback which allows tweaking the options in diff_setup_done().
Affects the way how a file that is seemingly binary is treated.