diff: introduce DIFF_PICKAXE_KINDS_MASK
authorStefan Beller <sbeller@google.com>
Thu, 4 Jan 2018 22:50:41 +0000 (14:50 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Jan 2018 23:02:40 +0000 (15:02 -0800)
Currently the check whether to perform pickaxing is done via checking
`diffopt->pickaxe`, which contains the command line argument that we
want to pickaxe for. Soon we'll introduce a new type of pickaxing, that
will not store anything in the `.pickaxe` field, so let's migrate the
check to be dependent on pickaxe_opts.

It is not enough to just replace the check for pickaxe by pickaxe_opts,
because flags might be set, but pickaxing was not requested ('-i').
To cope with that, introduce a mask to check only for the bits indicating
the modes of operation.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
combine-diff.c
diff.c
diff.h
revision.c
index 6c1fa896ad01a8de0dcd99be80827d436d2cc857..bd6f2d1efb9b87f00dd782651d713d4982d5239e 100644 (file)
@@ -180,8 +180,8 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
        if (rev->show_notes)
                init_display_notes(&rev->notes_opt);
 
-       if (rev->diffopt.pickaxe || rev->diffopt.filter ||
-           rev->diffopt.flags.follow_renames)
+       if ((rev->diffopt.pickaxe_opts & DIFF_PICKAXE_KINDS_MASK) ||
+           rev->diffopt.filter || rev->diffopt.flags.follow_renames)
                rev->always_show_header = 0;
 
        if (source)
index 2505de119a2be37e9dfb313a2e44db68595ad13f..bc08c4c5b1f68e731efce9adf2a4032eb5246f99 100644 (file)
@@ -1438,7 +1438,7 @@ void diff_tree_combined(const struct object_id *oid,
                        opt->flags.follow_renames       ||
                        opt->break_opt != -1    ||
                        opt->detect_rename      ||
-                       opt->pickaxe            ||
+                       (opt->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)   ||
                        opt->filter;
 
 
diff --git a/diff.c b/diff.c
index 0763e89263efac5fe75a57f0c068049fae610851..5508745dc88f60bbeabcdf318bebf3ce6b36b90d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4173,7 +4173,7 @@ void diff_setup_done(struct diff_options *options)
        /*
         * Also pickaxe would not work very well if you do not say recursive
         */
-       if (options->pickaxe)
+       if (options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)
                options->flags.recursive = 1;
        /*
         * When patches are generated, submodules diffed against the work tree
@@ -5777,7 +5777,7 @@ void diffcore_std(struct diff_options *options)
                if (options->break_opt != -1)
                        diffcore_merge_broken();
        }
-       if (options->pickaxe)
+       if (options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)
                diffcore_pickaxe(options);
        if (options->orderfile)
                diffcore_order(options->orderfile);
diff --git a/diff.h b/diff.h
index 8af1213684e2b5c3f1f877557d8733860520a6cd..9ec4f824fec837dd7e0824d9aa32ead9e185f1c8 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -326,6 +326,8 @@ extern void diff_setup_done(struct diff_options *);
 #define DIFF_PICKAXE_KIND_S    4 /* traditional plumbing counter */
 #define DIFF_PICKAXE_KIND_G    8 /* grep in the patch */
 
+#define DIFF_PICKAXE_KINDS_MASK (DIFF_PICKAXE_KIND_S | DIFF_PICKAXE_KIND_G)
+
 #define DIFF_PICKAXE_IGNORE_CASE       32
 
 extern void diffcore_std(struct diff_options *);
index ccf1d212cee4dba953cbf9674f74df41dedbd9e6..5d11ecaf275635c20bf841bea7a3cced9f409b4f 100644 (file)
@@ -2407,7 +2407,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                revs->diff = 1;
 
        /* Pickaxe, diff-filter and rename following need diffs */
-       if (revs->diffopt.pickaxe ||
+       if ((revs->diffopt.pickaxe_opts & DIFF_PICKAXE_KINDS_MASK) ||
            revs->diffopt.filter ||
            revs->diffopt.flags.follow_renames)
                revs->diff = 1;