EXPECT_HEADER_COUNT=4 \
git rebase -i $base
) &&
- git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
+ commit_body HEAD >actual-squash-fixup &&
test_cmp expect-squash-fixup actual-squash-fixup &&
git cat-file commit HEAD@{2} >actual &&
test_grep "^# This is a combination of 3 commits\." actual &&
test_tick &&
git commit -F F &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
+ commit_body HEAD >F0 &&
git checkout diff-in-message &&
echo "commit log message containing a diff" >G &&
test_tick &&
git commit -F G &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
+ commit_body HEAD >G0 &&
git checkout empty-message-merge &&
echo file3 >file3 &&
test_expect_success 'rebase commit with multi-line subject' '
git rebase main multi-line-subject &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
+ commit_body HEAD >F1 &&
test_cmp F0 F1 &&
test_cmp F F0
test_expect_success 'rebase commit with diff in message' '
git rebase main diff-in-message &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
+ commit_body HEAD >G1 &&
test_cmp G0 G1 &&
test_cmp G G0
'
git checkout side &&
git rebase main &&
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
- git cat-file commit side@{1} | sed -e "1,/^\$/d" >expect &&
+ commit_body HEAD >actual &&
+ commit_body side@{1} >expect &&
test_cmp expect actual
'
compare_msg () {
iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
- git cat-file commit HEAD >raw &&
- sed "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
}
git rev-list HEAD >actual &&
test_line_count = 3 actual &&
iconv -f $old -t UTF-8 "$TEST_DIRECTORY"/t3900/$msg >expect &&
- git cat-file commit HEAD^ >raw &&
- (sed "1,/^$/d" raw | iconv -f $new -t utf-8) >actual &&
+ commit_body HEAD^ >raw &&
+ iconv -f $new -t utf-8 <raw >actual &&
test_cmp expect actual
'
}
Signed-off-by: J C H <j@c.h>
EOF
git commit -F msg &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
+ commit_body HEAD >original &&
git format-patch --stdout -1 >patch &&
git reset --hard HEAD^ &&
cat original &&
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
) >expect &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual &&
cat >msg <<-\EOF &&
EOF
git reset HEAD^ &&
git commit -F msg file &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
+ commit_body HEAD >original &&
git format-patch --stdout -1 >patch &&
git reset --hard HEAD^ &&
echo &&
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
) >expect &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_expect_success 'nonexistent optional template file in config' '
test_config commit.template ":(optional)$(pwd)"/notexist &&
GIT_EDITOR="echo hello >" git commit --allow-empty &&
- git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ commit_body HEAD >actual &&
echo hello >expect &&
test_cmp expect actual
'
test_expect_success '--signoff' '
echo "yet another content *narf*" >> foo &&
echo "zort" | git commit -s -F - foo &&
- git cat-file commit HEAD | sed "1,/^\$/d" > output &&
+ commit_body HEAD >output &&
test_cmp expect output
'
echo 1 >positive &&
git add positive &&
git commit -s -m "thank you" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo thank you &&
echo &&
git commit -s -m "thank you
$existing" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo thank you &&
echo &&
git commit -s -m "welcome
$alt" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo welcome &&
echo &&
We have now
$alt" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo welcome &&
echo &&
non-trailer line
Myfooter: x" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo subject &&
echo &&
non-trailer line
Myfooter: x" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo subject &&
echo &&
>negative &&
git add negative &&
git commit -m "one" -m "two" -m "three" &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
(
echo one &&
echo &&
Reported-by: C3 E3
Mentored-by: C4 E4
EOF
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Mentored-by: C4 E4" \
--trailer "Helped-by: C3 E3" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Reported-by: C3 E3" \
--trailer "Mentored-by: C4 E4" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Mentored-by: C5 E5" \
--trailer "Reviewed-by: C6 E6" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Reported-by: C3 E3" \
--trailer "Mentored-by: C5 E5" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Mentored-by: C4 E4" \
--trailer "Reported-by: C3 E3" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Reported-by: C3 E3" \
--trailer "Mentored-by: C4 E4" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Signed-off-by: C O Mitter <committer@example.com>" \
--trailer "Signed-off-by: C1 E1" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Mentored-by: C4 E4" \
--trailer "Mentored-by: C5 E5" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Mentored-by: C3 E3" \
--trailer "Mentored-by: C2 E2" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Helped-by: C5 E5" \
--trailer "Based-by: C6 E6" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
commit --trailer "Helped-by: C5 E5" \
--trailer "Based-by: C6 E6" \
--amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
EOF
git -c trailer.ack.key="Acked-by" \
commit --trailer "ack = Peff" -m "hello" &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
git -c trailer.separators=":=#" \
-c trailer.bug.key="Bug #" \
commit --trailer "bug = 42" -m "I hate bug" &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
-c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \
git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \
commit --trailer "report = author" --amend &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
echo &&
echo "my-trailer: value"
} >expected &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
echo &&
echo "my-trailer: value"
} >expected &&
- git cat-file commit HEAD >commit.msg &&
- sed -e "1,/^\$/d" commit.msg >actual &&
+ commit_body HEAD >actual &&
test_cmp expected actual
'
>negative &&
git add negative &&
git commit -m "one" -m "two" -m "three" &&
- actual=$(git cat-file commit HEAD >tmp && sed -e "1,/^\$/d" tmp && rm tmp) &&
+ actual=$(commit_body HEAD) &&
expected=$(test_write_lines "one" "" "two" "" "three") &&
test "z$actual" = "z$expected"
echo >>negative &&
git commit --cleanup=verbatim --no-status -t expect -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
echo >>negative &&
git commit --cleanup=verbatim -F expect -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
echo >>negative &&
git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_write_lines "" "# text" "" >text &&
echo "# text" >expect &&
git commit --cleanup=whitespace -F text -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
# to be kept, too
EOF
git commit --cleanup=scissors -e -F text -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
to be removed
EOF
git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_must_be_empty actual
'
test_write_lines "" "# text" "sample" "" >text &&
echo sample >expect &&
git commit --cleanup=strip -F text -a &&
- git cat-file -p HEAD >raw &&
- sed -e "1,/^\$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
git reset --hard &&
git commit -s -m "hello: kitty" --allow-empty &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_line_count = 3 actual
'
sed -n -e '/^$/q' -e '/^author /p'
}
-message_body () {
- git cat-file commit "$1" |
- sed -e '1,/^$/d'
-}
-
test_expect_success '-C option copies authorship and message' '
test_commit --author Frigate\ \<flying@over.world\> \
"Initial Commit" foo Initial Initial &&
author_header HEAD >actual &&
test_cmp expect actual &&
- message_body Initial >expect &&
- message_body HEAD >actual &&
+ commit_body Initial >expect &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
author_header HEAD >actual &&
test_cmp expect actual &&
- message_body Initial >expect &&
- message_body HEAD >actual &&
+ commit_body Initial >expect &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
author_header HEAD >actual &&
test_cmp expect actual &&
- message_body Initial >expect &&
- message_body HEAD >actual &&
+ commit_body Initial >expect &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_cmp expect actual &&
echo "amend test" >expect &&
- message_body HEAD >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_cmp expect actual &&
echo "Changed again" >expect &&
- message_body HEAD >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_cmp expect actual &&
echo "This is a MERGE_MSG" >expect &&
- message_body HEAD >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
# Conflicts:
# file
EOF
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
# Conflicts:
# file
EOF
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
# Conflicts:
# file
EOF
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
git reset --hard c0 &&
EDITOR=./editor git merge --no-ff --edit c1 &&
verify_parents $c0 $c1 &&
- git cat-file commit HEAD >raw &&
- test_grep "work done on the side branch" raw &&
- sed "1,/^$/d" >actual raw &&
+ commit_body HEAD >actual &&
+ test_grep "work done on the side branch" actual &&
test_cmp expected actual
'
test_expect_success 'merge c2 with a custom message' '
git reset --hard c1 &&
git merge -m "$(cat exp.subject)" c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp exp.subject actual
'
test_expect_success 'merge --log appends to custom message' '
git reset --hard c1 &&
git merge --log -m "$(cat exp.subject)" c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp exp.log actual
'
test_expect_success 'cleanup commit messages (verbatim option)' '
git reset --hard c1 &&
git merge --cleanup=verbatim -F expect c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_write_lines "" "# text" "" >text &&
echo "# text" >expect &&
git merge --cleanup=whitespace -F text c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
# to be kept, too
EOF
git merge --cleanup=scissors -e -F text c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_write_lines "" "# text" "sample" "" >text &&
echo sample >expect &&
git merge --cleanup=strip -F text c2 &&
- git cat-file commit HEAD >raw &&
- sed -e "1,/^$/d" raw >actual &&
+ commit_body HEAD >actual &&
test_cmp expect actual
'
test_commit main-branch-2 file2 2 &&
git checkout other-branch &&
git merge main --signoff --no-edit &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
test_cmp expected-signed actual
'
test_commit main-branch-3 file3 3 &&
git checkout other-branch &&
git merge main --no-edit &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
test_cmp expected-unsigned actual
'
test_commit main-branch-4 file4 4 &&
git checkout other-branch &&
git merge main --no-edit --signoff --no-signoff &&
- git cat-file commit HEAD >commit &&
- sed -e "1,/^\$/d" commit >actual &&
+ commit_body HEAD >actual &&
test_cmp expected-unsigned actual
'