Skip to content

Commit 85785df

Browse files
committed
Merge branch 'mk/show-s-no-extra-blank-line-for-merges' into maint
"git show -s" (i.e. show log message only) used to incorrectly emit an extra blank line after a merge commit. * mk/show-s-no-extra-blank-line-for-merges: git-show: fix 'git show -s' to not add extra terminator after merge commit
2 parents d9036cd + ad2f725 commit 85785df

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

combine-diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,8 @@ void diff_tree_combined(const unsigned char *sha1,
13391339
if (show_log_first && i == 0) {
13401340
show_log(rev);
13411341

1342-
if (rev->verbose_header && opt->output_format)
1342+
if (rev->verbose_header && opt->output_format &&
1343+
opt->output_format != DIFF_FORMAT_NO_OUTPUT)
13431344
printf("%s%c", diff_line_prefix(opt),
13441345
opt->line_termination);
13451346
}

t/t1507-rev-parse-upstream.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ test_expect_success 'merge my-side@{u} records the correct name' '
121121
git branch -D new ;# can fail but is ok
122122
git branch -t new my-side@{u} &&
123123
git merge -s ours new@{u} &&
124-
git show -s --pretty=format:%s >actual &&
124+
git show -s --pretty=tformat:%s >actual &&
125125
echo "Merge remote-tracking branch ${sq}origin/side${sq}" >expect &&
126126
test_cmp expect actual
127127
)

t/t7007-show.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ test_expect_success 'set up a bit of history' '
2424
git tag -m "annotated tag" annotated &&
2525
git checkout -b side HEAD^^ &&
2626
test_commit side2 &&
27-
test_commit side3
27+
test_commit side3 &&
28+
test_merge merge main3
2829
'
2930

3031
test_expect_success 'showing two commits' '
@@ -109,8 +110,11 @@ test_expect_success 'showing range' '
109110
'
110111

111112
test_expect_success '-s suppresses diff' '
112-
echo main3 >expect &&
113-
git show -s --format=%s main3 >actual &&
113+
cat >expect <<-\EOF &&
114+
merge
115+
main3
116+
EOF
117+
git show -s --format=%s merge main3 >actual &&
114118
test_cmp expect actual
115119
'
116120

t/t7600-merge.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ create_merge_msgs () {
5757
git log --no-merges ^HEAD c2 c3
5858
} >squash.1-5-9 &&
5959
: >msg.nologff &&
60-
echo >msg.nolognoff &&
60+
: >msg.nolognoff &&
6161
{
6262
echo "* tag 'c3':" &&
63-
echo " commit 3" &&
64-
echo
63+
echo " commit 3"
6564
} >msg.log
6665
}
6766

@@ -71,7 +70,7 @@ verify_merge () {
7170
git diff --exit-code &&
7271
if test -n "$3"
7372
then
74-
git show -s --pretty=format:%s HEAD >msg.act &&
73+
git show -s --pretty=tformat:%s HEAD >msg.act &&
7574
test_cmp "$3" msg.act
7675
fi
7776
}
@@ -620,10 +619,10 @@ test_expect_success 'merge early part of c2' '
620619
git tag c6 &&
621620
git branch -f c5-branch c5 &&
622621
git merge c5-branch~1 &&
623-
git show -s --pretty=format:%s HEAD >actual.branch &&
622+
git show -s --pretty=tformat:%s HEAD >actual.branch &&
624623
git reset --keep HEAD^ &&
625624
git merge c5~1 &&
626-
git show -s --pretty=format:%s HEAD >actual.tag &&
625+
git show -s --pretty=tformat:%s HEAD >actual.tag &&
627626
test_cmp expected.branch actual.branch &&
628627
test_cmp expected.tag actual.tag
629628
'

0 commit comments

Comments
 (0)