Skip to content

Commit 17c13e6

Browse files
sorganovgitster
authored andcommitted
diff-merges: introduce log.diffMerges config variable
New log.diffMerges configuration variable sets the format that --diff-merges=on will be using. The default is "separate". t4013: add the following tests for log.diffMerges config: * Test that wrong values are denied. * Test that the value of log.diffMerges properly affects both --diff-merges=on and -m. t9902: fix completion tests for log.d* to match log.diffMerges. Added documentation for log.diffMerges. Signed-off-by: Sergey Organov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38fc4db commit 17c13e6

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

Documentation/config/log.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ log.excludeDecoration::
2424
the config option can be overridden by the `--decorate-refs`
2525
option.
2626

27+
log.diffMerges::
28+
Set default diff format to be used for merge commits. See
29+
`--diff-merges` in linkgit:git-log[1] for details.
30+
Defaults to `separate`.
31+
2732
log.follow::
2833
If `true`, `git log` will act as if the `--follow` option was used when
2934
a single <path> is given. This has the same limitations as `--follow`,

builtin/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ static int git_log_config(const char *var, const char *value, void *cb)
481481
decoration_style = 0; /* maybe warn? */
482482
return 0;
483483
}
484+
if (!strcmp(var, "log.diffmerges"))
485+
return diff_merges_config(value);
484486
if (!strcmp(var, "log.showroot")) {
485487
default_show_root = git_config_bool(var, value);
486488
return 0;

diff-merges.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ static void set_diff_merges(struct rev_info *revs, const char *optarg)
9090
* Public functions. They are in the order they are called.
9191
*/
9292

93+
int diff_merges_config(const char *value)
94+
{
95+
diff_merges_setup_func_t func = func_by_opt(value);
96+
97+
if (!func)
98+
return -1;
99+
100+
set_to_default = func;
101+
return 0;
102+
}
103+
93104
int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
94105
{
95106
int argcount = 1;

diff-merges.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
struct rev_info;
1111

12+
int diff_merges_config(const char *value);
13+
1214
int diff_merges_parse_opts(struct rev_info *revs, const char **argv);
1315

1416
void diff_merges_suppress(struct rev_info *revs);

t/t4013-diff-various.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,29 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
460460
test_cmp expected actual
461461
'
462462

463+
test_expect_success 'deny wrong log.diffMerges config' '
464+
test_config log.diffMerges wrong-value &&
465+
test_expect_code 128 git log
466+
'
467+
468+
test_expect_success 'git config log.diffMerges first-parent' '
469+
git log -p --diff-merges=first-parent master >result &&
470+
process_diffs result >expected &&
471+
test_config log.diffMerges first-parent &&
472+
git log -p --diff-merges=on master >result &&
473+
process_diffs result >actual &&
474+
test_cmp expected actual
475+
'
476+
477+
test_expect_success 'git config log.diffMerges first-parent vs -m' '
478+
git log -p --diff-merges=first-parent master >result &&
479+
process_diffs result >expected &&
480+
test_config log.diffMerges first-parent &&
481+
git log -p -m master >result &&
482+
process_diffs result >actual &&
483+
test_cmp expected actual
484+
'
485+
463486
test_expect_success 'log -S requires an argument' '
464487
test_must_fail git log -S
465488
'

t/t9902-completion.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,7 @@ test_expect_success 'git config - variable name' '
23062306
test_completion "git config log.d" <<-\EOF
23072307
log.date Z
23082308
log.decorate Z
2309+
log.diffMerges Z
23092310
EOF
23102311
'
23112312

@@ -2327,6 +2328,7 @@ test_expect_success 'git -c - variable name' '
23272328
test_completion "git -c log.d" <<-\EOF
23282329
log.date=Z
23292330
log.decorate=Z
2331+
log.diffMerges=Z
23302332
EOF
23312333
'
23322334

@@ -2348,6 +2350,7 @@ test_expect_success 'git clone --config= - variable name' '
23482350
test_completion "git clone --config=log.d" <<-\EOF
23492351
log.date=Z
23502352
log.decorate=Z
2353+
log.diffMerges=Z
23512354
EOF
23522355
'
23532356

0 commit comments

Comments
 (0)