Skip to content

Commit 5acffd3

Browse files
sorganovgitster
authored andcommitted
diff-index: restore -c/--cc options handling
This fixes 19b2517 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 225bc32 commit 5acffd3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

builtin/diff-index.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
2929
prefix = precompose_argv_prefix(argc, argv, prefix);
3030

3131
/*
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".
3434
*/
35-
diff_merges_suppress_options_parsing();
35+
diff_merges_suppress_m_parsing();
3636

3737
argc = setup_revisions(argc, argv, &rev, NULL);
3838
for (i = 1; i < argc; i++) {

diff-merges.c

+4-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ typedef void (*diff_merges_setup_func_t)(struct rev_info *);
66
static void set_separate(struct rev_info *revs);
77

88
static diff_merges_setup_func_t set_to_default = set_separate;
9-
static int suppress_parsing;
9+
static int suppress_m_parsing;
1010

1111
static void suppress(struct rev_info *revs)
1212
{
@@ -91,9 +91,9 @@ int diff_merges_config(const char *value)
9191
return 0;
9292
}
9393

94-
void diff_merges_suppress_options_parsing(void)
94+
void diff_merges_suppress_m_parsing(void)
9595
{
96-
suppress_parsing = 1;
96+
suppress_m_parsing = 1;
9797
}
9898

9999
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)
102102
const char *optarg;
103103
const char *arg = argv[0];
104104

105-
if (suppress_parsing)
106-
return 0;
107-
108-
if (!strcmp(arg, "-m")) {
105+
if (!suppress_m_parsing && !strcmp(arg, "-m")) {
109106
set_to_default(revs);
110107
} else if (!strcmp(arg, "-c")) {
111108
set_combined(revs);
@@ -153,9 +150,6 @@ void diff_merges_set_dense_combined_if_unset(struct rev_info *revs)
153150

154151
void diff_merges_setup_revs(struct rev_info *revs)
155152
{
156-
if (suppress_parsing)
157-
return;
158-
159153
if (revs->combine_merges == 0)
160154
revs->dense_combined_merges = 0;
161155
if (revs->separate_merges == 0)

diff-merges.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct rev_info;
1111

1212
int diff_merges_config(const char *value);
1313

14-
void diff_merges_suppress_options_parsing(void);
14+
void diff_merges_suppress_m_parsing(void);
1515

1616
int diff_merges_parse_opts(struct rev_info *revs, const char **argv);
1717

0 commit comments

Comments
 (0)