2007-07-31 23:37:30 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
|
|
|
|
#
|
|
|
|
|
|
|
|
# FIXME: Test the various index usages, -i and -o, test reflog,
|
2007-12-08 15:29:47 +03:00
|
|
|
# signoff
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-09-03 12:59:33 +04:00
|
|
|
test_description='git commit'
|
2007-07-31 23:37:30 +04:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"initial status" \
|
|
|
|
"echo 'bongo bongo' >file &&
|
2008-09-03 12:59:33 +04:00
|
|
|
git add file && \
|
|
|
|
git status | grep 'Initial commit'"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"fail initial amend" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit --amend"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"initial commit" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"git commit -m initial"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"invalid options 1" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit -m foo -m bar -F file"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"invalid options 2" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit -C HEAD -m illegal"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-11-12 18:15:39 +03:00
|
|
|
"using paths with -a" \
|
|
|
|
"echo King of the bongo >file &&
|
2008-09-03 12:59:33 +04:00
|
|
|
test_must_fail git commit -m foo -a file"
|
2007-11-12 18:15:39 +03:00
|
|
|
|
2009-04-03 23:33:59 +04:00
|
|
|
test_expect_success PERL \
|
2007-11-12 18:15:39 +03:00
|
|
|
"using paths with --interactive" \
|
|
|
|
"echo bong-o-bong >file &&
|
2008-09-03 12:59:33 +04:00
|
|
|
! (echo 7 | git commit -m foo --interactive file)"
|
2007-11-12 18:15:39 +03:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"using invalid commit with -C" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit -C bogus"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"testing nothing to commit" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit -m initial"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"next commit" \
|
|
|
|
"echo 'bongo bongo bongo' >file \
|
2008-09-03 12:59:33 +04:00
|
|
|
git commit -m next -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"commit message from non-existing file" \
|
|
|
|
"echo 'more bongo: bongo bongo bongo bongo' >file && \
|
2008-09-03 12:59:33 +04:00
|
|
|
test_must_fail git commit -F gah -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
# Empty except stray tabs and spaces on a few lines.
|
|
|
|
sed -e 's/@$//' >msg <<EOF
|
|
|
|
@
|
|
|
|
|
|
|
|
@
|
|
|
|
Signed-off-by: hula
|
|
|
|
EOF
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-07-31 23:37:30 +04:00
|
|
|
"empty commit message" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"test_must_fail git commit -F msg -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"commit message from file" \
|
|
|
|
"echo 'this is the commit message, coming from a file' >msg && \
|
2008-09-03 12:59:33 +04:00
|
|
|
git commit -F msg -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
cat >editor <<\EOF
|
|
|
|
#!/bin/sh
|
2008-05-04 09:37:59 +04:00
|
|
|
sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
|
|
|
|
mv "$1-" "$1"
|
2007-07-31 23:37:30 +04:00
|
|
|
EOF
|
|
|
|
chmod 755 editor
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"amend commit" \
|
Do not use VISUAL editor on dumb terminals
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
or set to "dumb". Traditionally, VISUAL is set to a screen
editor and EDITOR to a line-based editor, which should be more
useful in that situation.
vim, for example, is happy to assume a terminal supports ANSI
sequences even if TERM is dumb (e.g., when running from a text
editor like Acme). git already refuses to fall back to vi on a
dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
unset, but without this patch, that check is suppressed by
VISUAL=vi.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-12 02:56:07 +03:00
|
|
|
"EDITOR=./editor git commit --amend"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2008-02-01 12:50:53 +03:00
|
|
|
test_expect_success \
|
2007-08-02 05:14:41 +04:00
|
|
|
"passing -m and -F" \
|
2007-07-31 23:37:30 +04:00
|
|
|
"echo 'enough with the bongos' >file && \
|
2008-09-03 12:59:33 +04:00
|
|
|
test_must_fail git commit -F msg -m amending ."
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"using message from other commit" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"git commit -C HEAD^ ."
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
cat >editor <<\EOF
|
|
|
|
#!/bin/sh
|
2008-05-04 09:37:59 +04:00
|
|
|
sed -e "s/amend/older/g" < "$1" > "$1-"
|
|
|
|
mv "$1-" "$1"
|
2007-07-31 23:37:30 +04:00
|
|
|
EOF
|
|
|
|
chmod 755 editor
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"editing message from other commit" \
|
|
|
|
"echo 'hula hula' >file && \
|
Do not use VISUAL editor on dumb terminals
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
or set to "dumb". Traditionally, VISUAL is set to a screen
editor and EDITOR to a line-based editor, which should be more
useful in that situation.
vim, for example, is happy to assume a terminal supports ANSI
sequences even if TERM is dumb (e.g., when running from a text
editor like Acme). git already refuses to fall back to vi on a
dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
unset, but without this patch, that check is suppressed by
VISUAL=vi.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-12 02:56:07 +03:00
|
|
|
EDITOR=./editor git commit -c HEAD^ -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"message from stdin" \
|
|
|
|
"echo 'silly new contents' >file && \
|
2008-09-03 12:59:33 +04:00
|
|
|
echo commit message from stdin | git commit -F - -a"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"overriding author from command line" \
|
|
|
|
"echo 'gak' >file && \
|
commit: show interesting ident information in summary
There are a few cases of user identity information that we consider
interesting:
(1) When the author and committer identities do not match.
(2) When the committer identity was picked automatically from the
username, hostname and GECOS information.
In these cases, we already show the information in the commit
message template. However, users do not always see that template
because they might use "-m" or "-F". With this patch, we show these
interesting cases after the commit, along with the subject and
change summary. The new output looks like:
$ git commit \
-m "federalist papers" \
--author='Publius <alexander@hamilton.com>'
[master 3d226a7] federalist papers
Author: Publius <alexander@hamilton.com>
1 files changed, 1 insertions(+), 0 deletions(-)
for case (1), and:
$ git config --global --unset user.name
$ git config --global --unset user.email
$ git commit -m foo
[master 7c2a927] foo
Committer: Jeff King <peff@c-71-185-130-222.hsd1.va.comcast.net>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name Your Name
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
1 files changed, 1 insertions(+), 0 deletions(-)
for case (2).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-13 20:39:51 +03:00
|
|
|
git commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a >output 2>&1"
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"commit --author output mentions author" \
|
|
|
|
"grep Rubber.Duck output"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2009-04-03 23:33:59 +04:00
|
|
|
test_expect_success PERL \
|
2007-07-31 23:37:30 +04:00
|
|
|
"interactive add" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"echo 7 | git commit --interactive | grep 'What now'"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
"showing committed revisions" \
|
2008-09-03 12:59:33 +04:00
|
|
|
"git rev-list HEAD >current"
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2009-01-09 20:30:05 +03:00
|
|
|
cat >editor <<\EOF
|
|
|
|
#!/bin/sh
|
|
|
|
sed -e "s/good/bad/g" < "$1" > "$1-"
|
|
|
|
mv "$1-" "$1"
|
|
|
|
EOF
|
|
|
|
chmod 755 editor
|
|
|
|
|
|
|
|
cat >msg <<EOF
|
|
|
|
A good commit message.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'editor not invoked if -F is given' '
|
|
|
|
echo "moo" >file &&
|
Do not use VISUAL editor on dumb terminals
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
or set to "dumb". Traditionally, VISUAL is set to a screen
editor and EDITOR to a line-based editor, which should be more
useful in that situation.
vim, for example, is happy to assume a terminal supports ANSI
sequences even if TERM is dumb (e.g., when running from a text
editor like Acme). git already refuses to fall back to vi on a
dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
unset, but without this patch, that check is suppressed by
VISUAL=vi.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-12 02:56:07 +03:00
|
|
|
EDITOR=./editor git commit -a -F msg &&
|
2009-01-09 20:30:05 +03:00
|
|
|
git show -s --pretty=format:"%s" | grep -q good &&
|
|
|
|
echo "quack" >file &&
|
Do not use VISUAL editor on dumb terminals
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
or set to "dumb". Traditionally, VISUAL is set to a screen
editor and EDITOR to a line-based editor, which should be more
useful in that situation.
vim, for example, is happy to assume a terminal supports ANSI
sequences even if TERM is dumb (e.g., when running from a text
editor like Acme). git already refuses to fall back to vi on a
dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
unset, but without this patch, that check is suppressed by
VISUAL=vi.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-12 02:56:07 +03:00
|
|
|
echo "Another good message." | EDITOR=./editor git commit -a -F - &&
|
2009-01-09 20:30:05 +03:00
|
|
|
git show -s --pretty=format:"%s" | grep -q good
|
|
|
|
'
|
2007-07-31 23:37:30 +04:00
|
|
|
# We could just check the head sha1, but checking each commit makes it
|
|
|
|
# easier to isolate bugs.
|
|
|
|
|
|
|
|
cat >expected <<\EOF
|
|
|
|
72c0dc9855b0c9dadcbfd5a31cab072e0cb774ca
|
|
|
|
9b88fc14ce6b32e3d9ee021531a54f18a5cf38a2
|
|
|
|
3536bbb352c3a1ef9a420f5b4242d48578b92aa7
|
|
|
|
d381ac431806e53f3dd7ac2f1ae0534f36d738b9
|
|
|
|
4fd44095ad6334f3ef72e4c5ec8ddf108174b54a
|
|
|
|
402702b49136e7587daa9280e91e4bb7cb2179f7
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
2008-09-03 12:59:33 +04:00
|
|
|
'validate git rev-list output.' \
|
2008-09-10 21:32:44 +04:00
|
|
|
'test_cmp expected current'
|
2007-07-31 23:37:30 +04:00
|
|
|
|
2007-09-15 03:53:58 +04:00
|
|
|
test_expect_success 'partial commit that involves removal (1)' '
|
2007-09-13 03:04:22 +04:00
|
|
|
|
|
|
|
git rm --cached file &&
|
|
|
|
mv file elif &&
|
|
|
|
git add elif &&
|
|
|
|
git commit -m "Partial: add elif" elif &&
|
|
|
|
git diff-tree --name-status HEAD^ HEAD >current &&
|
|
|
|
echo "A elif" >expected &&
|
2008-09-10 21:32:44 +04:00
|
|
|
test_cmp expected current
|
2007-09-13 03:04:22 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-09-15 03:53:58 +04:00
|
|
|
test_expect_success 'partial commit that involves removal (2)' '
|
2007-09-13 03:04:22 +04:00
|
|
|
|
|
|
|
git commit -m "Partial: remove file" file &&
|
|
|
|
git diff-tree --name-status HEAD^ HEAD >current &&
|
|
|
|
echo "D file" >expected &&
|
2008-09-10 21:32:44 +04:00
|
|
|
test_cmp expected current
|
2007-09-13 03:04:22 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-09-15 03:53:58 +04:00
|
|
|
test_expect_success 'partial commit that involves removal (3)' '
|
|
|
|
|
|
|
|
git rm --cached elif &&
|
|
|
|
echo elif >elif &&
|
|
|
|
git commit -m "Partial: modify elif" elif &&
|
|
|
|
git diff-tree --name-status HEAD^ HEAD >current &&
|
|
|
|
echo "M elif" >expected &&
|
2008-09-10 21:32:44 +04:00
|
|
|
test_cmp expected current
|
2007-09-15 03:53:58 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-10 12:49:34 +03:00
|
|
|
author="The Real Author <someguy@his.email.org>"
|
|
|
|
test_expect_success 'amend commit to fix author' '
|
|
|
|
|
|
|
|
oldtick=$GIT_AUTHOR_DATE &&
|
|
|
|
test_tick &&
|
|
|
|
git reset --hard &&
|
|
|
|
git cat-file -p HEAD |
|
|
|
|
sed -e "s/author.*/author $author $oldtick/" \
|
|
|
|
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
|
|
|
|
expected &&
|
|
|
|
git commit --amend --author="$author" &&
|
|
|
|
git cat-file -p HEAD > current &&
|
2008-09-10 21:32:44 +04:00
|
|
|
test_cmp expected current
|
2007-11-10 12:49:34 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-03 01:16:18 +03:00
|
|
|
test_expect_success 'amend commit to fix date' '
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
newtick=$GIT_AUTHOR_DATE &&
|
|
|
|
git reset --hard &&
|
|
|
|
git cat-file -p HEAD |
|
|
|
|
sed -e "s/author.*/author $author $newtick/" \
|
|
|
|
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
|
|
|
|
expected &&
|
|
|
|
git commit --amend --date="$newtick" &&
|
|
|
|
git cat-file -p HEAD > current &&
|
|
|
|
test_cmp expected current
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-10 12:49:34 +03:00
|
|
|
test_expect_success 'sign off (1)' '
|
|
|
|
|
|
|
|
echo 1 >positive &&
|
|
|
|
git add positive &&
|
|
|
|
git commit -s -m "thank you" &&
|
|
|
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
|
|
|
|
(
|
|
|
|
echo thank you
|
|
|
|
echo
|
|
|
|
git var GIT_COMMITTER_IDENT |
|
|
|
|
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
|
|
|
|
) >expected &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-11-10 12:49:34 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'sign off (2)' '
|
|
|
|
|
|
|
|
echo 2 >positive &&
|
|
|
|
git add positive &&
|
|
|
|
existing="Signed-off-by: Watch This <watchthis@example.com>" &&
|
|
|
|
git commit -s -m "thank you
|
|
|
|
|
|
|
|
$existing" &&
|
|
|
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
|
|
|
|
(
|
|
|
|
echo thank you
|
|
|
|
echo
|
|
|
|
echo $existing
|
|
|
|
git var GIT_COMMITTER_IDENT |
|
|
|
|
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
|
|
|
|
) >expected &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-11-10 12:49:34 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-10-28 20:13:44 +03:00
|
|
|
test_expect_success 'signoff gap' '
|
|
|
|
|
|
|
|
echo 3 >positive &&
|
|
|
|
git add positive &&
|
|
|
|
alt="Alt-RFC-822-Header: Value" &&
|
|
|
|
git commit -s -m "welcome
|
|
|
|
|
|
|
|
$alt" &&
|
|
|
|
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
|
|
|
|
(
|
|
|
|
echo welcome
|
|
|
|
echo
|
|
|
|
echo $alt
|
|
|
|
git var GIT_COMMITTER_IDENT |
|
|
|
|
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
|
|
|
|
) >expected &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'signoff gap 2' '
|
|
|
|
|
|
|
|
echo 4 >positive &&
|
|
|
|
git add positive &&
|
|
|
|
alt="fixed: 34" &&
|
|
|
|
git commit -s -m "welcome
|
|
|
|
|
|
|
|
We have now
|
|
|
|
$alt" &&
|
|
|
|
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
|
|
|
|
(
|
|
|
|
echo welcome
|
|
|
|
echo
|
|
|
|
echo We have now
|
|
|
|
echo $alt
|
|
|
|
echo
|
|
|
|
git var GIT_COMMITTER_IDENT |
|
|
|
|
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
|
|
|
|
) >expected &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2007-11-10 12:49:34 +03:00
|
|
|
test_expect_success 'multiple -m' '
|
|
|
|
|
|
|
|
>negative &&
|
|
|
|
git add negative &&
|
|
|
|
git commit -m "one" -m "two" -m "three" &&
|
|
|
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
|
|
|
|
(
|
|
|
|
echo one
|
|
|
|
echo
|
|
|
|
echo two
|
|
|
|
echo
|
|
|
|
echo three
|
|
|
|
) >expected &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-11-10 12:49:34 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-02 18:33:06 +03:00
|
|
|
author="The Real Author <someguy@his.email.org>"
|
|
|
|
test_expect_success 'amend commit to fix author' '
|
|
|
|
|
|
|
|
oldtick=$GIT_AUTHOR_DATE &&
|
|
|
|
test_tick &&
|
|
|
|
git reset --hard &&
|
|
|
|
git cat-file -p HEAD |
|
|
|
|
sed -e "s/author.*/author $author $oldtick/" \
|
|
|
|
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
|
|
|
|
expected &&
|
|
|
|
git commit --amend --author="$author" &&
|
|
|
|
git cat-file -p HEAD > current &&
|
2008-09-10 21:32:44 +04:00
|
|
|
test_cmp expected current
|
2007-11-02 18:33:06 +03:00
|
|
|
|
|
|
|
'
|
2007-11-15 17:49:58 +03:00
|
|
|
|
|
|
|
test_expect_success 'git commit <file> with dirty index' '
|
|
|
|
echo tacocat > elif &&
|
|
|
|
echo tehlulz > chz &&
|
|
|
|
git add chz &&
|
|
|
|
git commit elif -m "tacocat is a palindrome" &&
|
|
|
|
git show --stat | grep elif &&
|
|
|
|
git diff --cached | grep chz
|
|
|
|
'
|
|
|
|
|
2007-12-03 10:24:50 +03:00
|
|
|
test_expect_success 'same tree (single parent)' '
|
|
|
|
|
2007-12-05 04:16:33 +03:00
|
|
|
git reset --hard
|
|
|
|
|
2007-12-03 10:24:50 +03:00
|
|
|
if git commit -m empty
|
|
|
|
then
|
|
|
|
echo oops -- should have complained
|
|
|
|
false
|
|
|
|
else
|
|
|
|
: happy
|
|
|
|
fi
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-03 11:03:10 +03:00
|
|
|
test_expect_success 'same tree (single parent) --allow-empty' '
|
|
|
|
|
|
|
|
git commit --allow-empty -m "forced empty" &&
|
|
|
|
git cat-file commit HEAD | grep forced
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-03 10:24:50 +03:00
|
|
|
test_expect_success 'same tree (merge and amend merge)' '
|
|
|
|
|
|
|
|
git checkout -b side HEAD^ &&
|
|
|
|
echo zero >zero &&
|
|
|
|
git add zero &&
|
|
|
|
git commit -m "add zero" &&
|
|
|
|
git checkout master &&
|
|
|
|
|
|
|
|
git merge -s ours side -m "empty ok" &&
|
|
|
|
git diff HEAD^ HEAD >actual &&
|
|
|
|
: >expected &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual &&
|
2007-12-03 10:24:50 +03:00
|
|
|
|
|
|
|
git commit --amend -m "empty really ok" &&
|
|
|
|
git diff HEAD^ HEAD >actual &&
|
|
|
|
: >expected &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-12-03 10:24:50 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-14 22:57:22 +03:00
|
|
|
test_expect_success 'amend using the message from another commit' '
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty -m "old commit" &&
|
|
|
|
old=$(git rev-parse --verify HEAD) &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty -m "new commit" &&
|
|
|
|
new=$(git rev-parse --verify HEAD) &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty --amend -C "$old" &&
|
|
|
|
git show --pretty="format:%ad %s" "$old" >expected &&
|
|
|
|
git show --pretty="format:%ad %s" HEAD >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-12-14 22:57:22 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-02-03 11:00:09 +03:00
|
|
|
test_expect_success 'amend using the message from a commit named with tag' '
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty -m "old commit" &&
|
|
|
|
old=$(git rev-parse --verify HEAD) &&
|
|
|
|
git tag -a -m "tag on old" tagged-old HEAD &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty -m "new commit" &&
|
|
|
|
new=$(git rev-parse --verify HEAD) &&
|
|
|
|
test_tick &&
|
|
|
|
git commit --allow-empty --amend -C tagged-old &&
|
|
|
|
git show --pretty="format:%ad %s" "$old" >expected &&
|
|
|
|
git show --pretty="format:%ad %s" HEAD >actual &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2008-02-03 11:00:09 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-07-31 23:37:30 +04:00
|
|
|
test_done
|