Skip to content

Commit 6606129

Browse files
committed
Merge branch 'dk/format-patch-ignore-diff-submodule' into maint
Setting diff.submodule to 'log' made "git format-patch" produce broken patches. * dk/format-patch-ignore-diff-submodule: format-patch: ignore diff.submodule setting t4255: test am submodule with diff.submodule
2 parents 74419c2 + 339de50 commit 6606129

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
705705
return 0;
706706
}
707707
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff") ||
708-
!strcmp(var, "color.ui")) {
708+
!strcmp(var, "color.ui") || !strcmp(var, "diff.submodule")) {
709709
return 0;
710710
}
711711
if (!strcmp(var, "format.numbered")) {

t/t4255-am-submodule.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,76 @@ am_3way () {
1818
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
1919
test_submodule_switch "am_3way"
2020

21+
test_expect_success 'setup diff.submodule' '
22+
test_commit one &&
23+
INITIAL=$(git rev-parse HEAD) &&
24+
25+
git init submodule &&
26+
(
27+
cd submodule &&
28+
test_commit two &&
29+
git rev-parse HEAD >../initial-submodule
30+
) &&
31+
git submodule add ./submodule &&
32+
git commit -m first &&
33+
34+
(
35+
cd submodule &&
36+
test_commit three &&
37+
git rev-parse HEAD >../first-submodule
38+
) &&
39+
git add submodule &&
40+
git commit -m second &&
41+
SECOND=$(git rev-parse HEAD) &&
42+
43+
(
44+
cd submodule &&
45+
git mv two.t four.t &&
46+
git commit -m "second submodule" &&
47+
git rev-parse HEAD >../second-submodule
48+
) &&
49+
test_commit four &&
50+
git add submodule &&
51+
git commit --amend --no-edit &&
52+
THIRD=$(git rev-parse HEAD) &&
53+
git submodule update --init
54+
'
55+
56+
run_test() {
57+
START_COMMIT=$1 &&
58+
EXPECT=$2 &&
59+
# Abort any merges in progress: the previous
60+
# test may have failed, and we should clean up.
61+
test_might_fail git am --abort &&
62+
git reset --hard $START_COMMIT &&
63+
rm -f *.patch &&
64+
git format-patch -1 &&
65+
git reset --hard $START_COMMIT^ &&
66+
git submodule update &&
67+
git am *.patch &&
68+
git submodule update &&
69+
git -C submodule rev-parse HEAD >actual &&
70+
test_cmp $EXPECT actual
71+
}
72+
73+
test_expect_success 'diff.submodule unset' '
74+
test_unconfig diff.submodule &&
75+
run_test $SECOND first-submodule
76+
'
77+
78+
test_expect_success 'diff.submodule unset with extra file' '
79+
test_unconfig diff.submodule &&
80+
run_test $THIRD second-submodule
81+
'
82+
83+
test_expect_success 'diff.submodule=log' '
84+
test_config diff.submodule log &&
85+
run_test $SECOND first-submodule
86+
'
87+
88+
test_expect_success 'diff.submodule=log with extra file' '
89+
test_config diff.submodule log &&
90+
run_test $THIRD second-submodule
91+
'
92+
2193
test_done

0 commit comments

Comments
 (0)