diff-index: restore -c/--cc options handling
This fixes 19b2517f (diff-merges: move specific diff-index "-m" handling to diff-index, 2021-05-21). That commit disabled handling of all diff for merges options in diff-index on an assumption that they are unused. However, it later appeared that -c and --cc, even though undocumented and not being covered by tests, happen to have had particular effect on diff-index output. Restore original -c/--cc options handling by diff-index. Signed-off-by: Sergey Organov <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sergey Organov committed
Sep 1, 2021 at 19:52 UTC
5acffd34738f9718caf2a5811bddbf2f40e968a0
3 files changed
+8
-14
builtin/diff-index.c
+3
-3
@@ -29,10 +29,10 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
29
prefix = precompose_argv_prefix(argc, argv, prefix);
30
31
/*
32
- * We need no diff for merges options, and we need to avoid conflict
33
- * with our own meaning of "-m".
32
+ * We need (some of) diff for merges options (e.g., --cc), and we need
33
+ * to avoid conflict with our own meaning of "-m".
34
*/
35
- diff_merges_suppress_options_parsing();
35
+ diff_merges_suppress_m_parsing();
36
37
argc = setup_revisions(argc, argv, &rev, NULL);
38
for (i = 1; i < argc; i++) {
diff-merges.c
+4
-10
@@ -6,7 +6,7 @@ typedef void (*diff_merges_setup_func_t)(struct rev_info *);
6
static void set_separate(struct rev_info *revs);
7
8
static diff_merges_setup_func_t set_to_default = set_separate;
9
-static int suppress_parsing;
9
+static int suppress_m_parsing;
10
11
static void suppress(struct rev_info *revs)
12
{
@@ -91,9 +91,9 @@ int diff_merges_config(const char *value)
91
return 0;
92
}
93
94
-void diff_merges_suppress_options_parsing(void)
94
+void diff_merges_suppress_m_parsing(void)
95
{
96
- suppress_parsing = 1;
96
+ suppress_m_parsing = 1;
97
}
98
99
int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
@@ -102,10 +102,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
102
const char *optarg;
103
const char *arg = argv[0];
104
105
- if (suppress_parsing)
106
- return 0;
107
-
108
- if (!strcmp(arg, "-m")) {
105
+ if (!suppress_m_parsing && !strcmp(arg, "-m")) {
106
set_to_default(revs);
107
} else if (!strcmp(arg, "-c")) {
108
set_combined(revs);
@@ -153,9 +150,6 @@ void diff_merges_set_dense_combined_if_unset(struct rev_info *revs)
150
151
void diff_merges_setup_revs(struct rev_info *revs)
152
{
156
- if (suppress_parsing)
157
- return;
158
-
153
if (revs->combine_merges == 0)
154
revs->dense_combined_merges = 0;
155
if (revs->separate_merges == 0)
diff-merges.h
+1
-1
@@ -11,7 +11,7 @@ struct rev_info;
11
12
int diff_merges_config(const char *value);
13
14
-void diff_merges_suppress_options_parsing(void);
14
+void diff_merges_suppress_m_parsing(void);
15
16
int diff_merges_parse_opts(struct rev_info *revs, const char **argv);
17