* Re: [PATCHv3 3/5] tag --exclude option
2012-02-23 0:22 ` Tom Grennan
@ 2012-02-23 1:00 ` Junio C Hamano
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (10 subsequent siblings)
11 siblings, 0 replies; 83+ messages in thread
From: Junio C Hamano @ 2012-02-23 1:00 UTC (permalink / raw)
To: Tom Grennan; +Cc: git, peff, jasampler, pclouds
Tom Grennan <tmgrennan@gmail.com> writes:
> On Tue, Feb 21, 2012 at 10:33:29PM -0800, Junio C Hamano wrote:
>
>>As you do not specify what kind of pattern matching is done to this
>>exclude pattern, it is important to use the same logic between positive
>>and negative ones to give users a consistent UI. Unfortunately we use
>>fnmatch without FNM_PATHNAME for positive ones, so this exclude pattern
>>needs to follow the same semantics to reduce confusion.
>>
>>This comment applies to all the patches in this series to add this option
>>to existing commands that take the positive pattern.
>
> OK, should I also describe the --no-exclude option?
If you support it, yes. What does it do?
--no-exclude::
Cancels all the `--exclude` options given so far on the command line.
perhaps?
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCH 0/5] modernize test style
2012-02-23 0:22 ` Tom Grennan
2012-02-23 1:00 ` Junio C Hamano
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2 " Tom Grennan
` (10 more replies)
2012-03-01 1:45 ` [PATCH 1/5] " Tom Grennan
` (9 subsequent siblings)
11 siblings, 11 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
>On Tue, Feb 21, 2012 at 10:33:29PM -0800, Junio C Hamano wrote:
>>I know you are imitating the style of surrounding tests that is an older
>>parts of this script, but it is an eyesore. More modern tests are written
>>like this:
>>
>> test_expect_success 'label for the test' '
>> cat >expect <<-EOF &&
>> v0.2.1
>> EOF
>> git tag -l ... >actual &&
>> test_cmp expect actual
>> '
>>
>>to avoid unnecessary backslash on the first line, and have the preparation
>>of test vectore _inside_ test_expect_success. We would eventually want to
>>update the older part to the newer style for consistency.
>>
>>Two possible ways to go about this are (1) have a "pure style" patch at
>>the beginning to update older tests to a new style and then add new code
>>and new test as a follow-up patch written in modern, or (2) add new code
>>and new test in modern, and make a mental note to update the older ones
>>after the dust settles. Adding new tests written in older style to a file
>>that already has mixed styles is the worst thing you can do.
>>
>>This comment applies to all the patches in this series with tests.
>
>I'd prefer, (1) precede each "--exclude" patch with a "pure style" patch
>to update the respective tests. However, since this will result in a
>lot of conflict with concurrent development; I'll separate the test
>patches from the code and documentation. I'll then cycle on rebasing
>the style and new test patches until the development of each is
>quiescent.
Per request, the following series modernize the style of the respective
test scripts. The common themes are:
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
- Use a "here" filter for some expect generation
I also used pipelines to validate expected results rather than temporary
files, i.e.
TEST | test_cmp expect -
vs. TEST >actual && test_cmp expect actual
Since the later three patches have a lot of whitespace change, I've included an
alternate, PATCH-w series that filters these for more substantive review.
However, even the filtered series is very large causing me to second guess
whether such style modernization should be pursued; so, I look forward to your
input.
Thanks,
Tom Grennan (5):
t6300 (for-each-ref): modernize style
t5512 (ls-remote): modernize style
t3200 (branch): modernize style
t0040 (parse-options): modernize style
t7004 (tag): modernize style
t/t7004-tag.sh | 1680 ++++++++++++++++++++++++++------------------------------
1 files changed, 783 insertions(+), 897 deletions(-)
--
1.7.8
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCHv2 0/5] modernize test style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 8:04 ` Junio C Hamano
2012-03-03 2:15 ` [PATCHv2 1/5] t7004 (tag): modernize style Tom Grennan
` (9 subsequent siblings)
10 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
I <tmgrennan@gmail.com> wrote:
>Per request, the following series modernize the style of the respective
>test scripts. The common themes are:
> - Guard setup with test_expect_success
> - Single-quoted, tab prefaced test blocks of < 80 cols
> - Redirect unwanted output
> - Use a "here" filter for some expect generation
>
>I also used pipelines to validate expected results rather than temporary
>files, i.e.
> TEST | test_cmp expect -
>vs. TEST >actual && test_cmp expect actual
>
>Since the later three patches have a lot of whitespace change, I've included an
>alternate, PATCH-w series that filters these for more substantive review.
>However, even the filtered series is very large causing me to second guess
>whether such style modernization should be pursued; so, I look forward to your
>input.
The following series is a much less ambitious modernization of these tests.
This version does NOT:
- Support running with t/TEST.sh vs. (cd t && ./TEST.sh)
- Redirect unwanted output
- Pipeline test_cmp
- Rewrite blocks to be less than 80 columns
This version DOES:
- Guard setup with test_expect_success
(in one case, a shell loop was unwound to facilitate this)
- Single-quoted, tab prefaced test blocks
- >FILE instead of > FILE redirection style
- Use a sed filter to process formatted whitespace test cases
I've also included PATCHv2-w for review alternatives.
Thanks,
Tom Grennan (5):
t7004 (tag): modernize style
t5512 (ls-remote): modernize style
t3200 (branch): modernize style
t0040 (parse-options): modernize style
t6300 (for-each-ref): modernize style
t/t7004-tag.sh | 828 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 447 insertions(+), 381 deletions(-)
--
1.7.8
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCHv2 0/5] modernize test style
2012-03-03 2:15 ` [PATCHv2 " Tom Grennan
@ 2012-03-03 8:04 ` Junio C Hamano
2012-03-03 17:42 ` Tom Grennan
0 siblings, 1 reply; 83+ messages in thread
From: Junio C Hamano @ 2012-03-03 8:04 UTC (permalink / raw)
To: Tom Grennan
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
> t7004 (tag): modernize style
> t5512 (ls-remote): modernize style
> t3200 (branch): modernize style
> t0040 (parse-options): modernize style
> t6300 (for-each-ref): modernize style
Hmph.
We would want to keep/make the codebase uniformly conform to our style
guide for longer term maintainability (this is not limited to the test
scripts) but at the same time we would strongly want to avoid churning
patches from interfering other patches that are still in flight that do
"real work".
There are only two appropriate occasions for file-wide clean-up patches
like these:
(1) The file has not been touched for quite some time, and it is not
expected to be touched for some time to come; or
(2) You are going to do extensive work on the file for reasons other than
clean-up, and nobody else is working or expected to work in the same
area for some time to come (in other words, you _own_ the file), and
your real work will be easier to review if it is done _after_ such a
clean-up patch.
Let's see how active these five files are:
$ git diff --stat v1.7.9..pu -- t/t{7004,5512,3200,0040,6300}-*.sh
t/t0040-parse-options.sh | 60 ++++++++++++++++++++++-
t/t3200-branch.sh | 122 ++++++++++++++++++++++++++++++++++++++++++++--
t/t7004-tag.sh | 96 ++++++++++++++++++++++++++++++++++++
3 files changed, 272 insertions(+), 6 deletions(-)
Given this, I do not want to take three of your 5 patches that touch these
files at this point. Please hold onto them and wait until topics that
touch these test scripts graduate to 'master', and then wait a bit more
until some time passes without anybody touching them, before redoing the
clean-up patches.
On the other hand, we can see that 5512 has been dormant for quite a
while. Note that the latter diff is against 3 cycles ago:
$ git diff --stat v1.7.6..pu -- t/t{7004,5512,3200,0040,6300}-*.sh
t/t0040-parse-options.sh | 79 +++++++++++++++-
t/t3200-branch.sh | 236 +++++++++++++++++++++++++++++++++++++++++-----
t/t6300-for-each-ref.sh | 101 +++++++++++++++++++-
t/t7004-tag.sh | 128 +++++++++++++++++++------
4 files changed, 490 insertions(+), 54 deletions(-)
so 5512 and possibly 6300 may be worth reviewing.
Thanks.
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCHv2 0/5] modernize test style
2012-03-03 8:04 ` Junio C Hamano
@ 2012-03-03 17:42 ` Tom Grennan
0 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 17:42 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Johannes Schindelin
On Sat, Mar 03, 2012 at 12:04:54AM -0800, Junio C Hamano wrote:
>
>On the other hand, we can see that 5512 has been dormant for quite a
>while. Note that the latter diff is against 3 cycles ago:
>
>$ git diff --stat v1.7.6..pu -- t/t{7004,5512,3200,0040,6300}-*.sh
> t/t0040-parse-options.sh | 79 +++++++++++++++-
> t/t3200-branch.sh | 236 +++++++++++++++++++++++++++++++++++++++++-----
> t/t6300-for-each-ref.sh | 101 +++++++++++++++++++-
> t/t7004-tag.sh | 128 +++++++++++++++++++------
> 4 files changed, 490 insertions(+), 54 deletions(-)
>
>so 5512 and possibly 6300 may be worth reviewing.
Ack, I'll hold the others until each are quiescent for a few cycles.
Thanks.
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCHv2 1/5] t7004 (tag): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
2012-03-03 2:15 ` [PATCHv2 " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 21:31 ` Johannes Sixt
2012-03-03 2:15 ` [PATCHv2 2/5] t5512 (ls-remote): " Tom Grennan
` (8 subsequent siblings)
10 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks
- Use >FILE instead of > FILE
- Use a "here" filter for generation of expect files with mixed tabs and
spaces
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t7004-tag.sh | 828 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 447 insertions(+), 381 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f8c247a..f819f41 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -27,8 +27,9 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git tag | wc -l` -eq 0
'
-test_expect_success 'looking for a tag in an empty tree should fail' \
- '! (tag_exists mytag)'
+test_expect_success 'looking for a tag in an empty tree should fail' '
+ ! tag_exists mytag
+'
test_expect_success 'creating a tag in an empty tree should fail' '
test_must_fail git tag mynotag &&
@@ -66,27 +67,32 @@ test_expect_success 'listing all tags if one exists should output that tag' '
# pattern matching:
-test_expect_success 'listing a tag using a matching pattern should succeed' \
- 'git tag -l mytag'
+test_expect_success 'listing a tag using a matching pattern should succeed' '
+ git tag -l mytag
+'
test_expect_success \
- 'listing a tag using a matching pattern should output that tag' \
- 'test `git tag -l mytag` = mytag'
+ 'listing a tag using a matching pattern should output that tag' '
+ test `git tag -l mytag` = mytag
+'
# todo: git tag -l now returns always zero, when fixed, change this test
test_expect_success \
- 'listing tags using a non-matching pattern should suceed' \
- 'git tag -l xxx'
+ 'listing tags using a non-matching pattern should suceed' '
+ git tag -l xxx
+'
test_expect_success \
- 'listing tags using a non-matching pattern should output nothing' \
- 'test `git tag -l xxx | wc -l` -eq 0'
+ 'listing tags using a non-matching pattern should output nothing' '
+ test `git tag -l xxx | wc -l` -eq 0
+'
# special cases for creating tags:
test_expect_success \
- 'trying to create a tag with the name of one existing should fail' \
- 'test_must_fail git tag mytag'
+ 'trying to create a tag with the name of one existing should fail' '
+ test_must_fail git tag mytag
+'
test_expect_success \
'trying to create a tag with a non-valid name should fail' '
@@ -111,15 +117,17 @@ test_expect_success 'trying to delete an unknown tag should fail' '
test_must_fail git tag -d unknown-tag
'
-cat >expect <<EOF
-myhead
-mytag
-EOF
test_expect_success \
'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && test_cmp expect actual &&
+ cat >expect <<-EOF &&
+ myhead
+ mytag
+ EOF
+ git tag -l >actual &&
+ test_cmp expect actual &&
git tag -d &&
- git tag -l > actual && test_cmp expect actual
+ git tag -l >actual &&
+ test_cmp expect actual
'
test_expect_success \
@@ -147,23 +155,25 @@ test_expect_success \
! tag_exists myhead
'
-test_expect_success 'trying to delete an already deleted tag should fail' \
- 'test_must_fail git tag -d mytag'
+test_expect_success \
+ 'trying to delete an already deleted tag should fail' '
+ test_must_fail git tag -d mytag
+'
# listing various tags with pattern matching:
-cat >expect <<EOF
-a1
-aa1
-cba
-t210
-t211
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
test_expect_success 'listing all tags should print them ordered' '
+ cat >expect <<-EOF &&
+ a1
+ aa1
+ cba
+ t210
+ t211
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag v1.0.1 &&
git tag t211 &&
git tag aa1 &&
@@ -173,88 +183,88 @@ test_expect_success 'listing all tags should print them ordered' '
git tag a1 &&
git tag v1.0 &&
git tag t210 &&
- git tag -l > actual &&
+ git tag -l >actual &&
test_cmp expect actual &&
- git tag > actual &&
+ git tag >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-a1
-aa1
-cba
-EOF
test_expect_success \
'listing tags with substring as pattern must print those matching' '
+ cat >expect <<-EOF &&
+ a1
+ aa1
+ cba
+ EOF
rm *a* &&
- git tag -l "*a*" > current &&
+ git tag -l "*a*" >current &&
test_cmp expect current
'
-cat >expect <<EOF
-v0.2.1
-v1.0.1
-EOF
test_expect_success \
'listing tags with a suffix as pattern must print those matching' '
- git tag -l "*.1" > actual &&
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0.1
+ EOF
+ git tag -l "*.1" >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-t210
-t211
-EOF
test_expect_success \
'listing tags with a prefix as pattern must print those matching' '
- git tag -l "t21*" > actual &&
+ cat >expect <<-EOF &&
+ t210
+ t211
+ EOF
+ git tag -l "t21*" >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-a1
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
- git tag -l a1 > actual &&
+ cat >expect <<-EOF &&
+ a1
+ EOF
+ git tag -l a1 >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v1.0
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
- git tag -l v1.0 > actual &&
+ cat >expect <<-EOF &&
+ v1.0
+ EOF
+ git tag -l v1.0 >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v1.0.1
-v1.1.3
-EOF
test_expect_success \
'listing tags with ? in the pattern should print those matching' '
- git tag -l "v1.?.?" > actual &&
+ cat >expect <<-EOF &&
+ v1.0.1
+ v1.1.3
+ EOF
+ git tag -l "v1.?.?" >actual &&
test_cmp expect actual
'
->expect
test_expect_success \
'listing tags using v.* should print nothing because none have v.' '
- git tag -l "v.*" > actual &&
+ >expect &&
+ git tag -l "v.*" >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
test_expect_success \
'listing tags using v* should print only those having v' '
- git tag -l "v*" > actual &&
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
+ git tag -l "v*" >actual &&
test_cmp expect actual
'
@@ -272,66 +282,73 @@ test_expect_success \
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_success 'trying to verify an unknown tag should fail' \
- 'test_must_fail git tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' '
+ test_must_fail git tag -v unknown-tag
+'
test_expect_success \
- 'trying to verify a non-annotated and non-signed tag should fail' \
- 'test_must_fail git tag -v non-annotated-tag'
+ 'trying to verify a non-annotated and non-signed tag should fail' '
+ test_must_fail git tag -v non-annotated-tag
+'
test_expect_success \
- 'trying to verify many non-annotated or unknown tags, should fail' \
- 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+ 'trying to verify many non-annotated or unknown tags, should fail' '
+ test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2
+'
# creating annotated tags:
+here='s/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g'
+
get_tag_msg () {
git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
}
# run test_tick before committing always gives the time in that timezone
get_tag_header () {
-cat <<EOF
-object $2
-type $3
-tag $1
-tagger C O Mitter <committer@example.com> $4 -0700
+ # name, object, type, time
+ cat <<-EOF &&
+ object $2
+ type $3
+ tag $1
+ tagger C O Mitter <committer@example.com> $4 -0700
-EOF
+ EOF
+ sed -e "$here"
}
-commit=$(git rev-parse HEAD)
-time=$test_tick
-
-get_tag_header annotated-tag $commit commit $time >expect
-echo "A message" >>expect
test_expect_success \
'creating an annotated tag with -m message should succeed' '
+ commit=$(git rev-parse HEAD) &&
+ time=$test_tick &&
+ get_tag_header annotated-tag $commit commit $time \
+ >expect <<-EOF &&
+ A message
+ EOF
git tag -m "A message" annotated-tag &&
get_tag_msg annotated-tag >actual &&
test_cmp expect actual
'
-cat >msgfile <<EOF
-Another message
-in a file.
-EOF
-get_tag_header file-annotated-tag $commit commit $time >expect
-cat msgfile >>expect
test_expect_success \
'creating an annotated tag with -F messagefile should succeed' '
+ cat >msgfile <<-EOF &&
+ A message from the
+ standard input
+ EOF
+ get_tag_header file-annotated-tag $commit commit $time >expect <msgfile
git tag -F msgfile file-annotated-tag &&
get_tag_msg file-annotated-tag >actual &&
test_cmp expect actual
'
-cat >inputmsg <<EOF
-A message from the
-standard input
-EOF
-get_tag_header stdin-annotated-tag $commit commit $time >expect
-cat inputmsg >>expect
test_expect_success 'creating an annotated tag with -F - should succeed' '
+ cat >inputmsg <<-EOF &&
+ A message from the
+ standard input
+ EOF
+ get_tag_header stdin-annotated-tag $commit commit $time \
+ >expect <inputmsg
git tag -F - stdin-annotated-tag <inputmsg &&
get_tag_msg stdin-annotated-tag >actual &&
test_cmp expect actual
@@ -361,67 +378,87 @@ test_expect_success \
# blank and empty messages:
-get_tag_header empty-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -m message should succeed' '
+ >emptyfile &&
+ get_tag_header empty-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -m "" empty-annotated-tag &&
get_tag_msg empty-annotated-tag >actual &&
test_cmp expect actual
'
->emptyfile
-get_tag_header emptyfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -F messagefile should succeed' '
+ get_tag_header emptyfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F emptyfile emptyfile-annotated-tag &&
get_tag_msg emptyfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
-printf '\n\n\nTrailing spaces \t \n' >>blanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
-get_tag_header blanks-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
+test_expect_success \
+ 'extra blanks in the message for an annotated tag should be removed' '
+ sed -e "$here" >blanksfile <<-\EOF &&
-Repeated blank lines
+ \s\s
+ \t
+ Leading blank lines
-Trailing spaces
+ \t\s\t\s\s
+ Repeated blank lines
-Trailing blank lines
-EOF
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ get_tag_header blanks-annotated-tag $commit commit $time \
+ >expect <<-EOF &&
+ Leading blank lines
+
+ Repeated blank lines
+
+ Trailing spaces
+
+ Trailing blank lines
+ EOF
git tag -F blanksfile blanks-annotated-tag &&
get_tag_msg blanks-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header blank-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -m message with spaces should succeed' '
+ get_tag_header blank-annotated-tag $commit commit $time >expect <emptyfile &&
git tag -m " " blank-annotated-tag &&
get_tag_msg blank-annotated-tag >actual &&
test_cmp expect actual
'
-echo ' ' >blankfile
-echo '' >>blankfile
-echo ' ' >>blankfile
-get_tag_header blankfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -F messagefile with spaces should succeed' '
+ sed -e "$here" >blankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ get_tag_header blankfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F blankfile blankfile-annotated-tag &&
get_tag_msg blankfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf ' ' >blanknonlfile
-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with -F file of spaces and no newline should succeed' '
+ printf " " >blanknonlfile &&
+ get_tag_header blanknonlfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F blanknonlfile blanknonlfile-annotated-tag &&
get_tag_msg blanknonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -429,62 +466,67 @@ test_expect_success \
# messages with commented lines:
-cat >commentsfile <<EOF
-# A comment
+test_expect_success \
+ 'creating a tag using a -F messagefile with #comments should succeed' '
+ cat >commentsfile <<-EOF &&
+ # A comment
-############
-The message.
-############
-One line.
+ ############
+ The message.
+ ############
+ One line.
-# commented lines
-# commented lines
+ # commented lines
+ # commented lines
-Another line.
-# comments
+ Another line.
+ # comments
-Last line.
-EOF
-get_tag_header comments-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
+ Last line.
+ EOF
+ get_tag_header comments-annotated-tag $commit commit $time \
+ >expect <<-EOF &&
+ The message.
+ One line.
-Another line.
+ Another line.
-Last line.
-EOF
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
+ Last line.
+ EOF
git tag -F commentsfile comments-annotated-tag &&
get_tag_msg comments-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header comment-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a #comment in the -m message should succeed' '
+ get_tag_header comment-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -m "#comment" comment-annotated-tag &&
get_tag_msg comment-annotated-tag >actual &&
test_cmp expect actual
'
-echo '#comment' >commentfile
-echo '' >>commentfile
-echo '####' >>commentfile
-get_tag_header commentfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with #comments in the -F messagefile should succeed' '
+ cat >commentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ get_tag_header commentfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F commentfile commentfile-annotated-tag &&
get_tag_msg commentfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '#comment' >commentnonlfile
-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a file of #comment and no newline should succeed' '
+ printf "#comment" >commentnonlfile &&
+ get_tag_header commentnonlfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F commentnonlfile commentnonlfile-annotated-tag &&
get_tag_msg commentnonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -542,11 +584,13 @@ test_expect_success \
test_cmp expect actual
'
-echo 'tag line one' >annotagmsg
-echo 'tag line two' >>annotagmsg
-echo 'tag line three' >>annotagmsg
test_expect_success \
'listing many message lines of a non-signed tag should succeed' '
+ cat >annotagmsg <<-EOF &&
+ tag line one
+ tag line two
+ tag line three
+ EOF
git tag -F annotagmsg tag-lines &&
echo "tag-lines" >expect &&
@@ -588,9 +632,9 @@ test_expect_success \
test_expect_success 'annotations for blobs are empty' '
blob=$(git hash-object -w --stdin <<-\EOF
- Blob paragraph 1.
+ Blob paragraph 1.
- Blob paragraph 2.
+ Blob paragraph 2.
EOF
) &&
git tag tag-blob $blob &&
@@ -621,20 +665,22 @@ test_expect_success GPG \
# creating and verifying signed tags:
-get_tag_header signed-tag $commit commit $time >expect
-echo 'A signed tag message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG 'creating a signed tag with -m message should succeed' '
+test_expect_success GPG \
+ 'creating a signed tag with -m message should succeed' '
+ get_tag_header signed-tag $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A signed tag message" signed-tag &&
get_tag_msg signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header u-signed-tag $commit commit $time >expect
-echo 'Another message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'sign with a given key id' '
-
+ get_tag_header u-signed-tag $commit commit $time >expect <<-EOF &&
+ Another message
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -u committer@example.com -m "Another message" u-signed-tag &&
get_tag_msg u-signed-tag >actual &&
test_cmp expect actual
@@ -654,54 +700,54 @@ test_expect_success GPG 'sign with an unknown id (2)' '
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-test -n "$1" && exec >"$1"
-echo A signed tag message
-echo from a fake editor.
-EOF
-chmod +x fakeeditor
-
-get_tag_header implied-sign $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-u implies signed tag' '
+ write_script fakeeditor <<-\EOF &&
+ test -n "$1" && exec >"$1"
+ echo A signed tag message
+ echo from a fake editor.
+ EOF
+ get_tag_header implied-sign $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
get_tag_msg implied-sign >actual &&
test_cmp expect actual
'
-cat >sigmsgfile <<EOF
-Another signed tag
-message in a file.
-EOF
-get_tag_header file-signed-tag $commit commit $time >expect
-cat sigmsgfile >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with -F messagefile should succeed' '
+ cat >sigmsgfile <<-EOF
+ Another signed tag
+ message in a file.
+ EOF
+ get_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect
git tag -s -F sigmsgfile file-signed-tag &&
get_tag_msg file-signed-tag >actual &&
test_cmp expect actual
'
-cat >siginputmsg <<EOF
-A signed tag message from
-the standard input
-EOF
-get_tag_header stdin-signed-tag $commit commit $time >expect
-cat siginputmsg >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -F - should succeed' '
+ cat >siginputmsg <<-EOF
+ A signed tag message from
+ the standard input
+ EOF
+ get_tag_header stdin-signed-tag $commit commit $time \
+ >expect <siginputmsg &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect
git tag -s -F - stdin-signed-tag <siginputmsg &&
get_tag_msg stdin-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header implied-annotate $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-s implies annotated tag' '
+ get_tag_header implied-annotate $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
get_tag_msg implied-annotate >actual &&
test_cmp expect actual
@@ -715,11 +761,14 @@ test_expect_success GPG \
! tag_exists nosigtag
'
-test_expect_success GPG 'verifying a signed tag should succeed' \
- 'git tag -v signed-tag'
+test_expect_success GPG 'verifying a signed tag should succeed' '
+ git tag -v signed-tag
+'
-test_expect_success GPG 'verifying two signed tags in one command should succeed' \
- 'git tag -v signed-tag file-signed-tag'
+test_expect_success GPG \
+ 'verifying two signed tags in one command should succeed' '
+ git tag -v signed-tag file-signed-tag
+'
test_expect_success GPG \
'verifying many signed and non-signed tags should fail' '
@@ -740,149 +789,181 @@ test_expect_success GPG 'verifying a forged tag should fail' '
# blank and empty messages for signed tags:
-get_tag_header empty-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -m message should succeed' '
+ get_tag_header empty-signed-tag $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "" empty-signed-tag &&
get_tag_msg empty-signed-tag >actual &&
test_cmp expect actual &&
git tag -v empty-signed-tag
'
->sigemptyfile
-get_tag_header emptyfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -F messagefile should succeed' '
+ >sigemptyfile &&
+ get_tag_header emptyfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigemptyfile emptyfile-signed-tag &&
get_tag_msg emptyfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v emptyfile-signed-tag
'
-printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
-printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
-get_tag_header blanks-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
+test_expect_success GPG \
+ 'extra blanks in the message for a signed tag should be removed' '
+ sed -e "$here" >sigblanksfile <<-\EOF &&
-Repeated blank lines
+ \s\s
+ \t
+ Leading blank lines
-Trailing spaces
+ \t\s\t\s\s
+ Repeated blank lines
-Trailing blank lines
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ get_tag_header blanks-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ Leading blank lines
+
+ Repeated blank lines
+
+ Trailing spaces
+
+ Trailing blank lines
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigblanksfile blanks-signed-tag &&
get_tag_msg blanks-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blanks-signed-tag
'
-get_tag_header blank-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a blank -m message should succeed' '
+ get_tag_header blank-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m " " blank-signed-tag &&
get_tag_msg blank-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blank-signed-tag
'
-echo ' ' >sigblankfile
-echo '' >>sigblankfile
-echo ' ' >>sigblankfile
-get_tag_header blankfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with blank -F file with spaces should succeed' '
+ sed -e "$here" >sigblankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ get_tag_header blankfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigblankfile blankfile-signed-tag &&
get_tag_msg blankfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blankfile-signed-tag
'
-printf ' ' >sigblanknonlfile
-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with spaces and no newline should succeed' '
+ printf >sigblanknonlfile " " &&
+ get_tag_header blanknonlfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
get_tag_msg blanknonlfile-signed-tag >actual &&
test_cmp expect actual &&
- git tag -v signed-tag
+ git tag -v blanknonlfile-signed-tag
'
# messages with commented lines for signed tags:
-cat >sigcommentsfile <<EOF
-# A comment
+test_expect_success GPG \
+ 'creating a signed tag with a -F file with #comments should succeed' '
+ cat >sigcommentsfile <<-EOF &&
+ # A comment
-############
-The message.
-############
-One line.
+ ############
+ The message.
+ ############
+ One line.
-# commented lines
-# commented lines
+ # commented lines
+ # commented lines
-Another line.
-# comments
+ Another line.
+ # comments
-Last line.
-EOF
-get_tag_header comments-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
+ Last line.
+ EOF
+ get_tag_header comments-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ The message.
+ One line.
-Another line.
+ Another line.
-Last line.
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
+ Last line.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigcommentsfile comments-signed-tag &&
get_tag_msg comments-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comments-signed-tag
'
-get_tag_header comment-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -m message should succeed' '
+ get_tag_header comment-signed-tag $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "#comment" comment-signed-tag &&
get_tag_msg comment-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comment-signed-tag
'
-echo '#comment' >sigcommentfile
-echo '' >>sigcommentfile
-echo '####' >>sigcommentfile
-get_tag_header commentfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -F messagefile should succeed' '
+ cat >sigcommentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ get_tag_header commentfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigcommentfile commentfile-signed-tag &&
get_tag_msg commentfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v commentfile-signed-tag
'
-printf '#comment' >sigcommentnonlfile
-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a #comment and no newline should succeed' '
+ printf "#comment" >sigcommentnonlfile &&
+ get_tag_header commentnonlfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
get_tag_msg commentnonlfile-signed-tag >actual &&
test_cmp expect actual &&
@@ -941,11 +1022,13 @@ test_expect_success GPG \
test_cmp expect actual
'
-echo 'stag line one' >sigtagmsg
-echo 'stag line two' >>sigtagmsg
-echo 'stag line three' >>sigtagmsg
test_expect_success GPG \
'listing many message lines of a signed tag should succeed' '
+ cat >sigtagmsg <<-EOF &&
+ stag line one
+ stag line two
+ stag line three
+ EOF
git tag -s -F sigtagmsg stag-lines &&
echo "stag-lines" >expect &&
@@ -987,72 +1070,68 @@ test_expect_success GPG \
# tags pointing to objects different from commits:
-tree=$(git rev-parse HEAD^{tree})
-blob=$(git rev-parse HEAD:foo)
-tag=$(git rev-parse signed-tag 2>/dev/null)
-
-get_tag_header tree-signed-tag $tree tree $time >expect
-echo "A message for a tree" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a tree should succeed' '
+ tree=$(git rev-parse HEAD^{tree}) &&
+ blob=$(git rev-parse HEAD:foo) &&
+ tag=$(git rev-parse signed-tag) &&
+ get_tag_header tree-signed-tag $tree tree $time >expect <<-EOF &&
+ A message for a tree
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
get_tag_msg tree-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header blob-signed-tag $blob blob $time >expect
-echo "A message for a blob" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a blob should succeed' '
+ get_tag_header blob-signed-tag $blob blob $time >expect <<-EOF &&
+ A message for a blob
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
get_tag_msg blob-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header tag-signed-tag $tag tag $time >expect
-echo "A message for another tag" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to another tag should succeed' '
+ get_tag_header tag-signed-tag $tag tag $time >expect <<-EOF &&
+ A message for another tag
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
get_tag_msg tag-signed-tag >actual &&
test_cmp expect actual
'
# usage with rfc1991 signatures
-echo "rfc1991" > gpghome/gpg.conf
-get_tag_header rfc1991-signed-tag $commit commit $time >expect
-echo "RFC1991 signed tag" >>expect
-echo '-----BEGIN PGP MESSAGE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with rfc1991' '
+test_expect_success GPG 'creating a signed tag with rfc1991' '
+ echo "rfc1991" >gpghome/gpg.conf &&
+ get_tag_header rfc1991-signed-tag $commit commit $time >expect <<-EOF &&
+ RFC1991 signed tag
+ -----BEGIN PGP MESSAGE-----
+ EOF
git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
get_tag_msg rfc1991-signed-tag >actual &&
test_cmp expect actual
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-cp "$1" actual
-EOF
-chmod +x fakeeditor
-
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
+ write_script fakeeditor <<-\EOF &&
+ cp "$1" actual
+ EOF
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-test_expect_success GPG \
- 'verifying rfc1991 signature' '
+test_expect_success GPG 'verifying rfc1991 signature' '
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature' '
+test_expect_success GPG 'list tag with rfc1991 signature' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
@@ -1062,15 +1141,12 @@ test_expect_success GPG \
test_cmp expect actual
'
-rm -f gpghome/gpg.conf
-
-test_expect_success GPG \
- 'verifying rfc1991 signature without --rfc1991' '
+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '
+ rm -f gpghome/gpg.conf &&
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature without --rfc1991' '
+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
@@ -1080,26 +1156,26 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-# try to sign with bad user.signingkey
-git config user.signingkey BobTheMouse
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured' \
- 'test_must_fail git tag -s -m tail tag-gpg-failure'
-git config --unset user.signingkey
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '
+ # try to sign with bad user.signingkey
+ git config user.signingkey BobTheMouse &&
+ test_must_fail git tag -s -m tail tag-gpg-failure &&
+ git config --unset user.signingkey
+'
# try to verify without gpg:
-rm -rf gpghome
test_expect_success GPG \
- 'verify signed tag fails when public key is not present' \
- 'test_must_fail git tag -v signed-tag'
+ 'verify signed tag fails when public key is not present' '
+ rm -rf gpghome &&
+ test_must_fail git tag -v signed-tag
+'
test_expect_success \
'git tag -a fails if tag annotation is empty' '
@@ -1108,7 +1184,7 @@ test_expect_success \
test_expect_success \
'message in editor has initial comment' '
- ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
+ ! (GIT_EDITOR=cat git tag -a initial-comment >actual)
'
test_expect_success 'message in editor has initial comment: first line' '
@@ -1126,12 +1202,13 @@ test_expect_success \
test_cmp rest.expect rest.actual
'
-get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >> expect
test_expect_success \
'overwriting an annoted tag should use its previous body' '
+ get_tag_header reuse $commit commit $time >expect <<-EOF &&
+ reuse
+ EOF
git tag -a -m "An annotation to be reused" reuse &&
- GIT_EDITOR=true git tag -f -a reuse &&
+ GIT_EDITOR=true git tag -f -a -m "reuse" reuse &&
get_tag_msg reuse >actual &&
test_cmp expect actual
'
@@ -1158,118 +1235,107 @@ test_expect_success 'filename for the message is relative to cwd' '
# create a few more commits to test --contains
-hash1=$(git rev-parse HEAD)
-
test_expect_success 'creating second commit and tag' '
+ hash1=$(git rev-parse HEAD) &&
echo foo-2.0 >foo &&
git add foo &&
git commit -m second &&
+ hash2=$(git rev-parse HEAD) &&
git tag v2.0
'
-hash2=$(git rev-parse HEAD)
-
test_expect_success 'creating third commit without tag' '
echo foo-dev >foo &&
git add foo &&
- git commit -m third
+ git commit -m third &&
+ hash3=$(git rev-parse HEAD)
'
-hash3=$(git rev-parse HEAD)
-
-# simple linear checks of --continue
+# simple linear checks of --contains
-cat > expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
-test_expect_success 'checking that first commit is in all tags (hash)' "
+test_expect_success 'checking that first commit is in all tags (hash)' '
+ cat >expected <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
# other ways of specifying the commit
-test_expect_success 'checking that first commit is in all tags (tag)' "
+test_expect_success 'checking that first commit is in all tags (tag)' '
git tag -l --contains v1.0 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that first commit is in all tags (relative)' "
+test_expect_success 'checking that first commit is in all tags (relative)' '
git tag -l --contains HEAD~2 v* >actual &&
test_cmp expected actual
-"
-
-cat > expected <<EOF
-v2.0
-EOF
+'
-test_expect_success 'checking that second commit only has one tag' "
+test_expect_success 'checking that second commit only has one tag' '
+ cat >expected <<-EOF &&
+ v2.0
+ EOF
git tag -l --contains $hash2 v* >actual &&
test_cmp expected actual
-"
-
-
-cat > expected <<EOF
-EOF
+'
-test_expect_success 'checking that third commit has no tags' "
+test_expect_success 'checking that third commit has no tags' '
+ cat >expected <<-EOF &&
+ EOF
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
# how about a simple merge?
test_expect_success 'creating simple branch' '
git branch stable v2.0 &&
- git checkout stable &&
- echo foo-3.0 > foo &&
+ git checkout stable &&
+ echo foo-3.0 >foo &&
git commit foo -m fourth &&
+ hash4=$(git rev-parse HEAD) &&
git tag v3.0
'
-hash4=$(git rev-parse HEAD)
-
-cat > expected <<EOF
-v3.0
-EOF
-
-test_expect_success 'checking that branch head only has one tag' "
+test_expect_success 'checking that branch head only has one tag' '
+ cat >expected <<-EOF &&
+ v3.0
+ EOF
git tag -l --contains $hash4 v* >actual &&
test_cmp expected actual
-"
+'
test_expect_success 'merging original branch into this branch' '
git merge --strategy=ours master &&
- git tag v4.0
+ git tag v4.0
'
-cat > expected <<EOF
-v4.0
-EOF
-
-test_expect_success 'checking that original branch head has one tag now' "
+test_expect_success 'checking that original branch head has one tag now' '
+ cat >expected <<-EOF &&
+ v4.0
+ EOF
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
-"
-
-cat > expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-v4.0
-EOF
-
-test_expect_success 'checking that initial commit is in all tags' "
+'
+
+test_expect_success 'checking that initial commit is in all tags' '
+ cat >expected <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ v3.0
+ v4.0
+ EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
# mixing modes and options:
@@ -1305,8 +1371,8 @@ test_expect_success '--points-at finds annotated tags of tags' '
git tag -m "describing the v4.0 tag object" \
annotated-again-v4.0 annotated-v4.0 &&
cat >expect <<-\EOF &&
- annotated-again-v4.0
- annotated-v4.0
+ annotated-again-v4.0
+ annotated-v4.0
EOF
git tag --points-at=annotated-v4.0 >actual &&
test_cmp expect actual
@@ -1314,8 +1380,8 @@ test_expect_success '--points-at finds annotated tags of tags' '
test_expect_success 'multiple --points-at are OR-ed together' '
cat >expect <<-\EOF &&
- v2.0
- v3.0
+ v2.0
+ v3.0
EOF
git tag --points-at=v2.0 --points-at=v3.0 >actual &&
test_cmp expect actual
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* Re: [PATCHv2 1/5] t7004 (tag): modernize style
2012-03-03 2:15 ` [PATCHv2 1/5] t7004 (tag): modernize style Tom Grennan
@ 2012-03-03 21:31 ` Johannes Sixt
0 siblings, 0 replies; 83+ messages in thread
From: Johannes Sixt @ 2012-03-03 21:31 UTC (permalink / raw)
To: Tom Grennan
Cc: git, Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
Am 03.03.2012 03:15, schrieb Tom Grennan:
> -test_expect_success 'trying to delete an already deleted tag should fail' \
> - 'test_must_fail git tag -d mytag'
> +test_expect_success \
> + 'trying to delete an already deleted tag should fail' '
> + test_must_fail git tag -d mytag
> +'
Personally, I prefer lines with 80+ chars over lines broken with a
backslash. So, while I can understand that you do not always remove a
backslash to avoid churn, I think it is not warranted to *introduce* one
to shorten a line below 80 chars. But that's really just a matter of taste.
> test_expect_success GPG \
> 'creating a signed tag with -F messagefile should succeed' '
> + cat >sigmsgfile <<-EOF
> + Another signed tag
> + message in a file.
> + EOF
> + get_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile
> + echo "-----BEGIN PGP SIGNATURE-----" >>expect
Several && missing here and later in the file.
I stopped reading here. This is too much to read in one go. This should
really be broken into several parts. For example, you changed
get_tag_header and added several <emptyfile redirections (which should
be /dev/null IMO); that has not a lot to do with "modernize style".
> git tag -s -F sigmsgfile file-signed-tag &&
> get_tag_msg file-signed-tag >actual &&
> test_cmp expect actual
> '
-- Hannes
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCHv2 2/5] t5512 (ls-remote): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
2012-03-03 2:15 ` [PATCHv2 " Tom Grennan
2012-03-03 2:15 ` [PATCHv2 1/5] t7004 (tag): modernize style Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 8:05 ` Junio C Hamano
2012-03-03 2:15 ` [PATCHv2 3/5] t3200 (branch): " Tom Grennan
` (7 subsequent siblings)
10 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
Guard setup with test_expect_success
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t5512-ls-remote.sh | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 5c546c9..811dcc3 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -102,11 +102,13 @@ test_expect_success 'use branch.<name>.remote if possible' '
'
-cat >exp <<EOF
-fatal: 'refs*master' does not appear to be a git repository
-fatal: The remote end hung up unexpectedly
-EOF
test_expect_success 'confuses pattern as remote when no remote specified' '
+ '"
+ cat >exp <<-EOF
+ fatal: 'refs*master' does not appear to be a git repository
+ fatal: The remote end hung up unexpectedly
+ EOF
+ "'
#
# Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly,
# confuses <pattern> for <remote>. Although ugly, this behaviour is akin
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* Re: [PATCHv2 2/5] t5512 (ls-remote): modernize style
2012-03-03 2:15 ` [PATCHv2 2/5] t5512 (ls-remote): " Tom Grennan
@ 2012-03-03 8:05 ` Junio C Hamano
2012-03-03 17:33 ` Tom Grennan
0 siblings, 1 reply; 83+ messages in thread
From: Junio C Hamano @ 2012-03-03 8:05 UTC (permalink / raw)
To: Tom Grennan
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
> test_expect_success 'confuses pattern as remote when no remote specified' '
> + '"
> + cat >exp <<-EOF
> + fatal: 'refs*master' does not appear to be a git repository
> + fatal: The remote end hung up unexpectedly
> + EOF
> + "'
Please make it a habit to make your test script a cascade of &&, i.e.
... remote specified' '
cat >exp <<-\EOF &&
fatal: '\''refs*master'\'' does not ...
...
EOF
No need to resend; I'll fix it up locally.
Thanks.
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCHv2 2/5] t5512 (ls-remote): modernize style
2012-03-03 8:05 ` Junio C Hamano
@ 2012-03-03 17:33 ` Tom Grennan
0 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 17:33 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Johannes Schindelin
On Sat, Mar 03, 2012 at 12:05:05AM -0800, Junio C Hamano wrote:
>Tom Grennan <tmgrennan@gmail.com> writes:
>
>> test_expect_success 'confuses pattern as remote when no remote specified' '
>> + '"
>> + cat >exp <<-EOF
>> + fatal: 'refs*master' does not appear to be a git repository
>> + fatal: The remote end hung up unexpectedly
>> + EOF
>> + "'
>
>Please make it a habit to make your test script a cascade of &&, i.e.
>
> ... remote specified' '
> cat >exp <<-\EOF &&
> fatal: '\''refs*master'\'' does not ...
> ...
> EOF
>
>No need to resend; I'll fix it up locally.
>
Oops, I missed the && on that one.
What about the quoting of t6300's,
cat >expected <<\EOF
'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
EOF
Do you want it like this,
cat >expected <<-EOF &&
'\''refs/heads/master'\'' '\''Mon Jul 3 17:18:43 2006 +0200'\'' '\''Mon Jul 3 17:18:44 2006 +0200'\''
'\''refs/tags/testtag'\'' '\''Mon Jul 3 17:18:45 2006 +0200'\''
EOF
or,
cat >expected <<-EOF &&
'"'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'"'
'"'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'"'
EOF
or something else?
Thanks,
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCHv2 3/5] t3200 (branch): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (2 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2 2/5] t5512 (ls-remote): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2 4/5] t0040 (parse-options): " Tom Grennan
` (6 subsequent siblings)
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t3200-branch.sh | 365 +++++++++++++++++++++++++++--------------------------
1 files changed, 186 insertions(+), 179 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index dd1aceb..7191b89 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -7,20 +7,20 @@ test_description='git branch assorted tests'
. ./test-lib.sh
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
- git update-index --add A &&
- git commit -m "Initial commit." &&
- echo World >> A &&
- git update-index --add A &&
- git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+test_expect_success 'prepare a trivial repository' '
+ echo Hello >A &&
+ git update-index --add A &&
+ git commit -m "Initial commit." &&
+ echo World >>A &&
+ git update-index --add A &&
+ git commit -m "Second commit." &&
+ HEAD=$(git rev-parse --verify HEAD)
+'
test_expect_success \
- 'git branch --help should not have created a bogus branch' '
- test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
- test_path_is_missing .git/refs/heads/--help
+ 'git branch --help should not have created a bogus branch' '
+ test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
+ test_path_is_missing .git/refs/heads/--help
'
test_expect_success 'branch -h in broken repository' '
@@ -34,63 +34,63 @@ test_expect_success 'branch -h in broken repository' '
grep "[Uu]sage" broken/usage
'
-test_expect_success \
- 'git branch abc should create a branch' \
- 'git branch abc && test_path_is_file .git/refs/heads/abc'
+test_expect_success 'git branch abc should create a branch' '
+ git branch abc && test_path_is_file .git/refs/heads/abc
+'
-test_expect_success \
- 'git branch a/b/c should create a branch' \
- 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
+test_expect_success 'git branch a/b/c should create a branch' '
+ git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
+'
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
-EOF
-test_expect_success \
- 'git branch -l d/e/f should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git branch -l d/e/f &&
- test_path_is_file .git/refs/heads/d/e/f &&
- test_path_is_file .git/logs/refs/heads/d/e/f &&
- test_cmp expect .git/logs/refs/heads/d/e/f'
+test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+ cat >expect <<-EOF
+ $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+ EOF
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git branch -l d/e/f &&
+ test_path_is_file .git/refs/heads/d/e/f &&
+ test_path_is_file .git/logs/refs/heads/d/e/f &&
+ test_cmp expect .git/logs/refs/heads/d/e/f
+'
-test_expect_success \
- 'git branch -d d/e/f should delete a branch and a log' \
- 'git branch -d d/e/f &&
- test_path_is_missing .git/refs/heads/d/e/f &&
- test_path_is_missing .git/logs/refs/heads/d/e/f'
+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
+ git branch -d d/e/f &&
+ test_path_is_missing .git/refs/heads/d/e/f &&
+ test_path_is_missing .git/logs/refs/heads/d/e/f
+'
-test_expect_success \
- 'git branch j/k should work after branch j has been deleted' \
- 'git branch j &&
- git branch -d j &&
- git branch j/k'
+test_expect_success 'git branch j/k should work after branch j has been deleted' '
+ git branch j &&
+ git branch -d j &&
+ git branch j/k
+'
-test_expect_success \
- 'git branch l should work after branch l/m has been deleted' \
- 'git branch l/m &&
- git branch -d l/m &&
- git branch l'
+test_expect_success 'git branch l should work after branch l/m has been deleted' '
+ git branch l/m &&
+ git branch -d l/m &&
+ git branch l
+'
-test_expect_success \
- 'git branch -m dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- grep "[Uu]sage: git branch" err'
+test_expect_success 'git branch -m dumps usage' '
+ test_expect_code 129 git branch -m 2>err &&
+ grep "[Uu]sage: git branch" err
+'
-test_expect_success \
- 'git branch -m m m/m should work' \
- 'git branch -l m &&
- git branch -m m m/m &&
- test_path_is_file .git/logs/refs/heads/m/m'
+test_expect_success 'git branch -m m m/m should work' '
+ git branch -l m &&
+ git branch -m m m/m &&
+ test_path_is_file .git/logs/refs/heads/m/m
+'
-test_expect_success \
- 'git branch -m n/n n should work' \
- 'git branch -l n/n &&
+test_expect_success 'git branch -m n/n n should work' '
+ git branch -l n/n &&
git branch -m n/n n &&
- test_path_is_file .git/logs/refs/heads/n'
+ test_path_is_file .git/logs/refs/heads/n
+'
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
git branch o/o &&
- git branch o/p &&
+ git branch o/p &&
test_must_fail git branch -m o/o o
'
@@ -160,33 +160,30 @@ test_expect_success 'git branch --list -d t should fail' '
test_path_is_missing .git/refs/heads/t
'
-mv .git/config .git/config-saved
-
test_expect_success 'git branch -m q q2 without config should succeed' '
+ mv .git/config .git/config-saved &&
+ test_when_finished mv .git/config-saved .git/config &&
git branch -m q q2 &&
git branch -m q2 q
'
-mv .git/config-saved .git/config
-
-git config branch.s/s.dummy Hello
-
-test_expect_success \
- 'git branch -m s/s s should work when s/t is deleted' \
- 'git branch -l s/s &&
+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
+ git config branch.s/s.dummy Hello
+ git branch -l s/s &&
test_path_is_file .git/logs/refs/heads/s/s &&
- git branch -l s/t &&
+ git branch -l s/t &&
test_path_is_file .git/logs/refs/heads/s/t &&
- git branch -d s/t &&
- git branch -m s/s s &&
- test_path_is_file .git/logs/refs/heads/s'
-
-test_expect_success 'config information was renamed, too' \
- "test $(git config branch.s.dummy) = Hello &&
- test_must_fail git config branch.s/s/dummy"
+ git branch -d s/t &&
+ git branch -m s/s s &&
+ test_path_is_file .git/logs/refs/heads/s
+'
-test_expect_success 'renaming a symref is not allowed' \
+test_expect_success 'config information was renamed, too' '
+ test $(git config branch.s.dummy) = Hello &&
+ test_must_fail git config branch.s/s/dummy
'
+
+test_expect_success 'renaming a symref is not allowed' '
git symbolic-ref refs/heads/master2 refs/heads/master &&
test_must_fail git branch -m master2 master3 &&
git symbolic-ref refs/heads/master2 &&
@@ -194,115 +191,125 @@ test_expect_success 'renaming a symref is not allowed' \
test_path_is_missing .git/refs/heads/master3
'
-test_expect_success SYMLINKS \
- 'git branch -m u v should fail when the reflog for u is a symlink' '
- git branch -l u &&
- mv .git/logs/refs/heads/u real-u &&
- ln -s real-u .git/logs/refs/heads/u &&
- test_must_fail git branch -m u v
-'
-
-test_expect_success 'test tracking setup via --track' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my1 local/master &&
- test $(git config branch.my1.remote) = local &&
- test $(git config branch.my1.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my4 local/master &&
- test $(git config branch.my4.remote) = local &&
- test $(git config branch.my4.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, not matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my5 local/master &&
- ! test "$(git config branch.my5.remote)" = local &&
- ! test "$(git config branch.my5.merge)" = refs/heads/master'
-
-test_expect_success 'test tracking setup via config' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch my3 local/master &&
- test $(git config branch.my3.remote) = local &&
- test $(git config branch.my3.merge) = refs/heads/master'
-
-test_expect_success 'test overriding tracking setup via --no-track' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track my2 local/master &&
- git config branch.autosetupmerge false &&
- ! test "$(git config branch.my2.remote)" = local &&
- ! test "$(git config branch.my2.merge)" = refs/heads/master'
-
-test_expect_success 'no tracking without .fetch entries' \
- 'git config branch.autosetupmerge true &&
- git branch my6 s &&
- git config branch.automsetupmerge false &&
- test -z "$(git config branch.my6.remote)" &&
- test -z "$(git config branch.my6.merge)"'
-
-test_expect_success 'test tracking setup via --track but deeper' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
- git branch --track my7 local/o/o &&
- test "$(git config branch.my7.remote)" = local &&
- test "$(git config branch.my7.merge)" = refs/heads/o/o'
-
-test_expect_success 'test deleting branch deletes branch config' \
- 'git branch -d my7 &&
- test -z "$(git config branch.my7.remote)" &&
- test -z "$(git config branch.my7.merge)"'
-
-test_expect_success 'test deleting branch without config' \
- 'git branch my7 s &&
- sha1=$(git rev-parse my7 | cut -c 1-7) &&
- echo "Deleted branch my7 (was $sha1)." >expect &&
- git branch -d my7 >actual 2>&1 &&
- test_i18ncmp expect actual'
-
-test_expect_success 'test --track without .fetch entries' \
- 'git branch --track my8 &&
- test "$(git config branch.my8.remote)" &&
- test "$(git config branch.my8.merge)"'
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
+ git branch -l u &&
+ mv .git/logs/refs/heads/u real-u &&
+ ln -s real-u .git/logs/refs/heads/u &&
+ test_must_fail git branch -m u v
+'
-test_expect_success \
- 'branch from non-branch HEAD w/autosetupmerge=always' \
- 'git config branch.autosetupmerge always &&
- git branch my9 HEAD^ &&
- git config branch.autosetupmerge false'
+test_expect_success 'test tracking setup via --track' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my1 local/master &&
+ test $(git config branch.my1.remote) = local &&
+ test $(git config branch.my1.merge) = refs/heads/master
+'
-test_expect_success \
- 'branch from non-branch HEAD w/--track causes failure' \
- 'test_must_fail git branch --track my10 HEAD^'
+test_expect_success 'test tracking setup (non-wildcard, matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch \
+ refs/heads/master:refs/remotes/local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my4 local/master &&
+ test $(git config branch.my4.remote) = local &&
+ test $(git config branch.my4.merge) = refs/heads/master
+'
-test_expect_success \
- 'branch from tag w/--track causes failure' \
- 'git tag foobar &&
- test_must_fail git branch --track my11 foobar'
+test_expect_success 'test tracking setup (non-wildcard, not matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my5 local/master &&
+ ! test "$(git config branch.my5.remote)" = local &&
+ ! test "$(git config branch.my5.merge)" = refs/heads/master
+'
+
+test_expect_success 'test tracking setup via config' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch my3 local/master &&
+ test $(git config branch.my3.remote) = local &&
+ test $(git config branch.my3.merge) = refs/heads/master
+'
+
+test_expect_success 'test overriding tracking setup via --no-track' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --no-track my2 local/master &&
+ git config branch.autosetupmerge false &&
+ ! test "$(git config branch.my2.remote)" = local &&
+ ! test "$(git config branch.my2.merge)" = refs/heads/master
+'
+
+test_expect_success 'no tracking without .fetch entries' '
+ git config branch.autosetupmerge true &&
+ git branch my6 s &&
+ git config branch.automsetupmerge false &&
+ test -z "$(git config branch.my6.remote)" &&
+ test -z "$(git config branch.my6.merge)"
+'
+
+test_expect_success 'test tracking setup via --track but deeper' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
+ git branch --track my7 local/o/o &&
+ test "$(git config branch.my7.remote)" = local &&
+ test "$(git config branch.my7.merge)" = refs/heads/o/o
+'
+
+test_expect_success 'test deleting branch deletes branch config' '
+ git branch -d my7 &&
+ test -z "$(git config branch.my7.remote)" &&
+ test -z "$(git config branch.my7.merge)"
+'
+
+test_expect_success 'test deleting branch without config' '
+ git branch my7 s &&
+ sha1=$(git rev-parse my7 | cut -c 1-7) &&
+ echo "Deleted branch my7 (was $sha1)." >expect &&
+ git branch -d my7 >actual 2>&1 &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'test --track without .fetch entries' '
+ git branch --track my8 &&
+ test "$(git config branch.my8.remote)" &&
+ test "$(git config branch.my8.merge)"
+'
+
+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
+ git config branch.autosetupmerge always &&
+ git branch my9 HEAD^ &&
+ git config branch.autosetupmerge false
+'
+
+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
+ test_must_fail git branch --track my10 HEAD^
+'
+
+test_expect_success 'branch from tag w/--track causes failure' '
+ git tag foobar &&
+ test_must_fail git branch --track my11 foobar
+'
# Keep this test last, as it changes the current branch
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
-EOF
-test_expect_success \
- 'git checkout -b g/h/i -l should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git checkout -b g/h/i -l master &&
- test_path_is_file .git/refs/heads/g/h/i &&
- test_path_is_file .git/logs/refs/heads/g/h/i &&
- test_cmp expect .git/logs/refs/heads/g/h/i'
+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
+ cat >expect <<-EOF
+ $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+ EOF
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git checkout -b g/h/i -l master &&
+ test_path_is_file .git/refs/heads/g/h/i &&
+ test_path_is_file .git/logs/refs/heads/g/h/i &&
+ test_cmp expect .git/logs/refs/heads/g/h/i
+'
test_expect_success 'checkout -b makes reflog by default' '
git checkout master &&
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2 4/5] t0040 (parse-options): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (3 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2 3/5] t3200 (branch): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2 5/5] t6300 (for-each-ref): " Tom Grennan
` (5 subsequent siblings)
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t0040-parse-options.sh | 438 ++++++++++++++++++++++------------------------
1 files changed, 212 insertions(+), 226 deletions(-)
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index a1e4616..4a0b991 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -7,87 +7,83 @@ test_description='our own option parser'
. ./test-lib.sh
-cat > expect << EOF
-usage: test-parse-options <options>
-
- -b, --boolean get a boolean
- -4, --or4 bitwise-or boolean with ...0100
- --neg-or4 same as --no-or4
-
- -i, --integer <n> get a integer
- -j <n> get a integer, too
- --set23 set integer to 23
- -t <time> get timestamp of <time>
- -L, --length <str> get length of <str>
- -F, --file <file> set file to <file>
-
-String options
- -s, --string <string>
- get a string
- --string2 <str> get another string
- --st <st> get another string (pervert ordering)
- -o <str> get another string
- --default-string set string to default
- --list <str> add str to list
-
-Magic arguments
- --quux means --quux
- -NUM set integer to NUM
- + same as -b
- --ambiguous positive ambiguity
- --no-ambiguous negative ambiguity
-
-Standard options
- --abbrev[=<n>] use <n> digits to display SHA-1s
- -v, --verbose be verbose
- -n, --dry-run dry run
- -q, --quiet be quiet
-
-EOF
-
test_expect_success 'test help' '
- test_must_fail test-parse-options -h > output 2> output.err &&
+ cat >expect <<-EOF &&
+ usage: test-parse-options <options>
+
+ -b, --boolean get a boolean
+ -4, --or4 bitwise-or boolean with ...0100
+ --neg-or4 same as --no-or4
+
+ -i, --integer <n> get a integer
+ -j <n> get a integer, too
+ --set23 set integer to 23
+ -t <time> get timestamp of <time>
+ -L, --length <str> get length of <str>
+ -F, --file <file> set file to <file>
+
+ String options
+ -s, --string <string>
+ '' get a string
+ --string2 <str> get another string
+ --st <st> get another string (pervert ordering)
+ -o <str> get another string
+ --default-string set string to default
+ --list <str> add str to list
+
+ Magic arguments
+ --quux means --quux
+ -NUM set integer to NUM
+ + same as -b
+ --ambiguous positive ambiguity
+ --no-ambiguous negative ambiguity
+
+ Standard options
+ --abbrev[=<n>] use <n> digits to display SHA-1s
+ -v, --verbose be verbose
+ -n, --dry-run dry run
+ -q, --quiet be quiet
+
+ EOF
+ cp expect expect.err &&
+ test_must_fail test-parse-options -h >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-mv expect expect.err
-
-cat > expect << EOF
-boolean: 2
-integer: 1729
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 2
-quiet: no
-dry run: yes
-file: prefix/my.file
-EOF
-
test_expect_success 'short options' '
+ cat >expect <<-\EOF &&
+ boolean: 2
+ integer: 1729
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 2
+ quiet: no
+ dry run: yes
+ file: prefix/my.file
+ EOF
test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \
- > output 2> output.err &&
+ >output 2>output.err &&
test_cmp expect output &&
test ! -s output.err
'
-cat > expect << EOF
-boolean: 2
-integer: 1729
-timestamp: 0
-string: 321
-abbrev: 10
-verbose: 2
-quiet: no
-dry run: no
-file: prefix/fi.le
-EOF
-
test_expect_success 'long options' '
+ cat >expect <<-\EOF &&
+ boolean: 2
+ integer: 1729
+ timestamp: 0
+ string: 321
+ abbrev: 10
+ verbose: 2
+ quiet: no
+ dry run: no
+ file: prefix/fi.le
+ EOF
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
- --verbose --verbose --no-dry-run --abbrev=10 --file fi.le\
- --obsolete > output 2> output.err &&
+ --verbose --verbose --no-dry-run --abbrev=10 --file fi.le \
+ --obsolete >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
@@ -101,48 +97,46 @@ test_expect_success 'missing required value' '
test $? = 129
'
-cat > expect << EOF
-boolean: 1
-integer: 13
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-arg 00: a1
-arg 01: b1
-arg 02: --boolean
-EOF
-
test_expect_success 'intermingled arguments' '
+ cat >expect <<-\EOF &&
+ boolean: 1
+ integer: 13
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ arg 00: a1
+ arg 01: b1
+ arg 02: --boolean
+ EOF
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
- > output 2> output.err &&
+ >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect << EOF
-boolean: 0
-integer: 2
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'unambiguously abbreviated option' '
- test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 2
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --int 2 --boolean --no-bo >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'unambiguously abbreviated option with "="' '
- test-parse-options --int=2 > output 2> output.err &&
+ test-parse-options --int=2 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
@@ -152,198 +146,190 @@ test_expect_success 'ambiguously abbreviated option' '
test $? = 129
'
-cat > expect << EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
- test-parse-options --st 123 > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --st 123 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > typo.err << EOF
-error: did you mean \`--boolean\` (with two dashes ?)
-EOF
-
test_expect_success 'detect possible typos' '
- test_must_fail test-parse-options -boolean > output 2> output.err &&
- test ! -s output &&
- test_cmp typo.err output.err
+ cat >typo.err <<-\EOF &&
+ error: did you mean `--boolean` (with two dashes ?)
+ EOF
+ >expect
+ test_must_fail test-parse-options -boolean >output 2>output.err &&
+ test_cmp typo.err output.err &&
+ test_cmp expect output
'
-cat > expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-arg 00: --quux
-EOF
-
test_expect_success 'keep some options as arguments' '
- test-parse-options --quux > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ arg 00: --quux
+ EOF
+ test-parse-options --quux >output 2>output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
'
-cat > expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 1
-string: default
-abbrev: 7
-verbose: 0
-quiet: yes
-dry run: no
-file: (not set)
-arg 00: foo
-EOF
-
test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
- foo -q > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 1
+ string: default
+ abbrev: 7
+ verbose: 0
+ quiet: yes
+ dry run: no
+ file: (not set)
+ arg 00: foo
+ EOF
+ test-parse-options -t "1970-01-01 00:00:01 +0000" \
+ --default-string foo -q >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
-Callback: "four", 0
-boolean: 5
-integer: 4
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
- test-parse-options --length=four -b -4 > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ Callback: "four", 0
+ boolean: 5
+ integer: 4
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --length=four -b -4 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
-Callback: "not set", 1
-EOF
-
test_expect_success 'OPT_CALLBACK() and callback errors work' '
- test_must_fail test-parse-options --no-length > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ Callback: "not set", 1
+ EOF
+ test_must_fail test-parse-options --no-length >output 2>output.err &&
test_cmp expect output &&
test_cmp expect.err output.err
'
-cat > expect <<EOF
-boolean: 1
-integer: 23
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 1
+ integer: 23
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --set23 -bbbbb --no-or4 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&
+ test-parse-options --set23 -bbbbb --neg-or4 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
-boolean: 6
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_BIT() works' '
- test-parse-options -bb --or4 > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 6
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options -bb --or4 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'OPT_NEGBIT() works' '
- test-parse-options -bb --no-neg-or4 > output 2> output.err &&
+ test-parse-options -bb --no-neg-or4 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '
- test-parse-options + + + + + + > output 2> output.err &&
+ test-parse-options + + + + + + >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
-boolean: 0
-integer: 12345
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
test_expect_success 'OPT_NUMBER_CALLBACK() works' '
- test-parse-options -12345 > output 2> output.err &&
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 12345
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options -12345 >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat >expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
test-parse-options --no-ambig >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat >>expect <<'EOF'
-list: foo
-list: bar
-list: baz
-EOF
test_expect_success '--list keeps list of strings' '
+ cat >>expect <<-\EOF &&
+ list: foo
+ list: bar
+ list: baz
+ EOF
test-parse-options --list foo --list=bar --list=baz >output &&
test_cmp expect output
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2 5/5] t6300 (for-each-ref): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (4 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2 4/5] t0040 (parse-options): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 101/105] t7004 (tag): " Tom Grennan
` (4 subsequent siblings)
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Unwound one loop to stay within the test_expect_success guard
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t6300-for-each-ref.sh | 186 +++++++++++++++++++++++------------------------
1 files changed, 92 insertions(+), 94 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..ebba7d1 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '
test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
-'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
-EOF
-
test_expect_success 'Check unformatted date fields output' '
+ '"
+ cat >expected <<-EOF &&
+ 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
+ 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
+ EOF
+ "'
(git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
test_cmp expected actual
@@ -171,84 +172,85 @@ test_expect_success 'Check format "relative" date fields output' '
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
'
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03' '2006-07-03'
-'refs/tags/testtag' '2006-07-03'
-EOF
-
test_expect_success 'Check format "short" date fields output' '
+ '"
+ cat >expected <<-EOF
+ 'refs/heads/master' '2006-07-03' '2006-07-03'
+ 'refs/tags/testtag' '2006-07-03'
+ EOF
+ "'
f=short &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
-'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
-EOF
-
test_expect_success 'Check format "local" date fields output' '
- f=local &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
+ '"
+ cat >expected <<-EOF
+ 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
+ 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
+ EOF
+ "'
+ (git for-each-ref --shell --format="%(refname) %(committerdate:local) %(authordate:local)" refs/heads &&
+ git for-each-ref --shell --format="%(refname) %(taggerdate:local)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
-'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
-EOF
-
test_expect_success 'Check format "iso8601" date fields output' '
+ '"
+ cat >expected <<-EOF
+ 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
+ 'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
+ EOF
+ "'
f=iso8601 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
-'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
-EOF
-
test_expect_success 'Check format "rfc2822" date fields output' '
+ '"
+ cat >expected <<-EOF
+ 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
+ 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
+ EOF
+ "'
f=rfc2822 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-refs/heads/master
-refs/remotes/origin/master
-refs/tags/testtag
-EOF
-
test_expect_success 'Verify ascending sort' '
+ cat >expected <<-EOF
+ refs/heads/master
+ refs/remotes/origin/master
+ refs/tags/testtag
+ EOF
git for-each-ref --format="%(refname)" --sort=refname >actual &&
test_cmp expected actual
'
-
-cat >expected <<\EOF
-refs/tags/testtag
-refs/remotes/origin/master
-refs/heads/master
-EOF
-
test_expect_success 'Verify descending sort' '
+ cat >expected <<-EOF
+ refs/tags/testtag
+ refs/remotes/origin/master
+ refs/heads/master
+ EOF
git for-each-ref --format="%(refname)" --sort=-refname >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-'refs/heads/master'
-'refs/remotes/origin/master'
-'refs/tags/testtag'
-EOF
-
test_expect_success 'Quoting style: shell' '
+ '"
+ cat >expected <<-EOF
+ 'refs/heads/master'
+ 'refs/remotes/origin/master'
+ 'refs/tags/testtag'
+ EOF
+ "'
git for-each-ref --shell --format="%(refname)" >actual &&
test_cmp expected actual
'
@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '
test_cmp expected actual
'
-cat >expected <<\EOF
-"refs/heads/master"
-"refs/remotes/origin/master"
-"refs/tags/testtag"
-EOF
-
test_expect_success 'Quoting style: tcl' '
+ cat >expected <<-EOF
+ "refs/heads/master"
+ "refs/remotes/origin/master"
+ "refs/tags/testtag"
+ EOF
git for-each-ref --tcl --format="%(refname)" >actual &&
test_cmp expected actual
'
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
- test_expect_success "more than one quoting style: $i" "
- git for-each-ref $i 2>&1 | (read line &&
- case \$line in
- \"error: more than one quoting style\"*) : happy;;
- *) false
- esac)
- "
-done
-
-cat >expected <<\EOF
-master
-testtag
-EOF
-
+test_expect_success 'more than one quoting styles' '
+ cat >expected <<-EOF
+ error: more than one quoting style?
+ EOF
+ git for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref -s --python 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual
+'
test_expect_success 'Check short refname format' '
+ cat >expected <<-EOF
+ master
+ testtag
+ EOF
(git for-each-ref --format="%(refname:short)" refs/heads &&
git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<EOF
-origin/master
-EOF
-
test_expect_success 'Check short upstream format' '
+ cat >expected <<-EOF
+ origin/master
+ EOF
git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
test_cmp expected actual
'
-cat >expected <<EOF
-67a36f1
-EOF
-
test_expect_success 'Check short objectname format' '
+ cat >expected <<-EOF
+ 67a36f1
+ EOF
git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
test_cmp expected actual
'
@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '
test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
-cat >expected <<\EOF
-heads/master
-tags/master
-EOF
-
test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ cat >expected <<-EOF
+ heads/master
+ tags/master
+ EOF
git config --bool core.warnambiguousrefs true &&
git checkout -b newtag &&
echo "Using $datestamp" > one &&
@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '
test_cmp expected actual
'
-cat >expected <<\EOF
-heads/master
-master
-EOF
-
test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ cat >expected <<-EOF
+ heads/master
+ master
+ EOF
git config --bool core.warnambiguousrefs false &&
git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
-heads/ambiguous
-ambiguous
-EOF
-
test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+ cat >expected <<-EOF
+ heads/ambiguous
+ ambiguous
+ EOF
git checkout master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&
@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '
'
test_expect_success 'create tag with subject and body content' '
- cat >>msg <<-\EOF &&
+ cat >msg <<-\EOF &&
the subject line
first body line
@@ -417,9 +415,9 @@ test_expect_success GPG 'create signed tags' '
git tag -s -m "" signed-empty &&
git tag -s -m "subject line" signed-short &&
cat >msg <<-\EOF &&
- subject line
+ subject line
- body contents
+ body contents
EOF
git tag -s -F msg signed-long
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2-w 101/105] t7004 (tag): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (5 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2 5/5] t6300 (for-each-ref): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 102/105] t5512 (ls-remote): " Tom Grennan
` (3 subsequent siblings)
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks
- Use >FILE instead of > FILE
- Use a "here" filter for generation of expect files with mixed tabs and
spaces
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t7004-tag.sh | 590 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 328 insertions(+), 262 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f8c247a..f819f41 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -27,8 +27,9 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git tag | wc -l` -eq 0
'
-test_expect_success 'looking for a tag in an empty tree should fail' \
- '! (tag_exists mytag)'
+test_expect_success 'looking for a tag in an empty tree should fail' '
+ ! tag_exists mytag
+'
test_expect_success 'creating a tag in an empty tree should fail' '
test_must_fail git tag mynotag &&
@@ -66,27 +67,32 @@ test_expect_success 'listing all tags if one exists should output that tag' '
# pattern matching:
-test_expect_success 'listing a tag using a matching pattern should succeed' \
- 'git tag -l mytag'
+test_expect_success 'listing a tag using a matching pattern should succeed' '
+ git tag -l mytag
+'
test_expect_success \
- 'listing a tag using a matching pattern should output that tag' \
- 'test `git tag -l mytag` = mytag'
+ 'listing a tag using a matching pattern should output that tag' '
+ test `git tag -l mytag` = mytag
+'
# todo: git tag -l now returns always zero, when fixed, change this test
test_expect_success \
- 'listing tags using a non-matching pattern should suceed' \
- 'git tag -l xxx'
+ 'listing tags using a non-matching pattern should suceed' '
+ git tag -l xxx
+'
test_expect_success \
- 'listing tags using a non-matching pattern should output nothing' \
- 'test `git tag -l xxx | wc -l` -eq 0'
+ 'listing tags using a non-matching pattern should output nothing' '
+ test `git tag -l xxx | wc -l` -eq 0
+'
# special cases for creating tags:
test_expect_success \
- 'trying to create a tag with the name of one existing should fail' \
- 'test_must_fail git tag mytag'
+ 'trying to create a tag with the name of one existing should fail' '
+ test_must_fail git tag mytag
+'
test_expect_success \
'trying to create a tag with a non-valid name should fail' '
@@ -111,15 +117,17 @@ test_expect_success 'trying to delete an unknown tag should fail' '
test_must_fail git tag -d unknown-tag
'
-cat >expect <<EOF
+test_expect_success \
+ 'trying to delete tags without params should succeed and do nothing' '
+ cat >expect <<-EOF &&
myhead
mytag
EOF
-test_expect_success \
- 'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && test_cmp expect actual &&
+ git tag -l >actual &&
+ test_cmp expect actual &&
git tag -d &&
- git tag -l > actual && test_cmp expect actual
+ git tag -l >actual &&
+ test_cmp expect actual
'
test_expect_success \
@@ -147,12 +155,15 @@ test_expect_success \
! tag_exists myhead
'
-test_expect_success 'trying to delete an already deleted tag should fail' \
- 'test_must_fail git tag -d mytag'
+test_expect_success \
+ 'trying to delete an already deleted tag should fail' '
+ test_must_fail git tag -d mytag
+'
# listing various tags with pattern matching:
-cat >expect <<EOF
+test_expect_success 'listing all tags should print them ordered' '
+ cat >expect <<-EOF &&
a1
aa1
cba
@@ -163,7 +174,6 @@ v1.0
v1.0.1
v1.1.3
EOF
-test_expect_success 'listing all tags should print them ordered' '
git tag v1.0.1 &&
git tag t211 &&
git tag aa1 &&
@@ -179,81 +189,81 @@ test_expect_success 'listing all tags should print them ordered' '
test_cmp expect actual
'
-cat >expect <<EOF
+test_expect_success \
+ 'listing tags with substring as pattern must print those matching' '
+ cat >expect <<-EOF &&
a1
aa1
cba
EOF
-test_expect_success \
- 'listing tags with substring as pattern must print those matching' '
rm *a* &&
git tag -l "*a*" > current &&
test_cmp expect current
'
-cat >expect <<EOF
+test_expect_success \
+ 'listing tags with a suffix as pattern must print those matching' '
+ cat >expect <<-EOF &&
v0.2.1
v1.0.1
EOF
-test_expect_success \
- 'listing tags with a suffix as pattern must print those matching' '
git tag -l "*.1" > actual &&
test_cmp expect actual
'
-cat >expect <<EOF
+test_expect_success \
+ 'listing tags with a prefix as pattern must print those matching' '
+ cat >expect <<-EOF &&
t210
t211
EOF
-test_expect_success \
- 'listing tags with a prefix as pattern must print those matching' '
git tag -l "t21*" > actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-a1
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
+ a1
+ EOF
git tag -l a1 > actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v1.0
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
+ v1.0
+ EOF
git tag -l v1.0 > actual &&
test_cmp expect actual
'
-cat >expect <<EOF
+test_expect_success \
+ 'listing tags with ? in the pattern should print those matching' '
+ cat >expect <<-EOF &&
v1.0.1
v1.1.3
EOF
-test_expect_success \
- 'listing tags with ? in the pattern should print those matching' '
git tag -l "v1.?.?" > actual &&
test_cmp expect actual
'
->expect
test_expect_success \
'listing tags using v.* should print nothing because none have v.' '
+ >expect &&
git tag -l "v.*" > actual &&
test_cmp expect actual
'
-cat >expect <<EOF
+test_expect_success \
+ 'listing tags using v* should print only those having v' '
+ cat >expect <<-EOF &&
v0.2.1
v1.0
v1.0.1
v1.1.3
EOF
-test_expect_success \
- 'listing tags using v* should print only those having v' '
git tag -l "v*" > actual &&
test_cmp expect actual
'
@@ -272,66 +282,73 @@ test_expect_success \
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_success 'trying to verify an unknown tag should fail' \
- 'test_must_fail git tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' '
+ test_must_fail git tag -v unknown-tag
+'
test_expect_success \
- 'trying to verify a non-annotated and non-signed tag should fail' \
- 'test_must_fail git tag -v non-annotated-tag'
+ 'trying to verify a non-annotated and non-signed tag should fail' '
+ test_must_fail git tag -v non-annotated-tag
+'
test_expect_success \
- 'trying to verify many non-annotated or unknown tags, should fail' \
- 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+ 'trying to verify many non-annotated or unknown tags, should fail' '
+ test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2
+'
# creating annotated tags:
+here='s/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g'
+
get_tag_msg () {
git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
}
# run test_tick before committing always gives the time in that timezone
get_tag_header () {
-cat <<EOF
+ # name, object, type, time
+ cat <<-EOF &&
object $2
type $3
tag $1
tagger C O Mitter <committer@example.com> $4 -0700
EOF
+ sed -e "$here"
}
-commit=$(git rev-parse HEAD)
-time=$test_tick
-
-get_tag_header annotated-tag $commit commit $time >expect
-echo "A message" >>expect
test_expect_success \
'creating an annotated tag with -m message should succeed' '
+ commit=$(git rev-parse HEAD) &&
+ time=$test_tick &&
+ get_tag_header annotated-tag $commit commit $time \
+ >expect <<-EOF &&
+ A message
+ EOF
git tag -m "A message" annotated-tag &&
get_tag_msg annotated-tag >actual &&
test_cmp expect actual
'
-cat >msgfile <<EOF
-Another message
-in a file.
-EOF
-get_tag_header file-annotated-tag $commit commit $time >expect
-cat msgfile >>expect
test_expect_success \
'creating an annotated tag with -F messagefile should succeed' '
+ cat >msgfile <<-EOF &&
+ A message from the
+ standard input
+ EOF
+ get_tag_header file-annotated-tag $commit commit $time >expect <msgfile
git tag -F msgfile file-annotated-tag &&
get_tag_msg file-annotated-tag >actual &&
test_cmp expect actual
'
-cat >inputmsg <<EOF
+test_expect_success 'creating an annotated tag with -F - should succeed' '
+ cat >inputmsg <<-EOF &&
A message from the
standard input
EOF
-get_tag_header stdin-annotated-tag $commit commit $time >expect
-cat inputmsg >>expect
-test_expect_success 'creating an annotated tag with -F - should succeed' '
+ get_tag_header stdin-annotated-tag $commit commit $time \
+ >expect <inputmsg
git tag -F - stdin-annotated-tag <inputmsg &&
get_tag_msg stdin-annotated-tag >actual &&
test_cmp expect actual
@@ -361,29 +378,47 @@ test_expect_success \
# blank and empty messages:
-get_tag_header empty-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -m message should succeed' '
+ >emptyfile &&
+ get_tag_header empty-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -m "" empty-annotated-tag &&
get_tag_msg empty-annotated-tag >actual &&
test_cmp expect actual
'
->emptyfile
-get_tag_header emptyfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -F messagefile should succeed' '
+ get_tag_header emptyfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F emptyfile emptyfile-annotated-tag &&
get_tag_msg emptyfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
-printf '\n\n\nTrailing spaces \t \n' >>blanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
-get_tag_header blanks-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
+test_expect_success \
+ 'extra blanks in the message for an annotated tag should be removed' '
+ sed -e "$here" >blanksfile <<-\EOF &&
+
+ \s\s
+ \t
+ Leading blank lines
+
+ \t\s\t\s\s
+ Repeated blank lines
+
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ get_tag_header blanks-annotated-tag $commit commit $time \
+ >expect <<-EOF &&
Leading blank lines
Repeated blank lines
@@ -392,36 +427,38 @@ Trailing spaces
Trailing blank lines
EOF
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
git tag -F blanksfile blanks-annotated-tag &&
get_tag_msg blanks-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header blank-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -m message with spaces should succeed' '
+ get_tag_header blank-annotated-tag $commit commit $time >expect <emptyfile &&
git tag -m " " blank-annotated-tag &&
get_tag_msg blank-annotated-tag >actual &&
test_cmp expect actual
'
-echo ' ' >blankfile
-echo '' >>blankfile
-echo ' ' >>blankfile
-get_tag_header blankfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -F messagefile with spaces should succeed' '
+ sed -e "$here" >blankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ get_tag_header blankfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F blankfile blankfile-annotated-tag &&
get_tag_msg blankfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf ' ' >blanknonlfile
-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with -F file of spaces and no newline should succeed' '
+ printf " " >blanknonlfile &&
+ get_tag_header blanknonlfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F blanknonlfile blanknonlfile-annotated-tag &&
get_tag_msg blanknonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -429,7 +466,9 @@ test_expect_success \
# messages with commented lines:
-cat >commentsfile <<EOF
+test_expect_success \
+ 'creating a tag using a -F messagefile with #comments should succeed' '
+ cat >commentsfile <<-EOF &&
# A comment
############
@@ -446,8 +485,8 @@ Another line.
Last line.
EOF
-get_tag_header comments-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
+ get_tag_header comments-annotated-tag $commit commit $time \
+ >expect <<-EOF &&
The message.
One line.
@@ -455,36 +494,39 @@ Another line.
Last line.
EOF
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
git tag -F commentsfile comments-annotated-tag &&
get_tag_msg comments-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header comment-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a #comment in the -m message should succeed' '
+ get_tag_header comment-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -m "#comment" comment-annotated-tag &&
get_tag_msg comment-annotated-tag >actual &&
test_cmp expect actual
'
-echo '#comment' >commentfile
-echo '' >>commentfile
-echo '####' >>commentfile
-get_tag_header commentfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with #comments in the -F messagefile should succeed' '
+ cat >commentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ get_tag_header commentfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F commentfile commentfile-annotated-tag &&
get_tag_msg commentfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '#comment' >commentnonlfile
-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a file of #comment and no newline should succeed' '
+ printf "#comment" >commentnonlfile &&
+ get_tag_header commentnonlfile-annotated-tag $commit commit $time \
+ >expect <emptyfile &&
git tag -F commentnonlfile commentnonlfile-annotated-tag &&
get_tag_msg commentnonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -542,11 +584,13 @@ test_expect_success \
test_cmp expect actual
'
-echo 'tag line one' >annotagmsg
-echo 'tag line two' >>annotagmsg
-echo 'tag line three' >>annotagmsg
test_expect_success \
'listing many message lines of a non-signed tag should succeed' '
+ cat >annotagmsg <<-EOF &&
+ tag line one
+ tag line two
+ tag line three
+ EOF
git tag -F annotagmsg tag-lines &&
echo "tag-lines" >expect &&
@@ -621,20 +665,22 @@ test_expect_success GPG \
# creating and verifying signed tags:
-get_tag_header signed-tag $commit commit $time >expect
-echo 'A signed tag message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG 'creating a signed tag with -m message should succeed' '
+test_expect_success GPG \
+ 'creating a signed tag with -m message should succeed' '
+ get_tag_header signed-tag $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A signed tag message" signed-tag &&
get_tag_msg signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header u-signed-tag $commit commit $time >expect
-echo 'Another message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'sign with a given key id' '
-
+ get_tag_header u-signed-tag $commit commit $time >expect <<-EOF &&
+ Another message
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -u committer@example.com -m "Another message" u-signed-tag &&
get_tag_msg u-signed-tag >actual &&
test_cmp expect actual
@@ -654,54 +700,54 @@ test_expect_success GPG 'sign with an unknown id (2)' '
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
+test_expect_success GPG '-u implies signed tag' '
+ write_script fakeeditor <<-\EOF &&
test -n "$1" && exec >"$1"
echo A signed tag message
echo from a fake editor.
EOF
-chmod +x fakeeditor
-
-get_tag_header implied-sign $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG '-u implies signed tag' '
+ get_tag_header implied-sign $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
get_tag_msg implied-sign >actual &&
test_cmp expect actual
'
-cat >sigmsgfile <<EOF
+test_expect_success GPG \
+ 'creating a signed tag with -F messagefile should succeed' '
+ cat >sigmsgfile <<-EOF
Another signed tag
message in a file.
EOF
-get_tag_header file-signed-tag $commit commit $time >expect
-cat sigmsgfile >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with -F messagefile should succeed' '
+ get_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect
git tag -s -F sigmsgfile file-signed-tag &&
get_tag_msg file-signed-tag >actual &&
test_cmp expect actual
'
-cat >siginputmsg <<EOF
+test_expect_success GPG 'creating a signed tag with -F - should succeed' '
+ cat >siginputmsg <<-EOF
A signed tag message from
the standard input
EOF
-get_tag_header stdin-signed-tag $commit commit $time >expect
-cat siginputmsg >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG 'creating a signed tag with -F - should succeed' '
+ get_tag_header stdin-signed-tag $commit commit $time \
+ >expect <siginputmsg &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect
git tag -s -F - stdin-signed-tag <siginputmsg &&
get_tag_msg stdin-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header implied-annotate $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-s implies annotated tag' '
+ get_tag_header implied-annotate $commit commit $time >expect <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
get_tag_msg implied-annotate >actual &&
test_cmp expect actual
@@ -715,11 +761,14 @@ test_expect_success GPG \
! tag_exists nosigtag
'
-test_expect_success GPG 'verifying a signed tag should succeed' \
- 'git tag -v signed-tag'
+test_expect_success GPG 'verifying a signed tag should succeed' '
+ git tag -v signed-tag
+'
-test_expect_success GPG 'verifying two signed tags in one command should succeed' \
- 'git tag -v signed-tag file-signed-tag'
+test_expect_success GPG \
+ 'verifying two signed tags in one command should succeed' '
+ git tag -v signed-tag file-signed-tag
+'
test_expect_success GPG \
'verifying many signed and non-signed tags should fail' '
@@ -740,33 +789,52 @@ test_expect_success GPG 'verifying a forged tag should fail' '
# blank and empty messages for signed tags:
-get_tag_header empty-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -m message should succeed' '
+ get_tag_header empty-signed-tag $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "" empty-signed-tag &&
get_tag_msg empty-signed-tag >actual &&
test_cmp expect actual &&
git tag -v empty-signed-tag
'
->sigemptyfile
-get_tag_header emptyfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -F messagefile should succeed' '
+ >sigemptyfile &&
+ get_tag_header emptyfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigemptyfile emptyfile-signed-tag &&
get_tag_msg emptyfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v emptyfile-signed-tag
'
-printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
-printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
-get_tag_header blanks-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
+test_expect_success GPG \
+ 'extra blanks in the message for a signed tag should be removed' '
+ sed -e "$here" >sigblanksfile <<-\EOF &&
+
+ \s\s
+ \t
+ Leading blank lines
+
+ \t\s\t\s\s
+ Repeated blank lines
+
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ get_tag_header blanks-signed-tag $commit commit $time \
+ >expect <<-EOF &&
Leading blank lines
Repeated blank lines
@@ -774,53 +842,61 @@ Repeated blank lines
Trailing spaces
Trailing blank lines
+ -----BEGIN PGP SIGNATURE-----
EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
git tag -s -F sigblanksfile blanks-signed-tag &&
get_tag_msg blanks-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blanks-signed-tag
'
-get_tag_header blank-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a blank -m message should succeed' '
+ get_tag_header blank-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m " " blank-signed-tag &&
get_tag_msg blank-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blank-signed-tag
'
-echo ' ' >sigblankfile
-echo '' >>sigblankfile
-echo ' ' >>sigblankfile
-get_tag_header blankfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with blank -F file with spaces should succeed' '
+ sed -e "$here" >sigblankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ get_tag_header blankfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigblankfile blankfile-signed-tag &&
get_tag_msg blankfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blankfile-signed-tag
'
-printf ' ' >sigblanknonlfile
-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with spaces and no newline should succeed' '
+ printf >sigblanknonlfile " " &&
+ get_tag_header blanknonlfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
get_tag_msg blanknonlfile-signed-tag >actual &&
test_cmp expect actual &&
- git tag -v signed-tag
+ git tag -v blanknonlfile-signed-tag
'
# messages with commented lines for signed tags:
-cat >sigcommentsfile <<EOF
+test_expect_success GPG \
+ 'creating a signed tag with a -F file with #comments should succeed' '
+ cat >sigcommentsfile <<-EOF &&
# A comment
############
@@ -837,52 +913,57 @@ Another line.
Last line.
EOF
-get_tag_header comments-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
+ get_tag_header comments-signed-tag $commit commit $time \
+ >expect <<-EOF &&
The message.
One line.
Another line.
Last line.
+ -----BEGIN PGP SIGNATURE-----
EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
git tag -s -F sigcommentsfile comments-signed-tag &&
get_tag_msg comments-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comments-signed-tag
'
-get_tag_header comment-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -m message should succeed' '
+ get_tag_header comment-signed-tag $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "#comment" comment-signed-tag &&
get_tag_msg comment-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comment-signed-tag
'
-echo '#comment' >sigcommentfile
-echo '' >>sigcommentfile
-echo '####' >>sigcommentfile
-get_tag_header commentfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -F messagefile should succeed' '
+ cat >sigcommentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ get_tag_header commentfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigcommentfile commentfile-signed-tag &&
get_tag_msg commentfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v commentfile-signed-tag
'
-printf '#comment' >sigcommentnonlfile
-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a #comment and no newline should succeed' '
+ printf "#comment" >sigcommentnonlfile &&
+ get_tag_header commentnonlfile-signed-tag $commit commit $time \
+ >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
get_tag_msg commentnonlfile-signed-tag >actual &&
test_cmp expect actual &&
@@ -941,11 +1022,13 @@ test_expect_success GPG \
test_cmp expect actual
'
-echo 'stag line one' >sigtagmsg
-echo 'stag line two' >>sigtagmsg
-echo 'stag line three' >>sigtagmsg
test_expect_success GPG \
'listing many message lines of a signed tag should succeed' '
+ cat >sigtagmsg <<-EOF &&
+ stag line one
+ stag line two
+ stag line three
+ EOF
git tag -s -F sigtagmsg stag-lines &&
echo "stag-lines" >expect &&
@@ -987,72 +1070,68 @@ test_expect_success GPG \
# tags pointing to objects different from commits:
-tree=$(git rev-parse HEAD^{tree})
-blob=$(git rev-parse HEAD:foo)
-tag=$(git rev-parse signed-tag 2>/dev/null)
-
-get_tag_header tree-signed-tag $tree tree $time >expect
-echo "A message for a tree" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a tree should succeed' '
+ tree=$(git rev-parse HEAD^{tree}) &&
+ blob=$(git rev-parse HEAD:foo) &&
+ tag=$(git rev-parse signed-tag) &&
+ get_tag_header tree-signed-tag $tree tree $time >expect <<-EOF &&
+ A message for a tree
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
get_tag_msg tree-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header blob-signed-tag $blob blob $time >expect
-echo "A message for a blob" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a blob should succeed' '
+ get_tag_header blob-signed-tag $blob blob $time >expect <<-EOF &&
+ A message for a blob
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
get_tag_msg blob-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header tag-signed-tag $tag tag $time >expect
-echo "A message for another tag" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to another tag should succeed' '
+ get_tag_header tag-signed-tag $tag tag $time >expect <<-EOF &&
+ A message for another tag
+ -----BEGIN PGP SIGNATURE-----
+ EOF
git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
get_tag_msg tag-signed-tag >actual &&
test_cmp expect actual
'
# usage with rfc1991 signatures
-echo "rfc1991" > gpghome/gpg.conf
-get_tag_header rfc1991-signed-tag $commit commit $time >expect
-echo "RFC1991 signed tag" >>expect
-echo '-----BEGIN PGP MESSAGE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with rfc1991' '
+test_expect_success GPG 'creating a signed tag with rfc1991' '
+ echo "rfc1991" >gpghome/gpg.conf &&
+ get_tag_header rfc1991-signed-tag $commit commit $time >expect <<-EOF &&
+ RFC1991 signed tag
+ -----BEGIN PGP MESSAGE-----
+ EOF
git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
get_tag_msg rfc1991-signed-tag >actual &&
test_cmp expect actual
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
+test_expect_success GPG 'reediting a signed tag body omits signature' '
+ write_script fakeeditor <<-\EOF &&
cp "$1" actual
EOF
-chmod +x fakeeditor
-
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-test_expect_success GPG \
- 'verifying rfc1991 signature' '
+test_expect_success GPG 'verifying rfc1991 signature' '
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature' '
+test_expect_success GPG 'list tag with rfc1991 signature' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
@@ -1062,15 +1141,12 @@ test_expect_success GPG \
test_cmp expect actual
'
-rm -f gpghome/gpg.conf
-
-test_expect_success GPG \
- 'verifying rfc1991 signature without --rfc1991' '
+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '
+ rm -f gpghome/gpg.conf &&
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature without --rfc1991' '
+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
@@ -1080,26 +1156,26 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '
# try to sign with bad user.signingkey
-git config user.signingkey BobTheMouse
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured' \
- 'test_must_fail git tag -s -m tail tag-gpg-failure'
+ git config user.signingkey BobTheMouse &&
+ test_must_fail git tag -s -m tail tag-gpg-failure &&
git config --unset user.signingkey
+'
# try to verify without gpg:
-rm -rf gpghome
test_expect_success GPG \
- 'verify signed tag fails when public key is not present' \
- 'test_must_fail git tag -v signed-tag'
+ 'verify signed tag fails when public key is not present' '
+ rm -rf gpghome &&
+ test_must_fail git tag -v signed-tag
+'
test_expect_success \
'git tag -a fails if tag annotation is empty' '
@@ -1126,12 +1202,13 @@ test_expect_success \
test_cmp rest.expect rest.actual
'
-get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >> expect
test_expect_success \
'overwriting an annoted tag should use its previous body' '
+ get_tag_header reuse $commit commit $time >expect <<-EOF &&
+ reuse
+ EOF
git tag -a -m "An annotation to be reused" reuse &&
- GIT_EDITOR=true git tag -f -a reuse &&
+ GIT_EDITOR=true git tag -f -a -m "reuse" reuse &&
get_tag_msg reuse >actual &&
test_cmp expect actual
'
@@ -1158,68 +1235,61 @@ test_expect_success 'filename for the message is relative to cwd' '
# create a few more commits to test --contains
-hash1=$(git rev-parse HEAD)
-
test_expect_success 'creating second commit and tag' '
+ hash1=$(git rev-parse HEAD) &&
echo foo-2.0 >foo &&
git add foo &&
git commit -m second &&
+ hash2=$(git rev-parse HEAD) &&
git tag v2.0
'
-hash2=$(git rev-parse HEAD)
-
test_expect_success 'creating third commit without tag' '
echo foo-dev >foo &&
git add foo &&
- git commit -m third
-'
-
+ git commit -m third &&
hash3=$(git rev-parse HEAD)
+'
-# simple linear checks of --continue
+# simple linear checks of --contains
-cat > expected <<EOF
+test_expect_success 'checking that first commit is in all tags (hash)' '
+ cat >expected <<-EOF &&
v0.2.1
v1.0
v1.0.1
v1.1.3
v2.0
EOF
-
-test_expect_success 'checking that first commit is in all tags (hash)' "
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
# other ways of specifying the commit
-test_expect_success 'checking that first commit is in all tags (tag)' "
+test_expect_success 'checking that first commit is in all tags (tag)' '
git tag -l --contains v1.0 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that first commit is in all tags (relative)' "
+test_expect_success 'checking that first commit is in all tags (relative)' '
git tag -l --contains HEAD~2 v* >actual &&
test_cmp expected actual
-"
+'
-cat > expected <<EOF
+test_expect_success 'checking that second commit only has one tag' '
+ cat >expected <<-EOF &&
v2.0
EOF
-
-test_expect_success 'checking that second commit only has one tag' "
git tag -l --contains $hash2 v* >actual &&
test_cmp expected actual
-"
-
+'
-cat > expected <<EOF
+test_expect_success 'checking that third commit has no tags' '
+ cat >expected <<-EOF &&
EOF
-
-test_expect_success 'checking that third commit has no tags' "
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
# how about a simple merge?
@@ -1228,35 +1298,33 @@ test_expect_success 'creating simple branch' '
git checkout stable &&
echo foo-3.0 > foo &&
git commit foo -m fourth &&
+ hash4=$(git rev-parse HEAD) &&
git tag v3.0
'
-hash4=$(git rev-parse HEAD)
-
-cat > expected <<EOF
+test_expect_success 'checking that branch head only has one tag' '
+ cat >expected <<-EOF &&
v3.0
EOF
-
-test_expect_success 'checking that branch head only has one tag' "
git tag -l --contains $hash4 v* >actual &&
test_cmp expected actual
-"
+'
test_expect_success 'merging original branch into this branch' '
git merge --strategy=ours master &&
git tag v4.0
'
-cat > expected <<EOF
+test_expect_success 'checking that original branch head has one tag now' '
+ cat >expected <<-EOF &&
v4.0
EOF
-
-test_expect_success 'checking that original branch head has one tag now' "
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
-cat > expected <<EOF
+test_expect_success 'checking that initial commit is in all tags' '
+ cat >expected <<-EOF &&
v0.2.1
v1.0
v1.0.1
@@ -1265,11 +1333,9 @@ v2.0
v3.0
v4.0
EOF
-
-test_expect_success 'checking that initial commit is in all tags' "
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
# mixing modes and options:
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2-w 102/105] t5512 (ls-remote): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (6 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2-w 101/105] t7004 (tag): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 103/105] t3200 (branch): " Tom Grennan
` (2 subsequent siblings)
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
Guard setup with test_expect_success
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t5512-ls-remote.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 5c546c9..811dcc3 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -102,11 +102,13 @@ test_expect_success 'use branch.<name>.remote if possible' '
'
-cat >exp <<EOF
+test_expect_success 'confuses pattern as remote when no remote specified' '
+ '"
+ cat >exp <<-EOF
fatal: 'refs*master' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
EOF
-test_expect_success 'confuses pattern as remote when no remote specified' '
+ "'
#
# Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly,
# confuses <pattern> for <remote>. Although ugly, this behaviour is akin
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2-w 103/105] t3200 (branch): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (7 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2-w 102/105] t5512 (ls-remote): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 104/105] t0040 (parse-options): " Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 105/105] t6300 (for-each-ref): " Tom Grennan
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t3200-branch.sh | 211 +++++++++++++++++++++++++++--------------------------
1 files changed, 109 insertions(+), 102 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index dd1aceb..7191b89 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -7,15 +7,15 @@ test_description='git branch assorted tests'
. ./test-lib.sh
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
+test_expect_success 'prepare a trivial repository' '
+ echo Hello >A &&
git update-index --add A &&
git commit -m "Initial commit." &&
echo World >> A &&
git update-index --add A &&
git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+ HEAD=$(git rev-parse --verify HEAD)
+'
test_expect_success \
'git branch --help should not have created a bogus branch' '
@@ -34,59 +34,59 @@ test_expect_success 'branch -h in broken repository' '
grep "[Uu]sage" broken/usage
'
-test_expect_success \
- 'git branch abc should create a branch' \
- 'git branch abc && test_path_is_file .git/refs/heads/abc'
+test_expect_success 'git branch abc should create a branch' '
+ git branch abc && test_path_is_file .git/refs/heads/abc
+'
-test_expect_success \
- 'git branch a/b/c should create a branch' \
- 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
+test_expect_success 'git branch a/b/c should create a branch' '
+ git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
+'
-cat >expect <<EOF
+test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+ cat >expect <<-EOF
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
-test_expect_success \
- 'git branch -l d/e/f should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
git branch -l d/e/f &&
test_path_is_file .git/refs/heads/d/e/f &&
test_path_is_file .git/logs/refs/heads/d/e/f &&
- test_cmp expect .git/logs/refs/heads/d/e/f'
+ test_cmp expect .git/logs/refs/heads/d/e/f
+'
-test_expect_success \
- 'git branch -d d/e/f should delete a branch and a log' \
- 'git branch -d d/e/f &&
+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
+ git branch -d d/e/f &&
test_path_is_missing .git/refs/heads/d/e/f &&
- test_path_is_missing .git/logs/refs/heads/d/e/f'
+ test_path_is_missing .git/logs/refs/heads/d/e/f
+'
-test_expect_success \
- 'git branch j/k should work after branch j has been deleted' \
- 'git branch j &&
+test_expect_success 'git branch j/k should work after branch j has been deleted' '
+ git branch j &&
git branch -d j &&
- git branch j/k'
+ git branch j/k
+'
-test_expect_success \
- 'git branch l should work after branch l/m has been deleted' \
- 'git branch l/m &&
+test_expect_success 'git branch l should work after branch l/m has been deleted' '
+ git branch l/m &&
git branch -d l/m &&
- git branch l'
+ git branch l
+'
-test_expect_success \
- 'git branch -m dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- grep "[Uu]sage: git branch" err'
+test_expect_success 'git branch -m dumps usage' '
+ test_expect_code 129 git branch -m 2>err &&
+ grep "[Uu]sage: git branch" err
+'
-test_expect_success \
- 'git branch -m m m/m should work' \
- 'git branch -l m &&
+test_expect_success 'git branch -m m m/m should work' '
+ git branch -l m &&
git branch -m m m/m &&
- test_path_is_file .git/logs/refs/heads/m/m'
+ test_path_is_file .git/logs/refs/heads/m/m
+'
-test_expect_success \
- 'git branch -m n/n n should work' \
- 'git branch -l n/n &&
+test_expect_success 'git branch -m n/n n should work' '
+ git branch -l n/n &&
git branch -m n/n n &&
- test_path_is_file .git/logs/refs/heads/n'
+ test_path_is_file .git/logs/refs/heads/n
+'
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
git branch o/o &&
@@ -160,33 +160,30 @@ test_expect_success 'git branch --list -d t should fail' '
test_path_is_missing .git/refs/heads/t
'
-mv .git/config .git/config-saved
-
test_expect_success 'git branch -m q q2 without config should succeed' '
+ mv .git/config .git/config-saved &&
+ test_when_finished mv .git/config-saved .git/config &&
git branch -m q q2 &&
git branch -m q2 q
'
-mv .git/config-saved .git/config
-
+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
git config branch.s/s.dummy Hello
-
-test_expect_success \
- 'git branch -m s/s s should work when s/t is deleted' \
- 'git branch -l s/s &&
+ git branch -l s/s &&
test_path_is_file .git/logs/refs/heads/s/s &&
git branch -l s/t &&
test_path_is_file .git/logs/refs/heads/s/t &&
git branch -d s/t &&
git branch -m s/s s &&
- test_path_is_file .git/logs/refs/heads/s'
-
-test_expect_success 'config information was renamed, too' \
- "test $(git config branch.s.dummy) = Hello &&
- test_must_fail git config branch.s/s/dummy"
+ test_path_is_file .git/logs/refs/heads/s
+'
-test_expect_success 'renaming a symref is not allowed' \
+test_expect_success 'config information was renamed, too' '
+ test $(git config branch.s.dummy) = Hello &&
+ test_must_fail git config branch.s/s/dummy
'
+
+test_expect_success 'renaming a symref is not allowed' '
git symbolic-ref refs/heads/master2 refs/heads/master &&
test_must_fail git branch -m master2 master3 &&
git symbolic-ref refs/heads/master2 &&
@@ -194,115 +191,125 @@ test_expect_success 'renaming a symref is not allowed' \
test_path_is_missing .git/refs/heads/master3
'
-test_expect_success SYMLINKS \
- 'git branch -m u v should fail when the reflog for u is a symlink' '
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
git branch -l u &&
mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u &&
test_must_fail git branch -m u v
'
-test_expect_success 'test tracking setup via --track' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup via --track' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track my1 local/master &&
test $(git config branch.my1.remote) = local &&
- test $(git config branch.my1.merge) = refs/heads/master'
+ test $(git config branch.my1.merge) = refs/heads/master
+'
-test_expect_success 'test tracking setup (non-wildcard, matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
+test_expect_success 'test tracking setup (non-wildcard, matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch \
+ refs/heads/master:refs/remotes/local/master &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track my4 local/master &&
test $(git config branch.my4.remote) = local &&
- test $(git config branch.my4.merge) = refs/heads/master'
+ test $(git config branch.my4.merge) = refs/heads/master
+'
-test_expect_success 'test tracking setup (non-wildcard, not matching)' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup (non-wildcard, not matching)' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --track my5 local/master &&
! test "$(git config branch.my5.remote)" = local &&
- ! test "$(git config branch.my5.merge)" = refs/heads/master'
+ ! test "$(git config branch.my5.merge)" = refs/heads/master
+'
-test_expect_success 'test tracking setup via config' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'test tracking setup via config' '
+ git config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch my3 local/master &&
test $(git config branch.my3.remote) = local &&
- test $(git config branch.my3.merge) = refs/heads/master'
+ test $(git config branch.my3.merge) = refs/heads/master
+'
-test_expect_success 'test overriding tracking setup via --no-track' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'test overriding tracking setup via --no-track' '
+ git config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --no-track my2 local/master &&
git config branch.autosetupmerge false &&
! test "$(git config branch.my2.remote)" = local &&
- ! test "$(git config branch.my2.merge)" = refs/heads/master'
+ ! test "$(git config branch.my2.merge)" = refs/heads/master
+'
-test_expect_success 'no tracking without .fetch entries' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'no tracking without .fetch entries' '
+ git config branch.autosetupmerge true &&
git branch my6 s &&
git config branch.automsetupmerge false &&
test -z "$(git config branch.my6.remote)" &&
- test -z "$(git config branch.my6.merge)"'
+ test -z "$(git config branch.my6.merge)"
+'
-test_expect_success 'test tracking setup via --track but deeper' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup via --track but deeper' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/o/o || git fetch local) &&
git branch --track my7 local/o/o &&
test "$(git config branch.my7.remote)" = local &&
- test "$(git config branch.my7.merge)" = refs/heads/o/o'
+ test "$(git config branch.my7.merge)" = refs/heads/o/o
+'
-test_expect_success 'test deleting branch deletes branch config' \
- 'git branch -d my7 &&
+test_expect_success 'test deleting branch deletes branch config' '
+ git branch -d my7 &&
test -z "$(git config branch.my7.remote)" &&
- test -z "$(git config branch.my7.merge)"'
+ test -z "$(git config branch.my7.merge)"
+'
-test_expect_success 'test deleting branch without config' \
- 'git branch my7 s &&
+test_expect_success 'test deleting branch without config' '
+ git branch my7 s &&
sha1=$(git rev-parse my7 | cut -c 1-7) &&
echo "Deleted branch my7 (was $sha1)." >expect &&
git branch -d my7 >actual 2>&1 &&
- test_i18ncmp expect actual'
+ test_i18ncmp expect actual
+'
-test_expect_success 'test --track without .fetch entries' \
- 'git branch --track my8 &&
+test_expect_success 'test --track without .fetch entries' '
+ git branch --track my8 &&
test "$(git config branch.my8.remote)" &&
- test "$(git config branch.my8.merge)"'
+ test "$(git config branch.my8.merge)"
+'
-test_expect_success \
- 'branch from non-branch HEAD w/autosetupmerge=always' \
- 'git config branch.autosetupmerge always &&
+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
+ git config branch.autosetupmerge always &&
git branch my9 HEAD^ &&
- git config branch.autosetupmerge false'
+ git config branch.autosetupmerge false
+'
-test_expect_success \
- 'branch from non-branch HEAD w/--track causes failure' \
- 'test_must_fail git branch --track my10 HEAD^'
+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
+ test_must_fail git branch --track my10 HEAD^
+'
-test_expect_success \
- 'branch from tag w/--track causes failure' \
- 'git tag foobar &&
- test_must_fail git branch --track my11 foobar'
+test_expect_success 'branch from tag w/--track causes failure' '
+ git tag foobar &&
+ test_must_fail git branch --track my11 foobar
+'
# Keep this test last, as it changes the current branch
-cat >expect <<EOF
+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
+ cat >expect <<-EOF
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
-test_expect_success \
- 'git checkout -b g/h/i -l should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
git checkout -b g/h/i -l master &&
test_path_is_file .git/refs/heads/g/h/i &&
test_path_is_file .git/logs/refs/heads/g/h/i &&
- test_cmp expect .git/logs/refs/heads/g/h/i'
+ test_cmp expect .git/logs/refs/heads/g/h/i
+'
test_expect_success 'checkout -b makes reflog by default' '
git checkout master &&
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2-w 104/105] t0040 (parse-options): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (8 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2-w 103/105] t3200 (branch): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
2012-03-03 2:15 ` [PATCHv2-w 105/105] t6300 (for-each-ref): " Tom Grennan
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t0040-parse-options.sh | 96 +++++++++++++++++++--------------------------
1 files changed, 41 insertions(+), 55 deletions(-)
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index a1e4616..4a0b991 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -7,7 +7,8 @@ test_description='our own option parser'
. ./test-lib.sh
-cat > expect << EOF
+test_expect_success 'test help' '
+ cat >expect <<-EOF &&
usage: test-parse-options <options>
-b, --boolean get a boolean
@@ -23,7 +24,7 @@ usage: test-parse-options <options>
String options
-s, --string <string>
- get a string
+ '' get a string
--string2 <str> get another string
--st <st> get another string (pervert ordering)
-o <str> get another string
@@ -44,16 +45,14 @@ Standard options
-q, --quiet be quiet
EOF
-
-test_expect_success 'test help' '
+ cp expect expect.err &&
test_must_fail test-parse-options -h > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-mv expect expect.err
-
-cat > expect << EOF
+test_expect_success 'short options' '
+ cat >expect <<-\EOF &&
boolean: 2
integer: 1729
timestamp: 0
@@ -64,15 +63,14 @@ quiet: no
dry run: yes
file: prefix/my.file
EOF
-
-test_expect_success 'short options' '
test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \
> output 2> output.err &&
test_cmp expect output &&
test ! -s output.err
'
-cat > expect << EOF
+test_expect_success 'long options' '
+ cat >expect <<-\EOF &&
boolean: 2
integer: 1729
timestamp: 0
@@ -83,8 +81,6 @@ quiet: no
dry run: no
file: prefix/fi.le
EOF
-
-test_expect_success 'long options' '
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\
--obsolete > output 2> output.err &&
@@ -101,7 +97,8 @@ test_expect_success 'missing required value' '
test $? = 129
'
-cat > expect << EOF
+test_expect_success 'intermingled arguments' '
+ cat >expect <<-\EOF &&
boolean: 1
integer: 13
timestamp: 0
@@ -115,15 +112,14 @@ arg 00: a1
arg 01: b1
arg 02: --boolean
EOF
-
-test_expect_success 'intermingled arguments' '
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
> output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect << EOF
+test_expect_success 'unambiguously abbreviated option' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 2
timestamp: 0
@@ -134,8 +130,6 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'unambiguously abbreviated option' '
test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
@@ -152,7 +146,8 @@ test_expect_success 'ambiguously abbreviated option' '
test $? = 129
'
-cat > expect << EOF
+test_expect_success 'non ambiguous option (after two options it abbreviates)' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -163,24 +158,23 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'non ambiguous option (after two options it abbreviates)' '
test-parse-options --st 123 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > typo.err << EOF
-error: did you mean \`--boolean\` (with two dashes ?)
-EOF
-
test_expect_success 'detect possible typos' '
+ cat >typo.err <<-\EOF &&
+ error: did you mean `--boolean` (with two dashes ?)
+ EOF
+ >expect
test_must_fail test-parse-options -boolean > output 2> output.err &&
- test ! -s output &&
- test_cmp typo.err output.err
+ test_cmp typo.err output.err &&
+ test_cmp expect output
'
-cat > expect <<EOF
+test_expect_success 'keep some options as arguments' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -192,14 +186,13 @@ dry run: no
file: (not set)
arg 00: --quux
EOF
-
-test_expect_success 'keep some options as arguments' '
test-parse-options --quux > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
+test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 1
@@ -211,15 +204,14 @@ dry run: no
file: (not set)
arg 00: foo
EOF
-
-test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
- foo -q > output 2> output.err &&
+ test-parse-options -t "1970-01-01 00:00:01 +0000" \
+ --default-string foo -q >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
+test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
+ cat >expect <<-\EOF &&
Callback: "four", 0
boolean: 5
integer: 4
@@ -231,24 +223,22 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
test-parse-options --length=four -b -4 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat > expect <<EOF
+test_expect_success 'OPT_CALLBACK() and callback errors work' '
+ cat >expect <<-\EOF &&
Callback: "not set", 1
EOF
-
-test_expect_success 'OPT_CALLBACK() and callback errors work' '
test_must_fail test-parse-options --no-length > output 2> output.err &&
test_cmp expect output &&
test_cmp expect.err output.err
'
-cat > expect <<EOF
+test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
+ cat >expect <<-\EOF &&
boolean: 1
integer: 23
timestamp: 0
@@ -259,8 +249,6 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
@@ -272,7 +260,8 @@ test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
test_cmp expect output
'
-cat > expect <<EOF
+test_expect_success 'OPT_BIT() works' '
+ cat >expect <<-\EOF &&
boolean: 6
integer: 0
timestamp: 0
@@ -283,8 +272,6 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_BIT() works' '
test-parse-options -bb --or4 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
@@ -302,7 +289,9 @@ test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '
test_cmp expect output
'
-cat > expect <<EOF
+
+test_expect_success 'OPT_NUMBER_CALLBACK() works' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 12345
timestamp: 0
@@ -313,14 +302,13 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_NUMBER_CALLBACK() works' '
test-parse-options -12345 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat >expect <<EOF
+test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -331,19 +319,17 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
test-parse-options --no-ambig >output 2>output.err &&
test ! -s output.err &&
test_cmp expect output
'
-cat >>expect <<'EOF'
+test_expect_success '--list keeps list of strings' '
+ cat >>expect <<-\EOF &&
list: foo
list: bar
list: baz
EOF
-test_expect_success '--list keeps list of strings' '
test-parse-options --list foo --list=bar --list=baz >output &&
test_cmp expect output
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCHv2-w 105/105] t6300 (for-each-ref): modernize style
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
` (9 preceding siblings ...)
2012-03-03 2:15 ` [PATCHv2-w 104/105] t0040 (parse-options): " Tom Grennan
@ 2012-03-03 2:15 ` Tom Grennan
10 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-03 2:15 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Johannes Schindelin
- Guard setup with test_expect_success
- Unwound one loop to stay within the test_expect_success guard
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t6300-for-each-ref.sh | 118 +++++++++++++++++++++++------------------------
1 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..ebba7d1 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '
test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
'
-cat >expected <<\EOF
+test_expect_success 'Check unformatted date fields output' '
+ '"
+ cat >expected <<-EOF &&
'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
EOF
-
-test_expect_success 'Check unformatted date fields output' '
+ "'
(git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
test_cmp expected actual
@@ -171,84 +172,85 @@ test_expect_success 'Check format "relative" date fields output' '
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "short" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' '2006-07-03' '2006-07-03'
'refs/tags/testtag' '2006-07-03'
EOF
-
-test_expect_success 'Check format "short" date fields output' '
+ "'
f=short &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "local" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
EOF
-
-test_expect_success 'Check format "local" date fields output' '
- f=local &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
+ "'
+ (git for-each-ref --shell --format="%(refname) %(committerdate:local) %(authordate:local)" refs/heads &&
+ git for-each-ref --shell --format="%(refname) %(taggerdate:local)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "iso8601" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "iso8601" date fields output' '
+ "'
f=iso8601 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "rfc2822" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "rfc2822" date fields output' '
+ "'
f=rfc2822 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Verify ascending sort' '
+ cat >expected <<-EOF
refs/heads/master
refs/remotes/origin/master
refs/tags/testtag
EOF
-
-test_expect_success 'Verify ascending sort' '
git for-each-ref --format="%(refname)" --sort=refname >actual &&
test_cmp expected actual
'
-
-cat >expected <<\EOF
+test_expect_success 'Verify descending sort' '
+ cat >expected <<-EOF
refs/tags/testtag
refs/remotes/origin/master
refs/heads/master
EOF
-
-test_expect_success 'Verify descending sort' '
git for-each-ref --format="%(refname)" --sort=-refname >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: shell' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master'
'refs/remotes/origin/master'
'refs/tags/testtag'
EOF
-
-test_expect_success 'Quoting style: shell' '
+ "'
git for-each-ref --shell --format="%(refname)" >actual &&
test_cmp expected actual
'
@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: tcl' '
+ cat >expected <<-EOF
"refs/heads/master"
"refs/remotes/origin/master"
"refs/tags/testtag"
EOF
-
-test_expect_success 'Quoting style: tcl' '
git for-each-ref --tcl --format="%(refname)" >actual &&
test_cmp expected actual
'
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
- test_expect_success "more than one quoting style: $i" "
- git for-each-ref $i 2>&1 | (read line &&
- case \$line in
- \"error: more than one quoting style\"*) : happy;;
- *) false
- esac)
- "
-done
-
-cat >expected <<\EOF
+test_expect_success 'more than one quoting styles' '
+ cat >expected <<-EOF
+ error: more than one quoting style?
+ EOF
+ git for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref -s --python 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual
+'
+test_expect_success 'Check short refname format' '
+ cat >expected <<-EOF
master
testtag
EOF
-
-test_expect_success 'Check short refname format' '
(git for-each-ref --format="%(refname:short)" refs/heads &&
git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<EOF
+test_expect_success 'Check short upstream format' '
+ cat >expected <<-EOF
origin/master
EOF
-
-test_expect_success 'Check short upstream format' '
git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
test_cmp expected actual
'
-cat >expected <<EOF
+test_expect_success 'Check short objectname format' '
+ cat >expected <<-EOF
67a36f1
EOF
-
-test_expect_success 'Check short objectname format' '
git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
test_cmp expected actual
'
@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '
test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ cat >expected <<-EOF
heads/master
tags/master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (strict)' '
git config --bool core.warnambiguousrefs true &&
git checkout -b newtag &&
echo "Using $datestamp" > one &&
@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ cat >expected <<-EOF
heads/master
master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (loose)' '
git config --bool core.warnambiguousrefs false &&
git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+ cat >expected <<-EOF
heads/ambiguous
ambiguous
EOF
-
-test_expect_success 'Check ambiguous head and tag refs II (loose)' '
git checkout master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&
@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '
'
test_expect_success 'create tag with subject and body content' '
- cat >>msg <<-\EOF &&
+ cat >msg <<-\EOF &&
the subject line
first body line
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH 1/5] t6300 (for-each-ref): modernize style
2012-02-23 0:22 ` Tom Grennan
2012-02-23 1:00 ` Junio C Hamano
2012-03-01 1:45 ` [PATCH 0/5] modernize test style Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 6:53 ` Johannes Sixt
2012-03-01 1:45 ` [PATCH 2/5] t5512 (ls-remote): " Tom Grennan
` (8 subsequent siblings)
11 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t6300-for-each-ref.sh | 364 +++++++++++++++++++++++++----------------------
1 files changed, 191 insertions(+), 173 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..12916b2 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -5,9 +5,17 @@
test_description='for-each-ref test'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+
# Mon Jul 3 15:18:43 2006 +0000
datestamp=1151939923
setdate_and_increment () {
@@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '
setdate_and_increment &&
echo "Using $datestamp" > one &&
git add one &&
- git commit -m "Initial" &&
+ git commit -q -m "Initial" &&
setdate_and_increment &&
- git tag -a -m "Tagging at $datestamp" testtag
+ quiet git tag -a -m "Tagging at $datestamp" testtag
'
test_expect_success 'Create upstream config' '
@@ -115,261 +123,270 @@ test_atom tag contents 'Tagging at 1151939927
'
test_expect_success 'Check invalid atoms names are errors' '
- test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
+ silent test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
'
test_expect_success 'Check format specifiers are ignored in naming date atoms' '
- git for-each-ref --format="%(authordate)" refs/heads &&
- git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
- git for-each-ref --format="%(authordate) %(authordate:default)" refs/heads &&
- git for-each-ref --format="%(authordate:default) %(authordate:default)" refs/heads
+ f1="%(authordate)" &&
+ f2="%(authordate:default) %(authordate)" &&
+ f3="%(authordate) %(authordate:default)" &&
+ f4="%(authordate:default) %(authordate:default)"
+ quiet git for-each-ref --format="$f1" refs/heads &&
+ quiet git for-each-ref --format="$f2" refs/heads &&
+ quiet git for-each-ref --format="$f3" refs/heads &&
+ quiet git for-each-ref --format="$f4" refs/heads
'
test_expect_success 'Check valid format specifiers for date fields' '
- git for-each-ref --format="%(authordate:default)" refs/heads &&
- git for-each-ref --format="%(authordate:relative)" refs/heads &&
- git for-each-ref --format="%(authordate:short)" refs/heads &&
- git for-each-ref --format="%(authordate:local)" refs/heads &&
- git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
- git for-each-ref --format="%(authordate:rfc2822)" refs/heads
+ quiet git for-each-ref --format="%(authordate:default)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:relative)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:short)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:local)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:rfc2822)" refs/heads
'
test_expect_success 'Check invalid format specifiers are errors' '
- test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
+ h="%(authordate:INVALID)" &&
+ silent test_must_fail git for-each-ref --format="$h" refs/heads
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
-'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
-EOF
-
test_expect_success 'Check unformatted date fields output' '
- (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF &&
+ 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
+ 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
+ EOF
+ "'
+ h="%(refname) %(committerdate) %(authordate)" &&
+ t="%(refname) %(taggerdate)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
test_expect_success 'Check format "default" formatted date fields output' '
- f=default &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ h="%(refname) %(committerdate:default) %(authordate:default)" &&
+ t="%(refname) %(taggerdate:default)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-# Don't know how to do relative check because I can't know when this script
-# is going to be run and can't fake the current time to git, and hence can't
-# provide expected output. Instead, I'll just make sure that "relative"
-# doesn't exit in error
-#
-#cat >expected <<\EOF
-#
-#EOF
-#
test_expect_success 'Check format "relative" date fields output' '
- f=relative &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
+ '"
+ # Don't know how to do relative check because I can't know when this
+ # script is going to be run and can't fake the current time to git,
+ # and hence can't provide expected output. Instead, I'll just make
+ # sure that 'relative' doesn't exit in error
+ "'
+ h="%(refname) %(committerdate:relative) %(authordate:relative)" &&
+ t="%(refname) %(taggerdate:relative)" &&
+ quiet git for-each-ref --shell --format="$h" refs/heads &&
+ quiet git for-each-ref --shell --format="$t" refs/tags
'
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03' '2006-07-03'
-'refs/tags/testtag' '2006-07-03'
-EOF
-
test_expect_success 'Check format "short" date fields output' '
- f=short &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF
+ 'refs/heads/master' '2006-07-03' '2006-07-03'
+ 'refs/tags/testtag' '2006-07-03'
+ EOF
+ "'
+ h="%(refname) %(committerdate:short) %(authordate:short)" &&
+ t="%(refname) %(taggerdate:short)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
-'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
-EOF
-
test_expect_success 'Check format "local" date fields output' '
- f=local &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF
+ 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
+ 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
+ EOF
+ "'
+ h="%(refname) %(committerdate:local) %(authordate:local)" &&
+ t="%(refname) %(taggerdate:local)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
-'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
-'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
-EOF
-
test_expect_success 'Check format "iso8601" date fields output' '
- f=iso8601 &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF
+ 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
+ 'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
+ EOF
+ "'
+ h="%(refname) %(committerdate:iso8601) %(authordate:iso8601)" &&
+ t="%(refname) %(taggerdate:iso8601)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
-'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
-'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
-EOF
-
test_expect_success 'Check format "rfc2822" date fields output' '
- f=rfc2822 &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF
+ 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
+ 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
+ EOF
+ "'
+ h="%(refname) %(committerdate:rfc2822) %(authordate:rfc2822)" &&
+ t="%(refname) %(taggerdate:rfc2822)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
-refs/heads/master
-refs/remotes/origin/master
-refs/tags/testtag
-EOF
-
test_expect_success 'Verify ascending sort' '
- git for-each-ref --format="%(refname)" --sort=refname >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ refs/heads/master
+ refs/remotes/origin/master
+ refs/tags/testtag
+ EOF
+ git for-each-ref --format="%(refname)" --sort=refname |
+ test_cmp expect -
'
-
-cat >expected <<\EOF
-refs/tags/testtag
-refs/remotes/origin/master
-refs/heads/master
-EOF
-
test_expect_success 'Verify descending sort' '
- git for-each-ref --format="%(refname)" --sort=-refname >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ refs/tags/testtag
+ refs/remotes/origin/master
+ refs/heads/master
+ EOF
+ git for-each-ref --format="%(refname)" --sort=-refname |
+ test_cmp expect -
'
-cat >expected <<\EOF
-'refs/heads/master'
-'refs/remotes/origin/master'
-'refs/tags/testtag'
-EOF
-
test_expect_success 'Quoting style: shell' '
- git for-each-ref --shell --format="%(refname)" >actual &&
- test_cmp expected actual
+ '"
+ cat >expect <<-EOF
+ 'refs/heads/master'
+ 'refs/remotes/origin/master'
+ 'refs/tags/testtag'
+ EOF
+ "'
+ git for-each-ref --shell --format="%(refname)" |
+ test_cmp expect -
'
test_expect_success 'Quoting style: perl' '
- git for-each-ref --perl --format="%(refname)" >actual &&
- test_cmp expected actual
+ git for-each-ref --perl --format="%(refname)" |
+ test_cmp expect -
'
test_expect_success 'Quoting style: python' '
- git for-each-ref --python --format="%(refname)" >actual &&
- test_cmp expected actual
+ git for-each-ref --python --format="%(refname)" |
+ test_cmp expect -
'
-cat >expected <<\EOF
-"refs/heads/master"
-"refs/remotes/origin/master"
-"refs/tags/testtag"
-EOF
-
test_expect_success 'Quoting style: tcl' '
- git for-each-ref --tcl --format="%(refname)" >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ "refs/heads/master"
+ "refs/remotes/origin/master"
+ "refs/tags/testtag"
+ EOF
+ git for-each-ref --tcl --format="%(refname)" |
+ test_cmp expect -
'
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
- test_expect_success "more than one quoting style: $i" "
- git for-each-ref $i 2>&1 | (read line &&
- case \$line in
- \"error: more than one quoting style\"*) : happy;;
- *) false
- esac)
- "
-done
-
-cat >expected <<\EOF
-master
-testtag
-EOF
-
+test_expect_success 'more than one quoting styles' '
+ cat >expect <<-EOF
+ error: more than one quoting style?
+ EOF
+ git for-each-ref --perl --shell 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref -s --python 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref --python --tcl 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref --tcl --perl 2>&1 | head -n 1 |
+ test_cmp expect -
+'
test_expect_success 'Check short refname format' '
- (git for-each-ref --format="%(refname:short)" refs/heads &&
- git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ master
+ testtag
+ EOF
+ git for-each-ref --format="%(refname:short)" refs/heads refs/tags |
+ test_cmp expect -
'
-cat >expected <<EOF
-origin/master
-EOF
-
test_expect_success 'Check short upstream format' '
- git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ origin/master
+ EOF
+ git for-each-ref --format="%(upstream:short)" refs/heads |
+ test_cmp expect -
'
-cat >expected <<EOF
-67a36f1
-EOF
-
test_expect_success 'Check short objectname format' '
- git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
- test_cmp expected actual
+ cat >expect <<-EOF
+ 67a36f1
+ EOF
+ git for-each-ref --format="%(objectname:short)" refs/heads |
+ test_cmp expect -
'
test_expect_success 'Check for invalid refname format' '
- test_must_fail git for-each-ref --format="%(refname:INVALID)"
+ silent test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
-cat >expected <<\EOF
-heads/master
-tags/master
-EOF
-
test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ cat >expect <<-EOF
+ heads/master
+ tags/master
+ EOF
git config --bool core.warnambiguousrefs true &&
- git checkout -b newtag &&
+ git checkout -q -b newtag &&
echo "Using $datestamp" > one &&
git add one &&
- git commit -m "Branch" &&
+ git commit -q -m "Branch" &&
setdate_and_increment &&
- git tag -m "Tagging at $datestamp" master &&
- git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
- test_cmp expected actual
+ quiet git tag -m "Tagging at $datestamp" master &&
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/master refs/tags/master |
+ test_cmp expect -
'
-cat >expected <<\EOF
-heads/master
-master
-EOF
-
test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ cat >expect <<-EOF
+ heads/master
+ master
+ EOF
git config --bool core.warnambiguousrefs false &&
- git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
- test_cmp expected actual
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/master refs/tags/master |
+ test_cmp expect -
'
-cat >expected <<\EOF
-heads/ambiguous
-ambiguous
-EOF
-
test_expect_success 'Check ambiguous head and tag refs II (loose)' '
- git checkout master &&
+ cat >expect <<-EOF
+ heads/ambiguous
+ ambiguous
+ EOF
+ git checkout -q master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&
- git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual &&
- test_cmp expected actual
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/ambiguous refs/tags/ambiguous |
+ test_cmp expect -
'
test_expect_success 'an unusual tag with an incomplete line' '
-
git tag -m "bogo" bogo &&
bogo=$(git cat-file tag bogo) &&
bogo=$(printf "%s" "$bogo" | git mktag) &&
git tag -f bogo "$bogo" &&
git for-each-ref --format "%(body)" refs/tags/bogo
-
'
test_expect_success 'create tag with subject and body content' '
- cat >>msg <<-\EOF &&
+ cat >msg <<-\EOF &&
the subject line
first body line
@@ -395,8 +412,9 @@ test_expect_success 'create tag with multiline subject' '
first body line
second body line
EOF
- git tag -F msg multiline
+ quiet git tag -F msg multiline
'
+
test_atom refs/tags/multiline subject 'first subject line second subject line'
test_atom refs/tags/multiline contents:subject 'first subject line second subject line'
test_atom refs/tags/multiline body 'first body line
@@ -417,9 +435,9 @@ test_expect_success GPG 'create signed tags' '
git tag -s -m "" signed-empty &&
git tag -s -m "subject line" signed-short &&
cat >msg <<-\EOF &&
- subject line
+ subject line
- body contents
+ body contents
EOF
git tag -s -F msg signed-long
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* Re: [PATCH 1/5] t6300 (for-each-ref): modernize style
2012-03-01 1:45 ` [PATCH 1/5] " Tom Grennan
@ 2012-03-01 6:53 ` Johannes Sixt
2012-03-01 15:58 ` Tom Grennan
0 siblings, 1 reply; 83+ messages in thread
From: Johannes Sixt @ 2012-03-01 6:53 UTC (permalink / raw)
To: Tom Grennan
Cc: Junio C Hamano, git, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Amos Waterland, Johannes Schindelin
Am 3/1/2012 2:45, schrieb Tom Grennan:
> + git for-each-ref --format="%(refname)" --sort=refname |
> + test_cmp expect -
DON'T DO THIS. It loses the exit code of the git invocation.
(And it is contrary to my effort to move all test_cmp away from being used
in a pipeline because I want to use a comparator tool that does not
understand '-' as stdin.)
-- Hannes
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH 1/5] t6300 (for-each-ref): modernize style
2012-03-01 6:53 ` Johannes Sixt
@ 2012-03-01 15:58 ` Tom Grennan
0 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 15:58 UTC (permalink / raw)
To: Johannes Sixt
Cc: Junio C Hamano, git, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Amos Waterland, Johannes Schindelin
On Thu, Mar 01, 2012 at 07:53:11AM +0100, Johannes Sixt wrote:
>Am 3/1/2012 2:45, schrieb Tom Grennan:
>> + git for-each-ref --format="%(refname)" --sort=refname |
>> + test_cmp expect -
>
>DON'T DO THIS. It loses the exit code of the git invocation.
>
>(And it is contrary to my effort to move all test_cmp away from being used
>in a pipeline because I want to use a comparator tool that does not
>understand '-' as stdin.)
OK, with bash, one could get that from PIPESTATUS, but that doesn't help if
you're not using bash or desire a different comparator.
Thanks,
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCH 2/5] t5512 (ls-remote): modernize style
2012-02-23 0:22 ` Tom Grennan
` (2 preceding siblings ...)
2012-03-01 1:45 ` [PATCH 1/5] " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 8:36 ` Thomas Rast
2012-03-01 1:45 ` [PATCH 3/5] t3200 (branch): " Tom Grennan
` (7 subsequent siblings)
11 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t5512-ls-remote.sh | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 5c546c9..bbe650f 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -2,14 +2,22 @@
test_description='git ls-remote'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+
test_expect_success setup '
>file &&
git add file &&
test_tick &&
- git commit -m initial &&
+ git commit -q -m initial &&
git tag mark &&
git show-ref --tags -d | sed -e "s/ / /" >expected.tag &&
(
@@ -51,7 +59,7 @@ test_expect_success 'ls-remote self' '
test_expect_success 'dies when no remote specified and no default remotes found' '
- test_must_fail git ls-remote
+ silent test_must_fail git ls-remote
'
@@ -70,8 +78,8 @@ test_expect_success 'use "origin" when no remote specified' '
test_expect_success 'suppress "From <url>" with -q' '
- git ls-remote -q 2>actual_err &&
- test_must_fail test_cmp exp_err actual_err
+ quiet git ls-remote -q 2>actual_err &&
+ test_must_fail cmp -s exp_err actual_err
'
@@ -83,7 +91,7 @@ test_expect_success 'use branch.<name>.remote if possible' '
#
# setup a new remote to differentiate from "origin"
- git clone . other.git &&
+ git clone -q . other.git &&
(
cd other.git &&
echo "$(git rev-parse HEAD) HEAD"
@@ -102,11 +110,13 @@ test_expect_success 'use branch.<name>.remote if possible' '
'
-cat >exp <<EOF
-fatal: 'refs*master' does not appear to be a git repository
-fatal: The remote end hung up unexpectedly
-EOF
test_expect_success 'confuses pattern as remote when no remote specified' '
+ '"
+ cat >exp <<-EOF
+ fatal: 'refs*master' does not appear to be a git repository
+ fatal: The remote end hung up unexpectedly
+ EOF
+ "'
#
# Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly,
# confuses <pattern> for <remote>. Although ugly, this behaviour is akin
@@ -124,7 +134,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' '
'
test_expect_success 'die with non-2 for wrong repository even with --exit-code' '
- git ls-remote --exit-code ./no-such-repository ;# not &&
+ silent git ls-remote --exit-code ./no-such-repository ;# not &&
status=$? &&
test $status != 2 && test $status != 0
'
@@ -136,7 +146,8 @@ test_expect_success 'Report success even when nothing matches' '
'
test_expect_success 'Report no-match with --exit-code' '
- test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual &&
+ test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" \
+ >actual &&
>expect &&
test_cmp expect actual
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* Re: [PATCH 2/5] t5512 (ls-remote): modernize style
2012-03-01 1:45 ` [PATCH 2/5] t5512 (ls-remote): " Tom Grennan
@ 2012-03-01 8:36 ` Thomas Rast
0 siblings, 0 replies; 83+ messages in thread
From: Thomas Rast @ 2012-03-01 8:36 UTC (permalink / raw)
To: Tom Grennan
Cc: Junio C Hamano, git, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Amos Waterland, Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
> - Redirect unwanted output
[...]
> - git commit -m initial &&
> + git commit -q -m initial &&
Why? When are you seeing the output, except with --verbose? In the
latter case, isn't it useful to have as much output as possible?
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCH 3/5] t3200 (branch): modernize style
2012-02-23 0:22 ` Tom Grennan
` (3 preceding siblings ...)
2012-03-01 1:45 ` [PATCH 2/5] t5512 (ls-remote): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH 4/5] t0040 (parse-options): " Tom Grennan
` (6 subsequent siblings)
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
- Use a "here" filter for expect generation
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t3200-branch.sh | 593 +++++++++++++++++++++++++++--------------------------
1 files changed, 304 insertions(+), 289 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index dd1aceb..93c35cd 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -5,125 +5,132 @@
test_description='git branch assorted tests'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
- git update-index --add A &&
- git commit -m "Initial commit." &&
- echo World >> A &&
- git update-index --add A &&
- git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+here () { sed 's/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g' $@; }
+
+test_expect_success 'prepare a trivial repository' '
+ echo Hello >A &&
+ git update-index --add A &&
+ git commit -q -m "Initial commit." &&
+ echo World >>A &&
+ git update-index --add A &&
+ git commit -q -m "Second commit." &&
+ HEAD=$(git rev-parse --verify HEAD)
+'
-test_expect_success \
- 'git branch --help should not have created a bogus branch' '
- test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
- test_path_is_missing .git/refs/heads/--help
+test_expect_success 'git branch --help should not have created a bogus branch' '
+ silent test_might_fail git branch --help </dev/null &&
+ test_path_is_missing .git/refs/heads/--help
'
test_expect_success 'branch -h in broken repository' '
- mkdir broken &&
- (
- cd broken &&
- git init &&
- >.git/refs/heads/master &&
- test_expect_code 129 git branch -h >usage 2>&1
- ) &&
- grep "[Uu]sage" broken/usage
-'
-
-test_expect_success \
- 'git branch abc should create a branch' \
- 'git branch abc && test_path_is_file .git/refs/heads/abc'
-
-test_expect_success \
- 'git branch a/b/c should create a branch' \
- 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
-
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
-EOF
-test_expect_success \
- 'git branch -l d/e/f should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git branch -l d/e/f &&
- test_path_is_file .git/refs/heads/d/e/f &&
- test_path_is_file .git/logs/refs/heads/d/e/f &&
- test_cmp expect .git/logs/refs/heads/d/e/f'
-
-test_expect_success \
- 'git branch -d d/e/f should delete a branch and a log' \
- 'git branch -d d/e/f &&
- test_path_is_missing .git/refs/heads/d/e/f &&
- test_path_is_missing .git/logs/refs/heads/d/e/f'
-
-test_expect_success \
- 'git branch j/k should work after branch j has been deleted' \
- 'git branch j &&
- git branch -d j &&
- git branch j/k'
-
-test_expect_success \
- 'git branch l should work after branch l/m has been deleted' \
- 'git branch l/m &&
- git branch -d l/m &&
- git branch l'
-
-test_expect_success \
- 'git branch -m dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- grep "[Uu]sage: git branch" err'
-
-test_expect_success \
- 'git branch -m m m/m should work' \
- 'git branch -l m &&
- git branch -m m m/m &&
- test_path_is_file .git/logs/refs/heads/m/m'
-
-test_expect_success \
- 'git branch -m n/n n should work' \
- 'git branch -l n/n &&
+ git init -q broken &&
+ test_when_finished rm -rf broken usage &&
+ >broken/.git/refs/heads/master &&
+ >usage 2>&1 test_expect_code 129 git --git-dir=broken/.git branch -h &&
+ grep -q "[Uu]sage" usage
+'
+
+test_expect_success 'git branch abc should create a branch' '
+ git branch abc && test_path_is_file .git/refs/heads/abc
+'
+
+test_expect_success 'git branch a/b/c should create a branch' '
+ git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
+'
+
+test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+ id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+ date="1117150200 +0000"
+ msg="branch: Created from master"
+ here >expect <<-EOF
+ $_z40 $HEAD $id $date\t$msg
+ EOF
+ GIT_COMMITTER_DATE="2005-05-26 23:30" git branch -l d/e/f &&
+ test_path_is_file .git/refs/heads/d/e/f &&
+ test_path_is_file .git/logs/refs/heads/d/e/f &&
+ test_cmp expect .git/logs/refs/heads/d/e/f
+'
+
+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
+ quiet git branch -d d/e/f &&
+ test_path_is_missing .git/refs/heads/d/e/f &&
+ test_path_is_missing .git/logs/refs/heads/d/e/f
+'
+
+test_expect_success 'git branch j/k should work after branch j has been deleted' '
+ git branch j &&
+ quiet git branch -d j &&
+ git branch j/k
+'
+
+test_expect_success 'git branch l should work after branch l/m has been deleted' '
+ git branch l/m &&
+ quiet git branch -d l/m &&
+ git branch l
+'
+
+test_expect_success 'git branch -m dumps usage' '
+ test_expect_code 129 git branch -m 2>err &&
+ grep -q "[Uu]sage: git branch" err
+'
+
+test_expect_success 'git branch -m m m/m should work' '
+ git branch -l m &&
+ git branch -m m m/m &&
+ test_path_is_file .git/logs/refs/heads/m/m
+'
+
+test_expect_success 'git branch -m n/n n should work' '
+ git branch -l n/n &&
git branch -m n/n n &&
- test_path_is_file .git/logs/refs/heads/n'
+ test_path_is_file .git/logs/refs/heads/n
+'
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
git branch o/o &&
- git branch o/p &&
- test_must_fail git branch -m o/o o
+ git branch o/p &&
+ silent test_must_fail git branch -m o/o o
'
test_expect_success 'git branch -m q r/q should fail when r exists' '
git branch q &&
git branch r &&
- test_must_fail git branch -m q r/q
+ silent test_must_fail git branch -m q r/q
'
test_expect_success 'git branch -M foo bar should fail when bar is checked out' '
git branch bar &&
- git checkout -b foo &&
- test_must_fail git branch -M bar foo
+ git checkout -q -b foo &&
+ silent test_must_fail git branch -M bar foo
'
test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '
- git checkout -b baz &&
+ git checkout -q -b baz &&
git branch bam &&
git branch -M baz bam
'
test_expect_success 'git branch -M master should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch -M master
'
test_expect_success 'git branch -M master master should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch -M master master
'
test_expect_success 'git branch -M master2 master2 should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch master2 &&
git branch -M master2 master2
'
@@ -131,7 +138,7 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch
test_expect_success 'git branch -v -d t should work' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- git branch -v -d t &&
+ quiet git branch -v -d t &&
test_path_is_missing .git/refs/heads/t
'
@@ -141,188 +148,198 @@ test_expect_success 'git branch -v -m t s should work' '
git branch -v -m t s &&
test_path_is_missing .git/refs/heads/t &&
test_path_is_file .git/refs/heads/s &&
- git branch -d s
+ quiet git branch -d s
'
test_expect_success 'git branch -m -d t s should fail' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- test_must_fail git branch -m -d t s &&
- git branch -d t &&
+ silent test_must_fail git branch -m -d t s &&
+ quiet git branch -d t &&
test_path_is_missing .git/refs/heads/t
'
test_expect_success 'git branch --list -d t should fail' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- test_must_fail git branch --list -d t &&
- git branch -d t &&
+ silent test_must_fail git branch --list -d t &&
+ quiet git branch -d t &&
test_path_is_missing .git/refs/heads/t
'
-mv .git/config .git/config-saved
-
test_expect_success 'git branch -m q q2 without config should succeed' '
+ mv .git/config .git/config-saved &&
+ test_when_finished mv .git/config-saved .git/config &&
git branch -m q q2 &&
git branch -m q2 q
'
-mv .git/config-saved .git/config
-
-git config branch.s/s.dummy Hello
-
-test_expect_success \
- 'git branch -m s/s s should work when s/t is deleted' \
- 'git branch -l s/s &&
+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
+ git config branch.s/s.dummy Hello
+ git branch -l s/s &&
test_path_is_file .git/logs/refs/heads/s/s &&
- git branch -l s/t &&
+ git branch -l s/t &&
test_path_is_file .git/logs/refs/heads/s/t &&
- git branch -d s/t &&
- git branch -m s/s s &&
- test_path_is_file .git/logs/refs/heads/s'
-
-test_expect_success 'config information was renamed, too' \
- "test $(git config branch.s.dummy) = Hello &&
- test_must_fail git config branch.s/s/dummy"
+ quiet git branch -d s/t &&
+ git branch -m s/s s &&
+ test_path_is_file .git/logs/refs/heads/s
+'
-test_expect_success 'renaming a symref is not allowed' \
+test_expect_success 'config information was renamed, too' '
+ test $(git config branch.s.dummy) = Hello &&
+ silent test_must_fail git config branch.s/s/dummy
'
+
+test_expect_success 'renaming a symref is not allowed' '
git symbolic-ref refs/heads/master2 refs/heads/master &&
- test_must_fail git branch -m master2 master3 &&
- git symbolic-ref refs/heads/master2 &&
+ silent test_must_fail git branch -m master2 master3 &&
+ quiet git symbolic-ref refs/heads/master2 &&
test_path_is_file .git/refs/heads/master &&
test_path_is_missing .git/refs/heads/master3
'
-test_expect_success SYMLINKS \
- 'git branch -m u v should fail when the reflog for u is a symlink' '
- git branch -l u &&
- mv .git/logs/refs/heads/u real-u &&
- ln -s real-u .git/logs/refs/heads/u &&
- test_must_fail git branch -m u v
-'
-
-test_expect_success 'test tracking setup via --track' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my1 local/master &&
- test $(git config branch.my1.remote) = local &&
- test $(git config branch.my1.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my4 local/master &&
- test $(git config branch.my4.remote) = local &&
- test $(git config branch.my4.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, not matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my5 local/master &&
- ! test "$(git config branch.my5.remote)" = local &&
- ! test "$(git config branch.my5.merge)" = refs/heads/master'
-
-test_expect_success 'test tracking setup via config' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch my3 local/master &&
- test $(git config branch.my3.remote) = local &&
- test $(git config branch.my3.merge) = refs/heads/master'
-
-test_expect_success 'test overriding tracking setup via --no-track' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track my2 local/master &&
- git config branch.autosetupmerge false &&
- ! test "$(git config branch.my2.remote)" = local &&
- ! test "$(git config branch.my2.merge)" = refs/heads/master'
-
-test_expect_success 'no tracking without .fetch entries' \
- 'git config branch.autosetupmerge true &&
- git branch my6 s &&
- git config branch.automsetupmerge false &&
- test -z "$(git config branch.my6.remote)" &&
- test -z "$(git config branch.my6.merge)"'
-
-test_expect_success 'test tracking setup via --track but deeper' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
- git branch --track my7 local/o/o &&
- test "$(git config branch.my7.remote)" = local &&
- test "$(git config branch.my7.merge)" = refs/heads/o/o'
-
-test_expect_success 'test deleting branch deletes branch config' \
- 'git branch -d my7 &&
- test -z "$(git config branch.my7.remote)" &&
- test -z "$(git config branch.my7.merge)"'
-
-test_expect_success 'test deleting branch without config' \
- 'git branch my7 s &&
- sha1=$(git rev-parse my7 | cut -c 1-7) &&
- echo "Deleted branch my7 (was $sha1)." >expect &&
- git branch -d my7 >actual 2>&1 &&
- test_i18ncmp expect actual'
-
-test_expect_success 'test --track without .fetch entries' \
- 'git branch --track my8 &&
- test "$(git config branch.my8.remote)" &&
- test "$(git config branch.my8.merge)"'
-
-test_expect_success \
- 'branch from non-branch HEAD w/autosetupmerge=always' \
- 'git config branch.autosetupmerge always &&
- git branch my9 HEAD^ &&
- git config branch.autosetupmerge false'
-
-test_expect_success \
- 'branch from non-branch HEAD w/--track causes failure' \
- 'test_must_fail git branch --track my10 HEAD^'
-
-test_expect_success \
- 'branch from tag w/--track causes failure' \
- 'git tag foobar &&
- test_must_fail git branch --track my11 foobar'
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
+ git branch -l u &&
+ mv .git/logs/refs/heads/u real-u &&
+ ln -s real-u .git/logs/refs/heads/u &&
+ silent test_must_fail git branch -m u v
+'
+
+test_expect_success 'test tracking setup via --track' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track my1 local/master &&
+ test $(git config branch.my1.remote) = local &&
+ test $(git config branch.my1.merge) = refs/heads/master
+'
+
+test_expect_success 'test tracking setup (non-wildcard, matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch \
+ refs/heads/master:refs/remotes/local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ quiet git branch --track my4 local/master &&
+ test $(git config branch.my4.remote) = local &&
+ test $(git config branch.my4.merge) = refs/heads/master
+'
+
+test_expect_success 'test tracking setup (non-wildcard, not matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ quiet git branch --track my5 local/master &&
+ ! test "$(git config branch.my5.remote)" = local &&
+ ! test "$(git config branch.my5.merge)" = refs/heads/master
+'
+
+test_expect_success 'test tracking setup via config' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ quiet git branch my3 local/master &&
+ test $(git config branch.my3.remote) = local &&
+ test $(git config branch.my3.merge) = refs/heads/master
+'
+
+test_expect_success 'test overriding tracking setup via --no-track' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --no-track my2 local/master &&
+ git config branch.autosetupmerge false &&
+ ! test "$(git config branch.my2.remote)" = local &&
+ ! test "$(git config branch.my2.merge)" = refs/heads/master
+'
+
+test_expect_success 'no tracking without .fetch entries' '
+ git config branch.autosetupmerge true &&
+ git branch my6 s &&
+ git config branch.automsetupmerge false &&
+ test -z "$(git config branch.my6.remote)" &&
+ test -z "$(git config branch.my6.merge)"
+'
+
+test_expect_success 'test tracking setup via --track but deeper' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
+ quiet git branch --track my7 local/o/o &&
+ test "$(git config branch.my7.remote)" = local &&
+ test "$(git config branch.my7.merge)" = refs/heads/o/o
+'
+
+test_expect_success 'test deleting branch deletes branch config' '
+ quiet git branch -d my7 &&
+ test -z "$(git config branch.my7.remote)" &&
+ test -z "$(git config branch.my7.merge)"
+'
+
+test_expect_success 'test deleting branch without config' '
+ git branch my7 s &&
+ sha1=$(git rev-parse my7 | cut -c 1-7) &&
+ echo "Deleted branch my7 (was $sha1)." >expect &&
+ git branch -d my7 >actual 2>&1 &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'test --track without .fetch entries' '
+ quiet git branch --track my8 &&
+ test "$(git config branch.my8.remote)" &&
+ test "$(git config branch.my8.merge)"
+'
+
+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
+ git config branch.autosetupmerge always &&
+ git branch my9 HEAD^ &&
+ git config branch.autosetupmerge false
+'
+
+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
+ silent test_must_fail git branch --track my10 HEAD^
+'
+
+test_expect_success 'branch from tag w/--track causes failure' '
+ git tag foobar &&
+ silent test_must_fail git branch --track my11 foobar
+'
# Keep this test last, as it changes the current branch
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
-EOF
-test_expect_success \
- 'git checkout -b g/h/i -l should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git checkout -b g/h/i -l master &&
- test_path_is_file .git/refs/heads/g/h/i &&
- test_path_is_file .git/logs/refs/heads/g/h/i &&
- test_cmp expect .git/logs/refs/heads/g/h/i'
+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
+ id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+ date="1117150200 +0000"
+ msg="branch: Created from master"
+ here >expect <<-EOF
+ $_z40 $HEAD $id $date\t$msg
+ EOF
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git checkout -q -b g/h/i -l master &&
+ test_path_is_file .git/refs/heads/g/h/i &&
+ test_path_is_file .git/logs/refs/heads/g/h/i &&
+ test_cmp expect .git/logs/refs/heads/g/h/i
+'
test_expect_success 'checkout -b makes reflog by default' '
- git checkout master &&
+ git checkout -q master &&
git config --unset core.logAllRefUpdates &&
- git checkout -b alpha &&
- git rev-parse --verify alpha@{0}
+ git checkout -q -b alpha &&
+ quiet git rev-parse --verify alpha@{0}
'
test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
- git checkout master &&
+ git checkout -q master &&
git config core.logAllRefUpdates false &&
- git checkout -b beta &&
- test_must_fail git rev-parse --verify beta@{0}
+ git checkout -q -b beta &&
+ silent test_must_fail git rev-parse --verify beta@{0}
'
test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
- git checkout master &&
- git checkout -lb gamma &&
+ git checkout -q master &&
+ git checkout -q -lb gamma &&
git config --unset core.logAllRefUpdates &&
- git rev-parse --verify gamma@{0}
+ quiet git rev-parse --verify gamma@{0}
'
test_expect_success 'avoid ambiguous track' '
@@ -331,7 +348,7 @@ test_expect_success 'avoid ambiguous track' '
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
git config remote.ambi2.url lilili &&
git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
- git branch all1 master &&
+ silent git branch all1 master &&
test -z "$(git config branch.all1.merge)"
'
@@ -339,9 +356,9 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase local &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase &&
- git branch --track myr1 mybase &&
+ quiet git branch --track myr1 mybase &&
test "$(git config branch.myr1.remote)" = . &&
test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
test "$(git config branch.myr1.rebase)" = true
@@ -351,9 +368,9 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase always &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase2 &&
- git branch --track myr2 mybase &&
+ quiet git branch --track myr2 mybase &&
test "$(git config branch.myr2.remote)" = . &&
test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
test "$(git config branch.myr2.rebase)" = true
@@ -363,9 +380,9 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase3 &&
- git branch --track myr3 mybase2 &&
+ quiet git branch --track myr3 mybase2 &&
test "$(git config branch.myr3.remote)" = . &&
test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
! test "$(git config branch.myr3.rebase)" = true
@@ -375,9 +392,9 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase never &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase4 &&
- git branch --track myr4 mybase2 &&
+ quiet git branch --track myr4 mybase2 &&
test "$(git config branch.myr4.remote)" = . &&
test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
! test "$(git config branch.myr4.rebase)" = true
@@ -387,8 +404,8 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase local &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr5 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr5 local/master &&
test "$(git config branch.myr5.remote)" = local &&
test "$(git config branch.myr5.merge)" = refs/heads/master &&
! test "$(git config branch.myr5.rebase)" = true
@@ -398,8 +415,8 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase never &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr6 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr6 local/master &&
test "$(git config branch.myr6.remote)" = local &&
test "$(git config branch.myr6.merge)" = refs/heads/master &&
! test "$(git config branch.myr6.rebase)" = true
@@ -409,8 +426,8 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr7 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr7 local/master &&
test "$(git config branch.myr7.remote)" = local &&
test "$(git config branch.myr7.merge)" = refs/heads/master &&
test "$(git config branch.myr7.rebase)" = true
@@ -420,8 +437,8 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr8 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr8 local/master &&
test "$(git config branch.myr8.remote)" = local &&
test "$(git config branch.myr8.merge)" = refs/heads/master &&
test "$(git config branch.myr8.rebase)" = true
@@ -431,8 +448,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
git config --unset branch.autosetuprebase &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr9 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr9 local/master &&
test "$(git config branch.myr9.remote)" = local &&
test "$(git config branch.myr9.merge)" = refs/heads/master &&
test "z$(git config branch.myr9.rebase)" = z
@@ -441,9 +458,9 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase10 &&
- git branch --track myr10 mybase2 &&
+ quiet git branch --track myr10 mybase2 &&
test "$(git config branch.myr10.remote)" = . &&
test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
test "z$(git config branch.myr10.rebase)" = z
@@ -452,8 +469,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr11 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr11 mybase2 &&
test "z$(git config branch.myr11.remote)" = z &&
test "z$(git config branch.myr11.merge)" = z &&
test "z$(git config branch.myr11.rebase)" = z
@@ -462,8 +479,8 @@ test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr12 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr12 local/master &&
test "z$(git config branch.myr12.remote)" = z &&
test "z$(git config branch.myr12.merge)" = z &&
test "z$(git config branch.myr12.rebase)" = z
@@ -473,8 +490,8 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '
git config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr13 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr13 mybase2 &&
test "z$(git config branch.myr13.remote)" = z &&
test "z$(git config branch.myr13.merge)" = z &&
test "z$(git config branch.myr13.rebase)" = z
@@ -484,8 +501,8 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '
git config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr14 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr14 mybase2 &&
test "z$(git config branch.myr14.remote)" = z &&
test "z$(git config branch.myr14.merge)" = z &&
test "z$(git config branch.myr14.rebase)" = z
@@ -495,8 +512,8 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '
git config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr15 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr15 mybase2 &&
test "z$(git config branch.myr15.remote)" = z &&
test "z$(git config branch.myr15.merge)" = z &&
test "z$(git config branch.myr15.rebase)" = z
@@ -506,8 +523,8 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '
git config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr16 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr16 mybase2 &&
test "z$(git config branch.myr16.remote)" = z &&
test "z$(git config branch.myr16.merge)" = z &&
test "z$(git config branch.myr16.rebase)" = z
@@ -517,8 +534,8 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '
git config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr17 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr17 local/master &&
test "z$(git config branch.myr17.remote)" = z &&
test "z$(git config branch.myr17.merge)" = z &&
test "z$(git config branch.myr17.rebase)" = z
@@ -528,8 +545,8 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '
git config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr18 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr18 local/master &&
test "z$(git config branch.myr18.remote)" = z &&
test "z$(git config branch.myr18.merge)" = z &&
test "z$(git config branch.myr18.rebase)" = z
@@ -539,8 +556,8 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '
git config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr19 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr19 local/master &&
test "z$(git config branch.myr19.remote)" = z &&
test "z$(git config branch.myr19.merge)" = z &&
test "z$(git config branch.myr19.rebase)" = z
@@ -550,8 +567,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
git config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr20 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr20 local/master &&
test "z$(git config branch.myr20.remote)" = z &&
test "z$(git config branch.myr20.merge)" = z &&
test "z$(git config branch.myr20.rebase)" = z
@@ -559,8 +576,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
test_expect_success 'autosetuprebase always on detached HEAD' '
git config branch.autosetupmerge always &&
- test_when_finished git checkout master &&
- git checkout HEAD^0 &&
+ test_when_finished git checkout -q master &&
+ git checkout -q HEAD^0 &&
git branch my11 &&
test -z "$(git config branch.my11.remote)" &&
test -z "$(git config branch.my11.merge)"
@@ -568,20 +585,20 @@ test_expect_success 'autosetuprebase always on detached HEAD' '
test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
git config branch.autosetuprebase garbage &&
- test_must_fail git branch
+ silent test_must_fail git branch
'
test_expect_success 'detect misconfigured autosetuprebase (no value)' '
git config --unset branch.autosetuprebase &&
echo "[branch] autosetuprebase" >> .git/config &&
- test_must_fail git branch &&
+ silent test_must_fail git branch &&
git config --unset branch.autosetuprebase
'
test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
- git checkout my9 &&
+ git checkout -q my9 &&
git config --unset branch.my8.merge &&
- test_must_fail git branch -d my8
+ silent test_must_fail git branch -d my8
'
test_expect_success 'attempt to delete a branch merged to its base' '
@@ -589,32 +606,30 @@ test_expect_success 'attempt to delete a branch merged to its base' '
# we would not have allowed deleting my8 that is not merged
# to my9, but it is set to track master that already has my8
git config branch.my8.merge refs/heads/master &&
- git branch -d my8
+ silent git branch -d my8
'
test_expect_success 'attempt to delete a branch merged to its base' '
- git checkout master &&
+ git checkout -q master &&
echo Third >>A &&
- git commit -m "Third commit" A &&
- git branch -t my10 my9 &&
- git branch -f my10 HEAD^ &&
+ git commit -q -m "Third commit" A &&
+ quiet git branch -t my10 my9 &&
+ quiet git branch -f my10 HEAD^ &&
# we are on master which is at the third commit, and my10
# is behind us, so traditionally we would have allowed deleting
# it; but my10 is set to track my9 that is further behind.
- test_must_fail git branch -d my10
+ silent test_must_fail git branch -d my10
'
test_expect_success 'use set-upstream on the current branch' '
- git checkout master &&
- git --bare init myupstream.git &&
- git push myupstream.git master:refs/heads/frotz &&
+ git checkout -q master &&
+ git --bare init -q myupstream.git &&
+ git push -q myupstream.git master:refs/heads/frotz &&
git remote add origin myupstream.git &&
- git fetch &&
- git branch --set-upstream master origin/frotz &&
-
+ git fetch -q &&
+ quiet git branch --set-upstream master origin/frotz &&
test "z$(git config branch.master.remote)" = "zorigin" &&
test "z$(git config branch.master.merge)" = "zrefs/heads/frotz"
-
'
test_expect_success 'use --edit-description' '
@@ -637,7 +652,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
(
EDITOR=./editor &&
export EDITOR &&
- test_must_fail git branch --edit-description no-such-branch
+ silent test_must_fail git branch --edit-description no-such-branch
)
'
@@ -645,11 +660,11 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
write_script editor <<-\EOF &&
echo "New contents" >"$1"
EOF
- git checkout --orphan unborn &&
+ git checkout -q --orphan unborn &&
(
EDITOR=./editor &&
export EDITOR &&
- test_must_fail git branch --edit-description
+ silent test_must_fail git branch --edit-description
)
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH 4/5] t0040 (parse-options): modernize style
2012-02-23 0:22 ` Tom Grennan
` (4 preceding siblings ...)
2012-03-01 1:45 ` [PATCH 3/5] t3200 (branch): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH 5/5] t7004 (tag): " Tom Grennan
` (5 subsequent siblings)
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t0040-parse-options.sh | 519 ++++++++++++++++++++++------------------------
1 files changed, 245 insertions(+), 274 deletions(-)
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index a1e4616..6416d77 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -5,353 +5,324 @@
test_description='our own option parser'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
-cat > expect << EOF
-usage: test-parse-options <options>
-
- -b, --boolean get a boolean
- -4, --or4 bitwise-or boolean with ...0100
- --neg-or4 same as --no-or4
-
- -i, --integer <n> get a integer
- -j <n> get a integer, too
- --set23 set integer to 23
- -t <time> get timestamp of <time>
- -L, --length <str> get length of <str>
- -F, --file <file> set file to <file>
-
-String options
- -s, --string <string>
- get a string
- --string2 <str> get another string
- --st <st> get another string (pervert ordering)
- -o <str> get another string
- --default-string set string to default
- --list <str> add str to list
-
-Magic arguments
- --quux means --quux
- -NUM set integer to NUM
- + same as -b
- --ambiguous positive ambiguity
- --no-ambiguous negative ambiguity
-
-Standard options
- --abbrev[=<n>] use <n> digits to display SHA-1s
- -v, --verbose be verbose
- -n, --dry-run dry run
- -q, --quiet be quiet
-
-EOF
+silent () { "$@" >/dev/null 2>&1; }
test_expect_success 'test help' '
- test_must_fail test-parse-options -h > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ sed -e "s/^|//" >expect <<-\EOF &&
+ |usage: test-parse-options <options>
+
+ | -b, --boolean get a boolean
+ | -4, --or4 bitwise-or boolean with ...0100
+ | --neg-or4 same as --no-or4
+
+ | -i, --integer <n> get a integer
+ | -j <n> get a integer, too
+ | --set23 set integer to 23
+ | -t <time> get timestamp of <time>
+ | -L, --length <str> get length of <str>
+ | -F, --file <file> set file to <file>
+
+ |String options
+ | -s, --string <string>
+ | get a string
+ | --string2 <str> get another string
+ | --st <st> get another string (pervert ordering)
+ | -o <str> get another string
+ | --default-string set string to default
+ | --list <str> add str to list
+
+ |Magic arguments
+ | --quux means --quux
+ | -NUM set integer to NUM
+ | + same as -b
+ | --ambiguous positive ambiguity
+ | --no-ambiguous negative ambiguity
+
+ |Standard options
+ | --abbrev[=<n>] use <n> digits to display SHA-1s
+ | -v, --verbose be verbose
+ | -n, --dry-run dry run
+ | -q, --quiet be quiet
+
+ EOF
+ cp expect expect.err
+ test_must_fail test-parse-options -h 2>err | test_cmp expect - &&
+ test ! -s err
'
-mv expect expect.err
-
-cat > expect << EOF
-boolean: 2
-integer: 1729
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 2
-quiet: no
-dry run: yes
-file: prefix/my.file
-EOF
-
test_expect_success 'short options' '
- test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \
- > output 2> output.err &&
- test_cmp expect output &&
- test ! -s output.err
+ cat >expect <<-\EOF &&
+ boolean: 2
+ integer: 1729
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 2
+ quiet: no
+ dry run: yes
+ file: prefix/my.file
+ EOF
+ test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file 2>err |
+ test_cmp expect - &&
+ test ! -s err
'
-cat > expect << EOF
-boolean: 2
-integer: 1729
-timestamp: 0
-string: 321
-abbrev: 10
-verbose: 2
-quiet: no
-dry run: no
-file: prefix/fi.le
-EOF
-
test_expect_success 'long options' '
+ cat >expect <<-\EOF &&
+ boolean: 2
+ integer: 1729
+ timestamp: 0
+ string: 321
+ abbrev: 10
+ verbose: 2
+ quiet: no
+ dry run: no
+ file: prefix/fi.le
+ EOF
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
- --verbose --verbose --no-dry-run --abbrev=10 --file fi.le\
- --obsolete > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ --verbose --verbose --no-dry-run --abbrev=10 --file fi.le \
+ --obsolete 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'missing required value' '
- test-parse-options -s;
- test $? = 129 &&
- test-parse-options --string;
- test $? = 129 &&
- test-parse-options --file;
- test $? = 129
+ silent test_expect_code 129 test-parse-options -s &&
+ silent test_expect_code 129 test-parse-options --string &&
+ silent test_expect_code 129 test-parse-options --file
'
-cat > expect << EOF
-boolean: 1
-integer: 13
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-arg 00: a1
-arg 01: b1
-arg 02: --boolean
-EOF
-
test_expect_success 'intermingled arguments' '
+ cat >expect <<-\EOF &&
+ boolean: 1
+ integer: 13
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ arg 00: a1
+ arg 01: b1
+ arg 02: --boolean
+ EOF
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
- > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect << EOF
-boolean: 0
-integer: 2
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'unambiguously abbreviated option' '
- test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 2
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --int 2 --boolean --no-bo 2>err |
+ test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'unambiguously abbreviated option with "="' '
- test-parse-options --int=2 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --int=2 2>err | test_cmp expect -&&
+ test ! -s err
'
test_expect_success 'ambiguously abbreviated option' '
- test-parse-options --strin 123;
- test $? = 129
+ silent test_expect_code 129 test-parse-options --strin 123
'
-cat > expect << EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: 123
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
- test-parse-options --st 123 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: 123
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --st 123 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > typo.err << EOF
-error: did you mean \`--boolean\` (with two dashes ?)
-EOF
-
test_expect_success 'detect possible typos' '
- test_must_fail test-parse-options -boolean > output 2> output.err &&
- test ! -s output &&
- test_cmp typo.err output.err
+ cat >typo.err <<-\EOF &&
+ error: did you mean `--boolean` (with two dashes ?)
+ EOF
+ >expect
+ test_must_fail test-parse-options -boolean 2>err | test_cmp expect - &&
+ test_cmp typo.err err
'
-cat > expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-arg 00: --quux
-EOF
-
test_expect_success 'keep some options as arguments' '
- test-parse-options --quux > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ arg 00: --quux
+ EOF
+ test-parse-options --quux 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 1
-string: default
-abbrev: 7
-verbose: 0
-quiet: yes
-dry run: no
-file: (not set)
-arg 00: foo
-EOF
-
test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
- foo -q > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 1
+ string: default
+ abbrev: 7
+ verbose: 0
+ quiet: yes
+ dry run: no
+ file: (not set)
+ arg 00: foo
+ EOF
+ test-parse-options -t "1970-01-01 00:00:01 +0000" \
+ --default-string foo -q 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
-Callback: "four", 0
-boolean: 5
-integer: 4
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
- test-parse-options --length=four -b -4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ Callback: "four", 0
+ boolean: 5
+ integer: 4
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --length=four -b -4 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
-Callback: "not set", 1
-EOF
-
test_expect_success 'OPT_CALLBACK() and callback errors work' '
- test_must_fail test-parse-options --no-length > output 2> output.err &&
- test_cmp expect output &&
- test_cmp expect.err output.err
+ cat >expect <<-\EOF &&
+ Callback: "not set", 1
+ EOF
+ test_must_fail test-parse-options --no-length 2>err |
+ test_cmp expect - &&
+ test_cmp expect.err err
'
-cat > expect <<EOF
-boolean: 1
-integer: 23
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 1
+ integer: 23
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --set23 -bbbbb --no-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --set23 -bbbbb --neg-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
-boolean: 6
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'OPT_BIT() works' '
- test-parse-options -bb --or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 6
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options -bb --or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_NEGBIT() works' '
- test-parse-options -bb --no-neg-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options -bb --no-neg-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '
- test-parse-options + + + + + + > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options + + + + + + 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
-boolean: 0
-integer: 12345
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
test_expect_success 'OPT_NUMBER_CALLBACK() works' '
- test-parse-options -12345 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 12345
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options -12345 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat >expect <<EOF
-boolean: 0
-integer: 0
-timestamp: 0
-string: (not set)
-abbrev: 7
-verbose: 0
-quiet: no
-dry run: no
-file: (not set)
-EOF
-
test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
- test-parse-options --no-ambig >output 2>output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ cat >expect <<-\EOF &&
+ boolean: 0
+ integer: 0
+ timestamp: 0
+ string: (not set)
+ abbrev: 7
+ verbose: 0
+ quiet: no
+ dry run: no
+ file: (not set)
+ EOF
+ test-parse-options --no-ambig 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat >>expect <<'EOF'
-list: foo
-list: bar
-list: baz
-EOF
test_expect_success '--list keeps list of strings' '
- test-parse-options --list foo --list=bar --list=baz >output &&
- test_cmp expect output
+ cat >>expect <<-\EOF &&
+ list: foo
+ list: bar
+ list: baz
+ EOF
+ test-parse-options --list foo --list=bar --list=baz | test_cmp expect -
'
test_expect_success '--no-list resets list' '
- test-parse-options --list=other --list=irrelevant --list=options \
- --no-list --list=foo --list=bar --list=baz >output &&
- test_cmp expect output
+ test-parse-options --list=other --list=irrelevant \
+ --list=options --no-list --list=foo --list=bar --list=baz |
+ test_cmp expect -
'
test_done
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH 5/5] t7004 (tag): modernize style
2012-02-23 0:22 ` Tom Grennan
` (5 preceding siblings ...)
2012-03-01 1:45 ` [PATCH 4/5] t0040 (parse-options): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH-w 101/105] t6300 (for-each-ref): " Tom Grennan
` (4 subsequent siblings)
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
- Use a "here" filter for expect generation
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t7004-tag.sh | 1680 ++++++++++++++++++++++++++------------------------------
1 files changed, 783 insertions(+), 897 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f8c247a..6704046 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -7,15 +7,37 @@ test_description='git tag
Tests for operations with tags.'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
-# creating and listing lightweight tags:
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+here () { sed 's/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g' $@; }
tag_exists () {
git show-ref --quiet --verify refs/tags/"$1"
}
+gen_header () { # name, object, type, time
+ cat <<-EOF &&
+ object $2
+ type $3
+ tag $1
+ tagger C O Mitter <committer@example.com> $4 -0700
+
+ EOF
+ here
+}
+
+get_header () {
+ git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
+}
+
# todo: git tag -l now returns always zero, when fixed, change this test
test_expect_success 'listing all tags in an empty tree should succeed' '
git tag -l &&
@@ -27,36 +49,38 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git tag | wc -l` -eq 0
'
-test_expect_success 'looking for a tag in an empty tree should fail' \
- '! (tag_exists mytag)'
+test_expect_success 'looking for a tag in an empty tree should fail' '
+ ! tag_exists mytag
+'
test_expect_success 'creating a tag in an empty tree should fail' '
- test_must_fail git tag mynotag &&
+ silent test_must_fail git tag mynotag &&
! tag_exists mynotag
'
test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
- test_must_fail git tag mytaghead HEAD &&
+ silent test_must_fail git tag mytaghead HEAD &&
! tag_exists mytaghead
'
test_expect_success 'creating a tag for an unknown revision should fail' '
- test_must_fail git tag mytagnorev aaaaaaaaaaa &&
+ silent test_must_fail git tag mytagnorev aaaaaaaaaaa &&
! tag_exists mytagnorev
'
-# commit used in the tests, test_tick is also called here to freeze the date:
test_expect_success 'creating a tag using default HEAD should succeed' '
+ # commit used in the tests
+ # test_tick is also called here to freeze the date:
test_tick &&
- echo foo >foo &&
+ echo >foo foo &&
git add foo &&
- git commit -m Foo &&
+ git commit -q -m Foo &&
git tag mytag
'
test_expect_success 'listing all tags if one exists should succeed' '
- git tag -l &&
- git tag
+ quiet git tag -l &&
+ quiet git tag
'
test_expect_success 'listing all tags if one exists should output that tag' '
@@ -66,36 +90,36 @@ test_expect_success 'listing all tags if one exists should output that tag' '
# pattern matching:
-test_expect_success 'listing a tag using a matching pattern should succeed' \
- 'git tag -l mytag'
+test_expect_success 'listing a tag using a matching pattern should succeed' '
+ quiet git tag -l mytag
+'
-test_expect_success \
- 'listing a tag using a matching pattern should output that tag' \
- 'test `git tag -l mytag` = mytag'
+test_expect_success 'listing a tag using a matching pattern should output that tag' '
+ test `git tag -l mytag` = mytag
+'
# todo: git tag -l now returns always zero, when fixed, change this test
-test_expect_success \
- 'listing tags using a non-matching pattern should suceed' \
- 'git tag -l xxx'
+test_expect_success 'listing tags using a non-matching pattern should suceed' '
+ git tag -l xxx
+'
-test_expect_success \
- 'listing tags using a non-matching pattern should output nothing' \
- 'test `git tag -l xxx | wc -l` -eq 0'
+test_expect_success 'listing tags using a non-matching pattern should output nothing' '
+ test `git tag -l xxx | wc -l` -eq 0
+'
# special cases for creating tags:
-test_expect_success \
- 'trying to create a tag with the name of one existing should fail' \
- 'test_must_fail git tag mytag'
+test_expect_success 'trying to create a tag with the name of one existing should fail' '
+ silent test_must_fail git tag mytag
+'
-test_expect_success \
- 'trying to create a tag with a non-valid name should fail' '
+test_expect_success 'trying to create a tag with a non-valid name should fail' '
test `git tag -l | wc -l` -eq 1 &&
- test_must_fail git tag "" &&
- test_must_fail git tag .othertag &&
- test_must_fail git tag "other tag" &&
- test_must_fail git tag "othertag^" &&
- test_must_fail git tag "other~tag" &&
+ silent test_must_fail git tag "" &&
+ silent test_must_fail git tag .othertag &&
+ silent test_must_fail git tag "other tag" &&
+ silent test_must_fail git tag "othertag^" &&
+ silent test_must_fail git tag "other~tag" &&
test `git tag -l | wc -l` -eq 1
'
@@ -108,62 +132,59 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
test_expect_success 'trying to delete an unknown tag should fail' '
! tag_exists unknown-tag &&
- test_must_fail git tag -d unknown-tag
+ silent test_must_fail git tag -d unknown-tag
'
-cat >expect <<EOF
-myhead
-mytag
-EOF
-test_expect_success \
- 'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && test_cmp expect actual &&
+test_expect_success 'trying to delete tags without params should succeed and do nothing' '
+ cat >expect <<-EOF &&
+ myhead
+ mytag
+ EOF
+ git tag -l | test_cmp expect - &&
git tag -d &&
- git tag -l > actual && test_cmp expect actual
+ git tag -l | test_cmp expect -
'
-test_expect_success \
- 'deleting two existing tags in one command should succeed' '
+test_expect_success 'deleting two existing tags in one command should succeed' '
tag_exists mytag &&
tag_exists myhead &&
- git tag -d mytag myhead &&
+ quiet git tag -d mytag myhead &&
! tag_exists mytag &&
! tag_exists myhead
'
-test_expect_success \
- 'creating a tag with the name of another deleted one should succeed' '
+test_expect_success 'creating a tag with the name of another deleted one should succeed' '
! tag_exists mytag &&
git tag mytag &&
tag_exists mytag
'
-test_expect_success \
- 'trying to delete two tags, existing and not, should fail in the 2nd' '
+test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' '
tag_exists mytag &&
! tag_exists myhead &&
- test_must_fail git tag -d mytag anothertag &&
+ silent test_must_fail git tag -d mytag anothertag &&
! tag_exists mytag &&
! tag_exists myhead
'
-test_expect_success 'trying to delete an already deleted tag should fail' \
- 'test_must_fail git tag -d mytag'
+test_expect_success 'trying to delete an already deleted tag should fail' '
+ silent test_must_fail git tag -d mytag
+'
# listing various tags with pattern matching:
-cat >expect <<EOF
-a1
-aa1
-cba
-t210
-t211
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
test_expect_success 'listing all tags should print them ordered' '
+ cat >expect <<-EOF &&
+ a1
+ aa1
+ cba
+ t210
+ t211
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag v1.0.1 &&
git tag t211 &&
git tag aa1 &&
@@ -173,561 +194,486 @@ test_expect_success 'listing all tags should print them ordered' '
git tag a1 &&
git tag v1.0 &&
git tag t210 &&
- git tag -l > actual &&
- test_cmp expect actual &&
- git tag > actual &&
- test_cmp expect actual
+ git tag -l | test_cmp expect - &&
+ git tag | test_cmp expect -
'
-cat >expect <<EOF
-a1
-aa1
-cba
-EOF
-test_expect_success \
- 'listing tags with substring as pattern must print those matching' '
- rm *a* &&
- git tag -l "*a*" > current &&
- test_cmp expect current
-'
-
-cat >expect <<EOF
-v0.2.1
-v1.0.1
-EOF
-test_expect_success \
- 'listing tags with a suffix as pattern must print those matching' '
- git tag -l "*.1" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags with substring as pattern must print those matching' '
+ cat >expect <<-EOF &&
+ a1
+ aa1
+ cba
+ EOF
+ git tag -l "*a*" | test_cmp expect -
'
-cat >expect <<EOF
-t210
-t211
-EOF
-test_expect_success \
- 'listing tags with a prefix as pattern must print those matching' '
- git tag -l "t21*" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags with a suffix as pattern must print those matching' '
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0.1
+ EOF
+ git tag -l "*.1" | test_cmp expect -
'
-cat >expect <<EOF
-a1
-EOF
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
- git tag -l a1 > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags with a prefix as pattern must print those matching' '
+ cat >expect <<-EOF &&
+ t210
+ t211
+ EOF
+ git tag -l "t21*" | test_cmp expect -
'
-cat >expect <<EOF
-v1.0
-EOF
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
- git tag -l v1.0 > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
+ a1
+ EOF
+ git tag -l a1 | test_cmp expect -
'
-cat >expect <<EOF
-v1.0.1
-v1.1.3
-EOF
-test_expect_success \
- 'listing tags with ? in the pattern should print those matching' '
- git tag -l "v1.?.?" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
+ v1.0
+ EOF
+ git tag -l v1.0 | test_cmp expect -
'
->expect
-test_expect_success \
- 'listing tags using v.* should print nothing because none have v.' '
- git tag -l "v.*" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags with ? in the pattern should print those matching' '
+ cat >expect <<-EOF &&
+ v1.0.1
+ v1.1.3
+ EOF
+ git tag -l "v1.?.?" | test_cmp expect -
'
-cat >expect <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
-test_expect_success \
- 'listing tags using v* should print only those having v' '
- git tag -l "v*" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags using v.* should print nothing because none have v.' '
+ >expect &&
+ git tag -l "v.*" | test_cmp expect -
+'
+
+test_expect_success 'listing tags using v* should print only those having v' '
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
+ git tag -l "v*" | test_cmp expect -
'
test_expect_success 'tag -l can accept multiple patterns' '
- git tag -l "v1*" "v0*" >actual &&
- test_cmp expect actual
+ git tag -l "v1*" "v0*" | test_cmp expect -
'
# creating and verifying lightweight tags:
-test_expect_success \
- 'a non-annotated tag created without parameters should point to HEAD' '
+test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '
git tag non-annotated-tag &&
test $(git cat-file -t non-annotated-tag) = commit &&
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_success 'trying to verify an unknown tag should fail' \
- 'test_must_fail git tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' '
+ silent test_must_fail git tag -v unknown-tag
+'
-test_expect_success \
- 'trying to verify a non-annotated and non-signed tag should fail' \
- 'test_must_fail git tag -v non-annotated-tag'
+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' '
+ silent test_must_fail git tag -v non-annotated-tag
+'
-test_expect_success \
- 'trying to verify many non-annotated or unknown tags, should fail' \
- 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' '
+ silent test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2
+'
# creating annotated tags:
-get_tag_msg () {
- git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
-}
-
-# run test_tick before committing always gives the time in that timezone
-get_tag_header () {
-cat <<EOF
-object $2
-type $3
-tag $1
-tagger C O Mitter <committer@example.com> $4 -0700
-
-EOF
-}
-
-commit=$(git rev-parse HEAD)
-time=$test_tick
-
-get_tag_header annotated-tag $commit commit $time >expect
-echo "A message" >>expect
-test_expect_success \
- 'creating an annotated tag with -m message should succeed' '
- git tag -m "A message" annotated-tag &&
- get_tag_msg annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating an annotated tag with -m message should succeed' '
+ commit=$(git rev-parse HEAD) &&
+ time=$test_tick &&
+ name="annotated-tag" &&
+ msg="A message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
+ EOF
+ git tag -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
-cat >msgfile <<EOF
-Another message
-in a file.
-EOF
-get_tag_header file-annotated-tag $commit commit $time >expect
-cat msgfile >>expect
-test_expect_success \
- 'creating an annotated tag with -F messagefile should succeed' '
- git tag -F msgfile file-annotated-tag &&
- get_tag_msg file-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating an annotated tag with -F messagefile should succeed' '
+ name="file-annotated-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ Another message
+ in a file.
+ EOF
+ tail -n 2 expect >msgfile &&
+ git tag -F msgfile $name &&
+ get_header $name | test_cmp expect -
'
-cat >inputmsg <<EOF
-A message from the
-standard input
-EOF
-get_tag_header stdin-annotated-tag $commit commit $time >expect
-cat inputmsg >>expect
test_expect_success 'creating an annotated tag with -F - should succeed' '
- git tag -F - stdin-annotated-tag <inputmsg &&
- get_tag_msg stdin-annotated-tag >actual &&
- test_cmp expect actual
+ name="stdin-annotated-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A message from the
+ standard input
+ EOF
+ tail -n 2 expect | git tag -F - $name &&
+ get_header $name | test_cmp expect -
'
-test_expect_success \
- 'trying to create a tag with a non-existing -F file should fail' '
+test_expect_success 'trying to create a tag with a non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists notag &&
- test_must_fail git tag -F nonexistingfile notag &&
+ silent test_must_fail git tag -F nonexistingfile notag &&
! tag_exists notag
'
-test_expect_success \
- 'trying to create tags giving both -m or -F options should fail' '
- echo "message file 1" >msgfile1 &&
- echo "message file 2" >msgfile2 &&
+test_expect_success 'trying to create tags giving both -m or -F options should fail' '
+ echo >msgfile1 "message file 1" &&
+ echo >msgfile2 "message file 2" &&
! tag_exists msgtag &&
- test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
+ silent test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
! tag_exists msgtag &&
- test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
+ silent test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
! tag_exists msgtag &&
- test_must_fail git tag -m "message 1" -F msgfile1 \
+ silent test_must_fail git tag -m "message 1" -F msgfile1 \
-m "message 2" msgtag &&
! tag_exists msgtag
'
# blank and empty messages:
-get_tag_header empty-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with an empty -m message should succeed' '
- git tag -m "" empty-annotated-tag &&
- get_tag_msg empty-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with an empty -m message should succeed' '
+ name="empty-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -m "" $name &&
+ get_header $name | test_cmp expect -
'
->emptyfile
-get_tag_header emptyfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with an empty -F messagefile should succeed' '
- git tag -F emptyfile emptyfile-annotated-tag &&
- get_tag_msg emptyfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with an empty -F messagefile should succeed' '
+ >emptyfile &&
+ name="emptyfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F emptyfile $name &&
+ get_header $name | test_cmp expect -
'
-printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
-printf '\n\n\nTrailing spaces \t \n' >>blanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
-get_tag_header blanks-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
+test_expect_success 'extra blanks in the message for an annotated tag should be removed' '
+ here >blanksfile <<-\EOF &&
-Repeated blank lines
+ \s\s
+ \t
+ Leading blank lines
-Trailing spaces
+ \t\s\t\s\s
+ Repeated blank lines
-Trailing blank lines
-EOF
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
- git tag -F blanksfile blanks-annotated-tag &&
- get_tag_msg blanks-annotated-tag >actual &&
- test_cmp expect actual
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ name="blanks-annotated-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ Leading blank lines
+
+ Repeated blank lines
+
+ Trailing spaces
+
+ Trailing blank lines
+ EOF
+ git tag -F blanksfile $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header blank-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with blank -m message with spaces should succeed' '
- git tag -m " " blank-annotated-tag &&
- get_tag_msg blank-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with blank -m message with spaces should succeed' '
+ name="blank-annotated-tag" &&
+ gen_header $name $commit commit $time </dev/null >expect &&
+ git tag -m " " $name &&
+ get_header $name | test_cmp expect -
'
-echo ' ' >blankfile
-echo '' >>blankfile
-echo ' ' >>blankfile
-get_tag_header blankfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with blank -F messagefile with spaces should succeed' '
- git tag -F blankfile blankfile-annotated-tag &&
- get_tag_msg blankfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' '
+ here >blankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ name="blankfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F blankfile $name &&
+ get_header $name | test_cmp expect -
'
-printf ' ' >blanknonlfile
-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with -F file of spaces and no newline should succeed' '
- git tag -F blanknonlfile blanknonlfile-annotated-tag &&
- get_tag_msg blanknonlfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' '
+ printf >blanknonlfile " " &&
+ name="blanknonlfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F blanknonlfile $name &&
+ get_header $name | test_cmp expect -
'
# messages with commented lines:
-cat >commentsfile <<EOF
-# A comment
+test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' '
+ cat >commentsfile <<-EOF &&
+ # A comment
-############
-The message.
-############
-One line.
+ ############
+ The message.
+ ############
+ One line.
-# commented lines
-# commented lines
+ # commented lines
+ # commented lines
-Another line.
-# comments
+ Another line.
+ # comments
-Last line.
-EOF
-get_tag_header comments-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
+ Last line.
+ EOF
+ name="comments-annotated-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ The message.
+ One line.
-Another line.
+ Another line.
-Last line.
-EOF
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
- git tag -F commentsfile comments-annotated-tag &&
- get_tag_msg comments-annotated-tag >actual &&
- test_cmp expect actual
+ Last line.
+ EOF
+ git tag -F commentsfile $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header comment-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with a #comment in the -m message should succeed' '
- git tag -m "#comment" comment-annotated-tag &&
- get_tag_msg comment-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with a #comment in the -m message should succeed' '
+ name="comment-annotated-tag" &&
+ gen_header $name $commit commit $time >expect </dev/null &&
+ git tag -m "#comment" $name &&
+ get_header $name | test_cmp expect -
'
-echo '#comment' >commentfile
-echo '' >>commentfile
-echo '####' >>commentfile
-get_tag_header commentfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with #comments in the -F messagefile should succeed' '
- git tag -F commentfile commentfile-annotated-tag &&
- get_tag_msg commentfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' '
+ cat >commentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ name="commentfile-annotated-tag" &&
+ gen_header $name $commit commit $time >expect </dev/null &&
+ git tag -F commentfile $name &&
+ get_header $name | test_cmp expect -
'
-printf '#comment' >commentnonlfile
-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with a file of #comment and no newline should succeed' '
- git tag -F commentnonlfile commentnonlfile-annotated-tag &&
- get_tag_msg commentnonlfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with a file of #comment and no newline should succeed' '
+ printf >commentnonlfile "#comment" &&
+ name="commentnonlfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F commentnonlfile $name &&
+ get_header $name | test_cmp expect -
'
# listing messages for annotated non-signed tags:
-test_expect_success \
- 'listing the one-line message of a non-signed tag should succeed' '
+test_expect_success 'listing the one-line message of a non-signed tag should succeed' '
git tag -m "A msg" tag-one-line &&
- echo "tag-one-line" >expect &&
- git tag -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-one-line >actual &&
- test_cmp expect actual &&
-
- echo "tag-one-line A msg" >expect &&
- git tag -n1 -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n999 -l tag-one-line >actual &&
- test_cmp expect actual
+ echo >expect "tag-one-line" &&
+ git tag -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n0 -l tag-one-line | test_cmp expect - &&
+
+ echo >expect "tag-one-line A msg" &&
+ git tag -n1 -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n1 -l tag-one-line | test_cmp expect - &&
+ git tag -n2 -l tag-one-line | test_cmp expect - &&
+ git tag -n999 -l tag-one-line | test_cmp expect -
'
-test_expect_success \
- 'listing the zero-lines message of a non-signed tag should succeed' '
+test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' '
git tag -m "" tag-zero-lines &&
- echo "tag-zero-lines" >expect &&
- git tag -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
-
- echo "tag-zero-lines " >expect &&
- git tag -n1 -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n999 -l tag-zero-lines >actual &&
- test_cmp expect actual
+ echo >expect "tag-zero-lines" &&
+ git tag -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l tag-zero-lines | test_cmp expect - &&
+
+ echo >expect "tag-zero-lines " &&
+ git tag -n1 -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n1 -l tag-zero-lines | test_cmp expect - &&
+ git tag -n2 -l tag-zero-lines | test_cmp expect - &&
+ git tag -n999 -l tag-zero-lines | test_cmp expect -
'
-echo 'tag line one' >annotagmsg
-echo 'tag line two' >>annotagmsg
-echo 'tag line three' >>annotagmsg
-test_expect_success \
- 'listing many message lines of a non-signed tag should succeed' '
+test_expect_success 'listing many message lines of a non-signed tag should succeed' '
+ cat >annotagmsg <<-EOF &&
+ tag line one
+ tag line two
+ tag line three
+ EOF
git tag -F annotagmsg tag-lines &&
-
echo "tag-lines" >expect &&
- git tag -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n0 -l tag-lines | test_cmp expect - &&
echo "tag-lines tag line one" >expect &&
- git tag -n1 -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n1 -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n1 -l tag-lines | test_cmp expect - &&
echo " tag line two" >>expect &&
- git tag -n2 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n2 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n2 -l tag-lines | test_cmp expect - &&
echo " tag line three" >>expect &&
- git tag -n3 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n3 -l tag-lines >actual &&
- test_cmp expect actual &&
- git tag -n4 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n4 -l tag-lines >actual &&
- test_cmp expect actual &&
- git tag -n99 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n99 -l tag-lines >actual &&
- test_cmp expect actual
+ git tag -n3 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n3 -l tag-lines | test_cmp expect - &&
+ git tag -n4 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n4 -l tag-lines | test_cmp expect - &&
+ git tag -n99 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n99 -l tag-lines | test_cmp expect -
'
test_expect_success 'annotations for blobs are empty' '
- blob=$(git hash-object -w --stdin <<-\EOF
- Blob paragraph 1.
+ blob=$(git hash-object -w --stdin <<-EOF
+ Blob paragraph 1.
- Blob paragraph 2.
+ Blob paragraph 2.
EOF
) &&
git tag tag-blob $blob &&
- echo "tag-blob " >expect &&
- git tag -n1 -l tag-blob >actual &&
- test_cmp expect actual
+ echo >expect "tag-blob " &&
+ git tag -n1 -l tag-blob | test_cmp expect -
'
# trying to verify annotated non-signed tags:
-test_expect_success GPG \
- 'trying to verify an annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' '
tag_exists annotated-tag &&
- test_must_fail git tag -v annotated-tag
+ silent test_must_fail git tag -v annotated-tag
'
-test_expect_success GPG \
- 'trying to verify a file-annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' '
tag_exists file-annotated-tag &&
- test_must_fail git tag -v file-annotated-tag
+ silent test_must_fail git tag -v file-annotated-tag
'
-test_expect_success GPG \
- 'trying to verify two annotated non-signed tags should fail' '
+test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' '
tag_exists annotated-tag file-annotated-tag &&
- test_must_fail git tag -v annotated-tag file-annotated-tag
+ silent test_must_fail git tag -v annotated-tag file-annotated-tag
'
# creating and verifying signed tags:
-get_tag_header signed-tag $commit commit $time >expect
-echo 'A signed tag message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -m message should succeed' '
- git tag -s -m "A signed tag message" signed-tag &&
- get_tag_msg signed-tag >actual &&
- test_cmp expect actual
+ name="signed-tag" &&
+ msg="A signed tag message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header u-signed-tag $commit commit $time >expect
-echo 'Another message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'sign with a given key id' '
-
- git tag -u committer@example.com -m "Another message" u-signed-tag &&
- get_tag_msg u-signed-tag >actual &&
- test_cmp expect actual
-
+ name="u-signed-tag" &&
+ msg="Another message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -u committer@example.com -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
test_expect_success GPG 'sign with an unknown id (1)' '
-
- test_must_fail git tag -u author@example.com \
+ silent test_must_fail git tag -u author@example.com \
-m "Another message" o-signed-tag
-
'
test_expect_success GPG 'sign with an unknown id (2)' '
-
- test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
-
+ silent test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-test -n "$1" && exec >"$1"
-echo A signed tag message
-echo from a fake editor.
-EOF
-chmod +x fakeeditor
-
-get_tag_header implied-sign $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-u implies signed tag' '
- GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
- get_tag_msg implied-sign >actual &&
- test_cmp expect actual
+ cat <<-\EOF | write_script fakeeditor &&
+ test -n "$1" && exec >"$1"
+ echo A signed tag message
+ echo from a fake editor.
+ EOF
+ name="implied-signed" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ GIT_EDITOR=./fakeeditor git tag -u CDDE430D $name &&
+ get_header $name | test_cmp expect -
'
-cat >sigmsgfile <<EOF
-Another signed tag
-message in a file.
-EOF
-get_tag_header file-signed-tag $commit commit $time >expect
-cat sigmsgfile >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with -F messagefile should succeed' '
- git tag -s -F sigmsgfile file-signed-tag &&
- get_tag_msg file-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' '
+ name="file-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ Another signed tag
+ message in a file.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ tail -n 3 expect | head -n 2 >sigmsgfile
+ git tag -s -F sigmsgfile $name &&
+ get_header $name | test_cmp expect -
'
-cat >siginputmsg <<EOF
-A signed tag message from
-the standard input
-EOF
-get_tag_header stdin-signed-tag $commit commit $time >expect
-cat siginputmsg >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -F - should succeed' '
- git tag -s -F - stdin-signed-tag <siginputmsg &&
- get_tag_msg stdin-signed-tag >actual &&
- test_cmp expect actual
+ name="stdin-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A signed tag message from
+ the standard input
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ tail -n 3 expect | head -n 2 | git tag -s -F - $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header implied-annotate $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-s implies annotated tag' '
- GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
- get_tag_msg implied-annotate >actual &&
- test_cmp expect actual
+ name="implied-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ GIT_EDITOR=./fakeeditor git tag -s $name &&
+ get_header $name | test_cmp expect -
'
-test_expect_success GPG \
- 'trying to create a signed tag with non-existing -F file should fail' '
+test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists nosigtag &&
- test_must_fail git tag -s -F nonexistingfile nosigtag &&
+ silent test_must_fail git tag -s -F nonexistingfile nosigtag &&
! tag_exists nosigtag
'
-test_expect_success GPG 'verifying a signed tag should succeed' \
- 'git tag -v signed-tag'
+test_expect_success GPG 'verifying a signed tag should succeed' '
+ silent git tag -v signed-tag
+'
-test_expect_success GPG 'verifying two signed tags in one command should succeed' \
- 'git tag -v signed-tag file-signed-tag'
+test_expect_success GPG 'verifying two signed tags in one command should succeed' '
+ silent git tag -v signed-tag file-signed-tag
+'
-test_expect_success GPG \
- 'verifying many signed and non-signed tags should fail' '
- test_must_fail git tag -v signed-tag annotated-tag &&
- test_must_fail git tag -v file-annotated-tag file-signed-tag &&
- test_must_fail git tag -v annotated-tag \
+test_expect_success GPG 'verifying many signed and non-signed tags should fail' '
+ silent test_must_fail git tag -v signed-tag annotated-tag &&
+ silent test_must_fail git tag -v file-annotated-tag file-signed-tag &&
+ silent test_must_fail git tag -v annotated-tag \
file-signed-tag file-annotated-tag &&
- test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
+ silent test_must_fail git tag -v signed-tag \
+ annotated-tag file-signed-tag
'
test_expect_success GPG 'verifying a forged tag should fail' '
@@ -735,405 +681,374 @@ test_expect_success GPG 'verifying a forged tag should fail' '
sed -e "s/signed-tag/forged-tag/" |
git mktag) &&
git tag forged-tag $forged &&
- test_must_fail git tag -v forged-tag
+ silent test_must_fail git tag -v forged-tag
'
# blank and empty messages for signed tags:
-get_tag_header empty-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with an empty -m message should succeed' '
- git tag -s -m "" empty-signed-tag &&
- get_tag_msg empty-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v empty-signed-tag
-'
-
->sigemptyfile
-get_tag_header emptyfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with an empty -F messagefile should succeed' '
- git tag -s -F sigemptyfile emptyfile-signed-tag &&
- get_tag_msg emptyfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v emptyfile-signed-tag
-'
-
-printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
-printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
-get_tag_header blanks-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
-
-Repeated blank lines
-
-Trailing spaces
-
-Trailing blank lines
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
- git tag -s -F sigblanksfile blanks-signed-tag &&
- get_tag_msg blanks-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blanks-signed-tag
-'
-
-get_tag_header blank-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a blank -m message should succeed' '
- git tag -s -m " " blank-signed-tag &&
- get_tag_msg blank-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blank-signed-tag
-'
-
-echo ' ' >sigblankfile
-echo '' >>sigblankfile
-echo ' ' >>sigblankfile
-get_tag_header blankfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with blank -F file with spaces should succeed' '
- git tag -s -F sigblankfile blankfile-signed-tag &&
- get_tag_msg blankfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blankfile-signed-tag
-'
-
-printf ' ' >sigblanknonlfile
-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with spaces and no newline should succeed' '
- git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
- get_tag_msg blanknonlfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v signed-tag
+test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' '
+ name="empty-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "" $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' '
+ >sigemptyfile &&
+ name="emptyfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigemptyfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' '
+ here >sigblanksfile <<-\EOF &&
+
+ \s\s
+ \t
+ Leading blank lines
+
+ \t\s\t\s\s
+ Repeated blank lines
+
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ name="blanks-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ Leading blank lines
+
+ Repeated blank lines
+
+ Trailing spaces
+
+ Trailing blank lines
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblanksfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' '
+ name="blank-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m " " $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' '
+ here >sigblankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ name="blankfile-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblankfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' '
+ printf >sigblanknonlfile " " &&
+ name="blanknonlfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblanknonlfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
'
# messages with commented lines for signed tags:
-cat >sigcommentsfile <<EOF
-# A comment
-
-############
-The message.
-############
-One line.
-
-
-# commented lines
-# commented lines
-
-Another line.
-# comments
-
-Last line.
-EOF
-get_tag_header comments-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
-
-Another line.
-
-Last line.
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
- git tag -s -F sigcommentsfile comments-signed-tag &&
- get_tag_msg comments-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v comments-signed-tag
-'
-
-get_tag_header comment-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with #commented -m message should succeed' '
- git tag -s -m "#comment" comment-signed-tag &&
- get_tag_msg comment-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v comment-signed-tag
-'
-
-echo '#comment' >sigcommentfile
-echo '' >>sigcommentfile
-echo '####' >>sigcommentfile
-get_tag_header commentfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with #commented -F messagefile should succeed' '
- git tag -s -F sigcommentfile commentfile-signed-tag &&
- get_tag_msg commentfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v commentfile-signed-tag
-'
-
-printf '#comment' >sigcommentnonlfile
-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a #comment and no newline should succeed' '
- git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
- get_tag_msg commentnonlfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v commentnonlfile-signed-tag
+test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' '
+ cat >sigcommentsfile <<-EOF &&
+ # A comment
+
+ ############
+ The message.
+ ############
+ One line.
+
+
+ # commented lines
+ # commented lines
+
+ Another line.
+ # comments
+
+ Last line.
+ EOF
+ name="comments-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ The message.
+ One line.
+
+ Another line.
+
+ Last line.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentsfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' '
+ name="comment-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "#comment" $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' '
+ cat >sigcommentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ name="commentfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' '
+ printf "#comment" >sigcommentnonlfile &&
+ name="commentnonlfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentnonlfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
'
# listing messages for signed tags:
-test_expect_success GPG \
- 'listing the one-line message of a signed tag should succeed' '
+test_expect_success GPG 'listing the one-line message of a signed tag should succeed' '
git tag -s -m "A message line signed" stag-one-line &&
echo "stag-one-line" >expect &&
- git tag -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-one-line >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n0 -l stag-one-line | test_cmp expect - &&
echo "stag-one-line A message line signed" >expect &&
- git tag -n1 -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n999 -l stag-one-line >actual &&
- test_cmp expect actual
+ git tag -n1 -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n1 -l stag-one-line | test_cmp expect - &&
+ git tag -n2 -l stag-one-line | test_cmp expect - &&
+ git tag -n999 -l stag-one-line | test_cmp expect -
'
-test_expect_success GPG \
- 'listing the zero-lines message of a signed tag should succeed' '
+test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' '
git tag -s -m "" stag-zero-lines &&
echo "stag-zero-lines" >expect &&
- git tag -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l stag-zero-lines | test_cmp expect - &&
echo "stag-zero-lines " >expect &&
- git tag -n1 -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n999 -l stag-zero-lines >actual &&
- test_cmp expect actual
-'
-
-echo 'stag line one' >sigtagmsg
-echo 'stag line two' >>sigtagmsg
-echo 'stag line three' >>sigtagmsg
-test_expect_success GPG \
- 'listing many message lines of a signed tag should succeed' '
+ git tag -n1 -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n1 -l stag-zero-lines | test_cmp expect - &&
+ git tag -n2 -l stag-zero-lines | test_cmp expect - &&
+ git tag -n999 -l stag-zero-lines | test_cmp expect -
+'
+
+test_expect_success GPG 'listing many message lines of a signed tag should succeed' '
+ cat >sigtagmsg <<-EOF &&
+ stag line one
+ stag line two
+ stag line three
+ EOF
git tag -s -F sigtagmsg stag-lines &&
echo "stag-lines" >expect &&
- git tag -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n0 -l stag-lines | test_cmp expect - &&
echo "stag-lines stag line one" >expect &&
- git tag -n1 -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n1 -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n1 -l stag-lines | test_cmp expect - &&
echo " stag line two" >>expect &&
- git tag -n2 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n2 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n2 -l stag-lines | test_cmp expect - &&
echo " stag line three" >>expect &&
- git tag -n3 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n3 -l stag-lines >actual &&
- test_cmp expect actual &&
- git tag -n4 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n4 -l stag-lines >actual &&
- test_cmp expect actual &&
- git tag -n99 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n99 -l stag-lines >actual &&
- test_cmp expect actual
-'
-
-# tags pointing to objects different from commits:
-
-tree=$(git rev-parse HEAD^{tree})
-blob=$(git rev-parse HEAD:foo)
-tag=$(git rev-parse signed-tag 2>/dev/null)
-
-get_tag_header tree-signed-tag $tree tree $time >expect
-echo "A message for a tree" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to a tree should succeed' '
- git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
- get_tag_msg tree-signed-tag >actual &&
- test_cmp expect actual
+ git tag -n3 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n3 -l stag-lines | test_cmp expect - &&
+ git tag -n4 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n4 -l stag-lines | test_cmp expect - &&
+ git tag -n99 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n99 -l stag-lines | test_cmp expect -
+'
+
+
+test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' '
+ # tags pointing to objects different from commits:
+ tree=$(git rev-parse HEAD^{tree}) &&
+ blob=$(git rev-parse HEAD:foo) &&
+ tag=$(git rev-parse signed-tag) &&
+ name="tree-signed-tag" &&
+ msg="A message for a tree" &&
+ gen_header $name $tree tree $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name HEAD^{tree} &&
+ get_header $name | test_cmp expect -
'
-get_tag_header blob-signed-tag $blob blob $time >expect
-echo "A message for a blob" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to a blob should succeed' '
- git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
- get_tag_msg blob-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' '
+ msg="A message for a blob" &&
+ name="blob-signed-tag" &&
+ gen_header $name $blob blob $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name HEAD:foo &&
+ get_header $name | test_cmp expect -
'
-get_tag_header tag-signed-tag $tag tag $time >expect
-echo "A message for another tag" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to another tag should succeed' '
- git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
- get_tag_msg tag-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' '
+ msg="A message for another tag" &&
+ name="tag-signed-tag" &&
+ gen_header $name $tag tag $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name signed-tag &&
+ get_header $name | test_cmp expect -
'
# usage with rfc1991 signatures
-echo "rfc1991" > gpghome/gpg.conf
-get_tag_header rfc1991-signed-tag $commit commit $time >expect
-echo "RFC1991 signed tag" >>expect
-echo '-----BEGIN PGP MESSAGE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with rfc1991' '
- git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
- get_tag_msg rfc1991-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag with rfc1991' '
+ echo "rfc1991" >gpghome/gpg.conf &&
+ msg="RFC1991 signed tag" &&
+ name="rfc1991-signed-tag"
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP MESSAGE-----
+ EOF
+ git tag -s -m "$msg" $name $commit &&
+ get_header $name | test_cmp expect -
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-cp "$1" actual
-EOF
-chmod +x fakeeditor
-
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
+ cat <<-\EOF | write_script fakeeditor &&
+ cp "$1" actual
+ EOF
echo "RFC1991 signed tag" >expect &&
- GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ GIT_EDITOR=./fakeeditor \
+ quiet git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-test_expect_success GPG \
- 'verifying rfc1991 signature' '
- git tag -v rfc1991-signed-tag
+test_expect_success GPG 'verifying rfc1991 signature' '
+ silent git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature' '
+test_expect_success GPG 'list tag with rfc1991 signature' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
- git tag -l -n1 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n2 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n999 rfc1991-signed-tag >actual &&
- test_cmp expect actual
+ git tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n999 rfc1991-signed-tag | test_cmp expect -
'
-rm -f gpghome/gpg.conf
-
-test_expect_success GPG \
- 'verifying rfc1991 signature without --rfc1991' '
- git tag -v rfc1991-signed-tag
+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '
+ rm -f gpghome/gpg.conf &&
+ silent git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature without --rfc1991' '
- echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
- git tag -l -n1 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n2 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n999 rfc1991-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '
+ echo >expect "rfc1991-signed-tag RFC1991 signed tag" &&
+ git tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n999 rfc1991-signed-tag | test_cmp expect -
'
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
- GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ GIT_EDITOR=./fakeeditor \
+ quiet git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-# try to sign with bad user.signingkey
-git config user.signingkey BobTheMouse
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured' \
- 'test_must_fail git tag -s -m tail tag-gpg-failure'
-git config --unset user.signingkey
-
-# try to verify without gpg:
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '
+ # try to sign with bad user.signingkey
+ git config user.signingkey BobTheMouse &&
+ silent test_must_fail git tag -s -m tail tag-gpg-failure &&
+ git config --unset user.signingkey
+'
-rm -rf gpghome
-test_expect_success GPG \
- 'verify signed tag fails when public key is not present' \
- 'test_must_fail git tag -v signed-tag'
+test_expect_success GPG 'verify signed tag fails when public key is not present' '
+ # try to verify without gpg:
+ rm -rf gpghome &&
+ silent test_must_fail git tag -v signed-tag
+'
-test_expect_success \
- 'git tag -a fails if tag annotation is empty' '
- ! (GIT_EDITOR=cat git tag -a initial-comment)
+test_expect_success 'git tag -a fails if tag annotation is empty' '
+ ! (GIT_EDITOR=cat silent git tag -a initial-comment)
'
-test_expect_success \
- 'message in editor has initial comment' '
- ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
+test_expect_success 'message in editor has initial comment' '
+ ! (GIT_EDITOR=cat git tag -a initial-comment >actual 2>/dev/null)
'
test_expect_success 'message in editor has initial comment: first line' '
# check the first line --- should be empty
echo >first.expect &&
- sed -e 1q <actual >first.actual &&
+ sed -e 1q actual >first.actual &&
test_i18ncmp first.expect first.actual
'
-test_expect_success \
- 'message in editor has initial comment: remainder' '
+test_expect_success 'message in editor has initial comment: remainder' '
# remove commented lines from the remainder -- should be empty
>rest.expect
sed -e 1d -e '/^#/d' <actual >rest.actual &&
test_cmp rest.expect rest.actual
'
-get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >> expect
-test_expect_success \
- 'overwriting an annoted tag should use its previous body' '
- git tag -a -m "An annotation to be reused" reuse &&
- GIT_EDITOR=true git tag -f -a reuse &&
- get_tag_msg reuse >actual &&
- test_cmp expect actual
+test_expect_success 'overwriting an annoted tag should use its previous body' '
+ name="reuse" &&
+ msg="An annotation to be reused" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ reuse
+ EOF
+ git tag -a -m "$msg" $name &&
+ GIT_EDITOR=true git tag -f -a -m "reuse" $name &&
+ get_header $name | test_cmp expect -
'
test_expect_success 'filename for the message is relative to cwd' '
@@ -1144,7 +1059,7 @@ test_expect_success 'filename for the message is relative to cwd' '
cd subdir &&
git tag -a -F msgfile-5 tag-from-subdir
) &&
- git cat-file tag tag-from-subdir | grep "in sub directory"
+ git cat-file tag tag-from-subdir | grep -q "in sub directory"
'
test_expect_success 'filename for the message is relative to cwd' '
@@ -1153,172 +1068,143 @@ test_expect_success 'filename for the message is relative to cwd' '
cd subdir &&
git tag -a -F msgfile-6 tag-from-subdir-2
) &&
- git cat-file tag tag-from-subdir-2 | grep "in sub directory"
+ git cat-file tag tag-from-subdir-2 | grep -q "in sub directory"
'
-# create a few more commits to test --contains
-
-hash1=$(git rev-parse HEAD)
-
test_expect_success 'creating second commit and tag' '
+ # create a few more commits to test --contains
+ hash1=$(git rev-parse HEAD) &&
echo foo-2.0 >foo &&
git add foo &&
- git commit -m second &&
+ git commit -q -m second &&
+ hash2=$(git rev-parse HEAD) &&
git tag v2.0
'
-hash2=$(git rev-parse HEAD)
-
test_expect_success 'creating third commit without tag' '
echo foo-dev >foo &&
git add foo &&
- git commit -m third
+ git commit -q -m third &&
+ hash3=$(git rev-parse HEAD)
+'
+
+test_expect_success 'checking that first commit is in all tags (hash)' '
+ # simple linear checks of --contains
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
+ git tag -l --contains $hash1 v* | test_cmp expect -
'
-hash3=$(git rev-parse HEAD)
-
-# simple linear checks of --continue
-
-cat > expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
-test_expect_success 'checking that first commit is in all tags (hash)' "
- git tag -l --contains $hash1 v* >actual &&
- test_cmp expected actual
-"
-
-# other ways of specifying the commit
-test_expect_success 'checking that first commit is in all tags (tag)' "
- git tag -l --contains v1.0 v* >actual &&
- test_cmp expected actual
-"
-
-test_expect_success 'checking that first commit is in all tags (relative)' "
- git tag -l --contains HEAD~2 v* >actual &&
- test_cmp expected actual
-"
-
-cat > expected <<EOF
-v2.0
-EOF
-
-test_expect_success 'checking that second commit only has one tag' "
- git tag -l --contains $hash2 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that first commit is in all tags (tag)' '
+ # other ways of specifying the commit
+ git tag -l --contains v1.0 v* | test_cmp expect -
+'
+test_expect_success 'checking that first commit is in all tags (relative)' '
+ git tag -l --contains HEAD~2 v* | test_cmp expect -
+'
-cat > expected <<EOF
-EOF
+test_expect_success 'checking that second commit only has one tag' '
+ cat >expect <<-EOF &&
+ v2.0
+ EOF
+ git tag -l --contains $hash2 v* | test_cmp expect -
+'
-test_expect_success 'checking that third commit has no tags' "
- git tag -l --contains $hash3 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that third commit has no tags' '
+ >expect
+ git tag -l --contains $hash3 v* | test_cmp expect -
+'
# how about a simple merge?
test_expect_success 'creating simple branch' '
git branch stable v2.0 &&
- git checkout stable &&
- echo foo-3.0 > foo &&
- git commit foo -m fourth &&
+ git checkout -q stable &&
+ echo foo-3.0 >foo &&
+ git commit -q foo -m fourth &&
+ hash4=$(git rev-parse HEAD) &&
git tag v3.0
'
-hash4=$(git rev-parse HEAD)
-
-cat > expected <<EOF
-v3.0
-EOF
-
-test_expect_success 'checking that branch head only has one tag' "
- git tag -l --contains $hash4 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that branch head only has one tag' '
+ cat >expect <<-EOF &&
+ v3.0
+ EOF
+ git tag -l --contains $hash4 v* | test_cmp expect -
+'
test_expect_success 'merging original branch into this branch' '
- git merge --strategy=ours master &&
+ git merge -q --strategy=ours master &&
git tag v4.0
'
-cat > expected <<EOF
-v4.0
-EOF
-
-test_expect_success 'checking that original branch head has one tag now' "
- git tag -l --contains $hash3 v* >actual &&
- test_cmp expected actual
-"
-
-cat > expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-v4.0
-EOF
-
-test_expect_success 'checking that initial commit is in all tags' "
- git tag -l --contains $hash1 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that original branch head has one tag now' '
+ cat >expect <<-EOF &&
+ v4.0
+ EOF
+ git tag -l --contains $hash3 v* | test_cmp expect -
+'
+
+test_expect_success 'checking that initial commit is in all tags' '
+ cat >expect <<-EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ v3.0
+ v4.0
+ EOF
+ git tag -l --contains $hash1 v* | test_cmp expect -
+'
-# mixing modes and options:
test_expect_success 'mixing incompatibles modes and options is forbidden' '
- test_must_fail git tag -a &&
- test_must_fail git tag -l -v &&
- test_must_fail git tag -n 100 &&
- test_must_fail git tag -l -m msg &&
- test_must_fail git tag -l -F some file &&
- test_must_fail git tag -v -s
+ # mixing modes and options:
+ silent test_must_fail git tag -a &&
+ silent test_must_fail git tag -l -v &&
+ silent test_must_fail git tag -n 100 &&
+ silent test_must_fail git tag -l -m msg &&
+ silent test_must_fail git tag -l -F some file &&
+ silent test_must_fail git tag -v -s &&
+ silent test_must_fail git tag --points-at=v4.0 foo
'
# check points-at
-test_expect_success '--points-at cannot be used in non-list mode' '
- test_must_fail git tag --points-at=v4.0 foo
-'
-
test_expect_success '--points-at finds lightweight tags' '
echo v4.0 >expect &&
- git tag --points-at v4.0 >actual &&
- test_cmp expect actual
+ git tag --points-at v4.0 | test_cmp expect -
'
test_expect_success '--points-at finds annotated tags of commits' '
git tag -m "v4.0, annotated" annotated-v4.0 v4.0 &&
echo annotated-v4.0 >expect &&
- git tag -l --points-at v4.0 "annotated*" >actual &&
- test_cmp expect actual
+ git tag -l --points-at v4.0 "annotated*" | test_cmp expect -
'
test_expect_success '--points-at finds annotated tags of tags' '
git tag -m "describing the v4.0 tag object" \
annotated-again-v4.0 annotated-v4.0 &&
- cat >expect <<-\EOF &&
- annotated-again-v4.0
- annotated-v4.0
+ cat >expect <<-EOF &&
+ annotated-again-v4.0
+ annotated-v4.0
EOF
- git tag --points-at=annotated-v4.0 >actual &&
- test_cmp expect actual
+ git tag --points-at=annotated-v4.0 | test_cmp expect -
'
test_expect_success 'multiple --points-at are OR-ed together' '
- cat >expect <<-\EOF &&
- v2.0
- v3.0
+ cat >expect <<-EOF &&
+ v2.0
+ v3.0
EOF
- git tag --points-at=v2.0 --points-at=v3.0 >actual &&
- test_cmp expect actual
+ git tag --points-at=v2.0 --points-at=v3.0 | test_cmp expect -
'
test_done
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-02-23 0:22 ` Tom Grennan
` (6 preceding siblings ...)
2012-03-01 1:45 ` [PATCH 5/5] t7004 (tag): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 2:13 ` Junio C Hamano
2012-03-01 1:45 ` [PATCH-w 102/105] t5512 (ls-remote): " Tom Grennan
` (3 subsequent siblings)
11 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t6300-for-each-ref.sh | 296 +++++++++++++++++++++++++----------------------
1 files changed, 157 insertions(+), 139 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..12916b2 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -5,9 +5,17 @@
test_description='for-each-ref test'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+
# Mon Jul 3 15:18:43 2006 +0000
datestamp=1151939923
setdate_and_increment () {
@@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '
setdate_and_increment &&
echo "Using $datestamp" > one &&
git add one &&
- git commit -m "Initial" &&
+ git commit -q -m "Initial" &&
setdate_and_increment &&
- git tag -a -m "Tagging at $datestamp" testtag
+ quiet git tag -a -m "Tagging at $datestamp" testtag
'
test_expect_success 'Create upstream config' '
@@ -115,261 +123,270 @@ test_atom tag contents 'Tagging at 1151939927
'
test_expect_success 'Check invalid atoms names are errors' '
- test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
+ silent test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
'
test_expect_success 'Check format specifiers are ignored in naming date atoms' '
- git for-each-ref --format="%(authordate)" refs/heads &&
- git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
- git for-each-ref --format="%(authordate) %(authordate:default)" refs/heads &&
- git for-each-ref --format="%(authordate:default) %(authordate:default)" refs/heads
+ f1="%(authordate)" &&
+ f2="%(authordate:default) %(authordate)" &&
+ f3="%(authordate) %(authordate:default)" &&
+ f4="%(authordate:default) %(authordate:default)"
+ quiet git for-each-ref --format="$f1" refs/heads &&
+ quiet git for-each-ref --format="$f2" refs/heads &&
+ quiet git for-each-ref --format="$f3" refs/heads &&
+ quiet git for-each-ref --format="$f4" refs/heads
'
test_expect_success 'Check valid format specifiers for date fields' '
- git for-each-ref --format="%(authordate:default)" refs/heads &&
- git for-each-ref --format="%(authordate:relative)" refs/heads &&
- git for-each-ref --format="%(authordate:short)" refs/heads &&
- git for-each-ref --format="%(authordate:local)" refs/heads &&
- git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
- git for-each-ref --format="%(authordate:rfc2822)" refs/heads
+ quiet git for-each-ref --format="%(authordate:default)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:relative)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:short)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:local)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
+ quiet git for-each-ref --format="%(authordate:rfc2822)" refs/heads
'
test_expect_success 'Check invalid format specifiers are errors' '
- test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
+ h="%(authordate:INVALID)" &&
+ silent test_must_fail git for-each-ref --format="$h" refs/heads
'
-cat >expected <<\EOF
+test_expect_success 'Check unformatted date fields output' '
+ '"
+ cat >expect <<-EOF &&
'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
EOF
-
-test_expect_success 'Check unformatted date fields output' '
- (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
- test_cmp expected actual
+ "'
+ h="%(refname) %(committerdate) %(authordate)" &&
+ t="%(refname) %(taggerdate)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
test_expect_success 'Check format "default" formatted date fields output' '
- f=default &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ h="%(refname) %(committerdate:default) %(authordate:default)" &&
+ t="%(refname) %(taggerdate:default)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-# Don't know how to do relative check because I can't know when this script
-# is going to be run and can't fake the current time to git, and hence can't
-# provide expected output. Instead, I'll just make sure that "relative"
-# doesn't exit in error
-#
-#cat >expected <<\EOF
-#
-#EOF
-#
test_expect_success 'Check format "relative" date fields output' '
- f=relative &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
+ '"
+ # Don't know how to do relative check because I can't know when this
+ # script is going to be run and can't fake the current time to git,
+ # and hence can't provide expected output. Instead, I'll just make
+ # sure that 'relative' doesn't exit in error
+ "'
+ h="%(refname) %(committerdate:relative) %(authordate:relative)" &&
+ t="%(refname) %(taggerdate:relative)" &&
+ quiet git for-each-ref --shell --format="$h" refs/heads &&
+ quiet git for-each-ref --shell --format="$t" refs/tags
'
-cat >expected <<\EOF
+test_expect_success 'Check format "short" date fields output' '
+ '"
+ cat >expect <<-EOF
'refs/heads/master' '2006-07-03' '2006-07-03'
'refs/tags/testtag' '2006-07-03'
EOF
-
-test_expect_success 'Check format "short" date fields output' '
- f=short &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ "'
+ h="%(refname) %(committerdate:short) %(authordate:short)" &&
+ t="%(refname) %(taggerdate:short)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Check format "local" date fields output' '
+ '"
+ cat >expect <<-EOF
'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
EOF
-
-test_expect_success 'Check format "local" date fields output' '
- f=local &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ "'
+ h="%(refname) %(committerdate:local) %(authordate:local)" &&
+ t="%(refname) %(taggerdate:local)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Check format "iso8601" date fields output' '
+ '"
+ cat >expect <<-EOF
'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "iso8601" date fields output' '
- f=iso8601 &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ "'
+ h="%(refname) %(committerdate:iso8601) %(authordate:iso8601)" &&
+ t="%(refname) %(taggerdate:iso8601)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Check format "rfc2822" date fields output' '
+ '"
+ cat >expect <<-EOF
'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "rfc2822" date fields output' '
- f=rfc2822 &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- test_cmp expected actual
+ "'
+ h="%(refname) %(committerdate:rfc2822) %(authordate:rfc2822)" &&
+ t="%(refname) %(taggerdate:rfc2822)" &&
+ (git for-each-ref --shell --format="$h" refs/heads &&
+ git for-each-ref --shell --format="$t" refs/tags) |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Verify ascending sort' '
+ cat >expect <<-EOF
refs/heads/master
refs/remotes/origin/master
refs/tags/testtag
EOF
-
-test_expect_success 'Verify ascending sort' '
- git for-each-ref --format="%(refname)" --sort=refname >actual &&
- test_cmp expected actual
+ git for-each-ref --format="%(refname)" --sort=refname |
+ test_cmp expect -
'
-
-cat >expected <<\EOF
+test_expect_success 'Verify descending sort' '
+ cat >expect <<-EOF
refs/tags/testtag
refs/remotes/origin/master
refs/heads/master
EOF
-
-test_expect_success 'Verify descending sort' '
- git for-each-ref --format="%(refname)" --sort=-refname >actual &&
- test_cmp expected actual
+ git for-each-ref --format="%(refname)" --sort=-refname |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: shell' '
+ '"
+ cat >expect <<-EOF
'refs/heads/master'
'refs/remotes/origin/master'
'refs/tags/testtag'
EOF
-
-test_expect_success 'Quoting style: shell' '
- git for-each-ref --shell --format="%(refname)" >actual &&
- test_cmp expected actual
+ "'
+ git for-each-ref --shell --format="%(refname)" |
+ test_cmp expect -
'
test_expect_success 'Quoting style: perl' '
- git for-each-ref --perl --format="%(refname)" >actual &&
- test_cmp expected actual
+ git for-each-ref --perl --format="%(refname)" |
+ test_cmp expect -
'
test_expect_success 'Quoting style: python' '
- git for-each-ref --python --format="%(refname)" >actual &&
- test_cmp expected actual
+ git for-each-ref --python --format="%(refname)" |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: tcl' '
+ cat >expect <<-EOF
"refs/heads/master"
"refs/remotes/origin/master"
"refs/tags/testtag"
EOF
-
-test_expect_success 'Quoting style: tcl' '
- git for-each-ref --tcl --format="%(refname)" >actual &&
- test_cmp expected actual
+ git for-each-ref --tcl --format="%(refname)" |
+ test_cmp expect -
'
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
- test_expect_success "more than one quoting style: $i" "
- git for-each-ref $i 2>&1 | (read line &&
- case \$line in
- \"error: more than one quoting style\"*) : happy;;
- *) false
- esac)
- "
-done
-
-cat >expected <<\EOF
+test_expect_success 'more than one quoting styles' '
+ cat >expect <<-EOF
+ error: more than one quoting style?
+ EOF
+ git for-each-ref --perl --shell 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref -s --python 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref --python --tcl 2>&1 | head -n 1 |
+ test_cmp expect - &&
+ git for-each-ref --tcl --perl 2>&1 | head -n 1 |
+ test_cmp expect -
+'
+test_expect_success 'Check short refname format' '
+ cat >expect <<-EOF
master
testtag
EOF
-
-test_expect_success 'Check short refname format' '
- (git for-each-ref --format="%(refname:short)" refs/heads &&
- git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
- test_cmp expected actual
+ git for-each-ref --format="%(refname:short)" refs/heads refs/tags |
+ test_cmp expect -
'
-cat >expected <<EOF
+test_expect_success 'Check short upstream format' '
+ cat >expect <<-EOF
origin/master
EOF
-
-test_expect_success 'Check short upstream format' '
- git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
- test_cmp expected actual
+ git for-each-ref --format="%(upstream:short)" refs/heads |
+ test_cmp expect -
'
-cat >expected <<EOF
+test_expect_success 'Check short objectname format' '
+ cat >expect <<-EOF
67a36f1
EOF
-
-test_expect_success 'Check short objectname format' '
- git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
- test_cmp expected actual
+ git for-each-ref --format="%(objectname:short)" refs/heads |
+ test_cmp expect -
'
test_expect_success 'Check for invalid refname format' '
- test_must_fail git for-each-ref --format="%(refname:INVALID)"
+ silent test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ cat >expect <<-EOF
heads/master
tags/master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (strict)' '
git config --bool core.warnambiguousrefs true &&
- git checkout -b newtag &&
+ git checkout -q -b newtag &&
echo "Using $datestamp" > one &&
git add one &&
- git commit -m "Branch" &&
+ git commit -q -m "Branch" &&
setdate_and_increment &&
- git tag -m "Tagging at $datestamp" master &&
- git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
- test_cmp expected actual
+ quiet git tag -m "Tagging at $datestamp" master &&
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/master refs/tags/master |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ cat >expect <<-EOF
heads/master
master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (loose)' '
git config --bool core.warnambiguousrefs false &&
- git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
- test_cmp expected actual
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/master refs/tags/master |
+ test_cmp expect -
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+ cat >expect <<-EOF
heads/ambiguous
ambiguous
EOF
-
-test_expect_success 'Check ambiguous head and tag refs II (loose)' '
- git checkout master &&
+ git checkout -q master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&
- git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual &&
- test_cmp expected actual
+ f="%(refname:short)" &&
+ git for-each-ref --format "$f" refs/heads/ambiguous refs/tags/ambiguous |
+ test_cmp expect -
'
test_expect_success 'an unusual tag with an incomplete line' '
-
git tag -m "bogo" bogo &&
bogo=$(git cat-file tag bogo) &&
bogo=$(printf "%s" "$bogo" | git mktag) &&
git tag -f bogo "$bogo" &&
git for-each-ref --format "%(body)" refs/tags/bogo
-
'
test_expect_success 'create tag with subject and body content' '
- cat >>msg <<-\EOF &&
+ cat >msg <<-\EOF &&
the subject line
first body line
@@ -395,8 +412,9 @@ test_expect_success 'create tag with multiline subject' '
first body line
second body line
EOF
- git tag -F msg multiline
+ quiet git tag -F msg multiline
'
+
test_atom refs/tags/multiline subject 'first subject line second subject line'
test_atom refs/tags/multiline contents:subject 'first subject line second subject line'
test_atom refs/tags/multiline body 'first body line
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 1:45 ` [PATCH-w 101/105] t6300 (for-each-ref): " Tom Grennan
@ 2012-03-01 2:13 ` Junio C Hamano
2012-03-01 3:20 ` Tom Grennan
0 siblings, 1 reply; 83+ messages in thread
From: Junio C Hamano @ 2012-03-01 2:13 UTC (permalink / raw)
To: Tom Grennan
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
> +if ! test -r test-lib.sh ; then
> + (cd ${0%/*} && ./${0##*/} $@)
> + exit $?
> +fi
Not very nice; why is this an improvement?
> . ./test-lib.sh
> . "$TEST_DIRECTORY"/lib-gpg.sh
>
> +quiet () { "$@" >/dev/null; }
> +silent () { "$@" >/dev/null 2>&1; }
Not nice, either.
> # Mon Jul 3 15:18:43 2006 +0000
> datestamp=1151939923
> setdate_and_increment () {
> @@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '
> setdate_and_increment &&
> echo "Using $datestamp" > one &&
> git add one &&
> - git commit -m "Initial" &&
> + git commit -q -m "Initial" &&
> setdate_and_increment &&
> - git tag -a -m "Tagging at $datestamp" testtag
> + quiet git tag -a -m "Tagging at $datestamp" testtag
Why? Why? Why?
cd t && sh ./t1234-frotz.sh
would be silent enough and suppressing the output from the commands like
this patch does makes it _harder_ for people to debug their changes to the
script with
sh ./t1234-frotz.sh -v
Most of the change in this patch does nothing to do with "modernize style".
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 2:13 ` Junio C Hamano
@ 2012-03-01 3:20 ` Tom Grennan
2012-03-01 3:26 ` Junio C Hamano
0 siblings, 1 reply; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 3:20 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
On Wed, Feb 29, 2012 at 06:13:53PM -0800, Junio C Hamano wrote:
>Tom Grennan <tmgrennan@gmail.com> writes:
>
>> +if ! test -r test-lib.sh ; then
>> + (cd ${0%/*} && ./${0##*/} $@)
>> + exit $?
>> +fi
>
>Not very nice; why is this an improvement?
I liked being able to,
t/t1234-frotz.sh [-q|-v]
in addition to,
cd t && sh ./t1234-frotz.sh
>> . ./test-lib.sh
>> . "$TEST_DIRECTORY"/lib-gpg.sh
>>
>> +quiet () { "$@" >/dev/null; }
>> +silent () { "$@" >/dev/null 2>&1; }
>
>Not nice, either.
"Not nice" b/c they're on one line?
I like simple things compressed so I quickly glance pass them.
Sort of forest through the trees.
>> # Mon Jul 3 15:18:43 2006 +0000
>> datestamp=1151939923
>> setdate_and_increment () {
>> @@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '
>> setdate_and_increment &&
>> echo "Using $datestamp" > one &&
>> git add one &&
>> - git commit -m "Initial" &&
>> + git commit -q -m "Initial" &&
>> setdate_and_increment &&
>> - git tag -a -m "Tagging at $datestamp" testtag
>> + quiet git tag -a -m "Tagging at $datestamp" testtag
>
>Why? Why? Why?
>
> cd t && sh ./t1234-frotz.sh
>
>would be silent enough and suppressing the output from the commands like
>this patch does makes it _harder_ for people to debug their changes to the
>script with
>
> sh ./t1234-frotz.sh -v
Hmm, I found the noise distracting. For example, w/o redirecting
stderr, most of the test_must_fail puke as expected. If it's expected,
why show it? BTW since it's a different stream, to get the error near
the exec log one has to:
sh ./t1234-frotz.sh -v |& less
Otherwise it's challenging to separate the expected vs unexpected failures.
Most of the "quiet's" are with git-tag and git-branch. I'd prefer
--quiet and --silent options to these commands like git-init, git-commit, etc.
>Most of the change in this patch does nothing to do with "modernize style".
It's trivial to remove these "quiet" and "silent", but to me that's the
only value added by these patches. More seriously, the remaining
modernization still seems much larger than its value.
--
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 3:20 ` Tom Grennan
@ 2012-03-01 3:26 ` Junio C Hamano
2012-03-01 5:10 ` Tom Grennan
0 siblings, 1 reply; 83+ messages in thread
From: Junio C Hamano @ 2012-03-01 3:26 UTC (permalink / raw)
To: Tom Grennan
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
Tom Grennan <tmgrennan@gmail.com> writes:
> It's trivial to remove these "quiet" and "silent", but to me that's the
> only value added by these patches. More seriously, the remaining
> modernization still seems much larger than its value.
Don't do that, then ;-).
Some older scripts do redirect the output from the commands to /dev/null
but that dates back before we made the default reasonably silent, and in
"modern" style we tend to keep them sent to their standard output to help
debuggability. These quiet/silent takes us to the prehistoric times.
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 3:26 ` Junio C Hamano
@ 2012-03-01 5:10 ` Tom Grennan
2012-03-01 5:57 ` Tom Grennan
2012-03-01 8:42 ` Thomas Rast
0 siblings, 2 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 5:10 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:
>Tom Grennan <tmgrennan@gmail.com> writes:
>
>> It's trivial to remove these "quiet" and "silent", but to me that's the
>> only value added by these patches. More seriously, the remaining
>> modernization still seems much larger than its value.
>
>Don't do that, then ;-).
>
>Some older scripts do redirect the output from the commands to /dev/null
>but that dates back before we made the default reasonably silent, and in
>"modern" style we tend to keep them sent to their standard output to help
>debuggability. These quiet/silent takes us to the prehistoric times.
Hey! I am prehistoric:-)
Like I said, I think there is currently a debug distraction with verbose
mode. However, rather than hiding expected failures and diverting other
output as I had, perhaps we should dup stderr to stdout in verbose mode
so error messages show up near the logged invocation when piped through
a pager (i.e. mimic "|&"). With this, one can quickly scan past the
noise to focus on the broken cases.
exec 5>&1
exec 6<&0
if test "$verbose" = "t"
then
- exec 4>&2 3>&1
+ exec 4>&1 3>&1
else
exec 4>/dev/null 3>/dev/null
fi
For example, try this w/ and w/o the above change.
(cd t && ./t5512-ls-remote.sh) | less
I still think git-branch and git-tag should have a -q option; better
yet, the wrapper itself (i.e. git --quiet/--silent XXX).
--
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 5:10 ` Tom Grennan
@ 2012-03-01 5:57 ` Tom Grennan
2012-03-01 8:42 ` Thomas Rast
1 sibling, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 5:57 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
On Wed, Feb 29, 2012 at 09:10:10PM -0800, Tom Grennan wrote:
>On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:
>>Tom Grennan <tmgrennan@gmail.com> writes:
>>
>For example, try this w/ and w/o the above change.
> (cd t && ./t5512-ls-remote.sh) | less
(cd t && ./t5512-ls-remote.sh -v) | less
--
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 5:10 ` Tom Grennan
2012-03-01 5:57 ` Tom Grennan
@ 2012-03-01 8:42 ` Thomas Rast
2012-03-01 15:48 ` Tom Grennan
1 sibling, 1 reply; 83+ messages in thread
From: Thomas Rast @ 2012-03-01 8:42 UTC (permalink / raw)
To: Tom Grennan
Cc: Junio C Hamano, git, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Amos Waterland, Johannes Schindelin
I sent out a reply to the same effect as Junio's longer one in this
side-thread. You can disregard that. Sorry for not first reading the
whole thread.
Tom Grennan <tmgrennan@gmail.com> writes:
> On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:
>>Tom Grennan <tmgrennan@gmail.com> writes:
>>
>>> It's trivial to remove these "quiet" and "silent", but to me that's the
>>> only value added by these patches. More seriously, the remaining
>>> modernization still seems much larger than its value.
>>
>>Don't do that, then ;-).
>>
>>Some older scripts do redirect the output from the commands to /dev/null
>>but that dates back before we made the default reasonably silent, and in
>>"modern" style we tend to keep them sent to their standard output to help
>>debuggability. These quiet/silent takes us to the prehistoric times.
>
> Hey! I am prehistoric:-)
>
> Like I said, I think there is currently a debug distraction with verbose
> mode. However, rather than hiding expected failures and diverting other
> output as I had, perhaps we should dup stderr to stdout in verbose mode
> so error messages show up near the logged invocation when piped through
> a pager (i.e. mimic "|&"). With this, one can quickly scan past the
> noise to focus on the broken cases.
If you have trouble finding the broken case, you can run with -v -i.
I also think you are making an argument for a different feature (which
does not rob us of having all the debug output): test-lib.sh could
perhaps redirect the test output to a file, and dump the file to stdout
only if the test failed. Perhaps --verbose-failing or something like
that.
Otherwise, your proposal is restricting us to having only an "easily
scannable" amount of output per test, perhaps 5-15 lines. Which I
personally think is an insane restriction for something that was
intended for debugging in the first place.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 83+ messages in thread
* Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style
2012-03-01 8:42 ` Thomas Rast
@ 2012-03-01 15:48 ` Tom Grennan
0 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 15:48 UTC (permalink / raw)
To: Thomas Rast
Cc: Junio C Hamano, git, Jeff King, Carlos Rica, Andy Parkins,
Shawn O. Pearce, Amos Waterland, Johannes Schindelin
On Thu, Mar 01, 2012 at 09:42:51AM +0100, Thomas Rast wrote:
>Tom Grennan <tmgrennan@gmail.com> writes:
>> On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:
>>>Tom Grennan <tmgrennan@gmail.com> writes:
>>>
>> Like I said, I think there is currently a debug distraction with verbose
>> mode. However, rather than hiding expected failures and diverting other
>> output as I had, perhaps we should dup stderr to stdout in verbose mode
>> so error messages show up near the logged invocation when piped through
>> a pager (i.e. mimic "|&"). With this, one can quickly scan past the
>> noise to focus on the broken cases.
>
>If you have trouble finding the broken case, you can run with -v -i.
>
>I also think you are making an argument for a different feature (which
>does not rob us of having all the debug output): test-lib.sh could
>perhaps redirect the test output to a file, and dump the file to stdout
>only if the test failed. Perhaps --verbose-failing or something like
>that.
>
>Otherwise, your proposal is restricting us to having only an "easily
>scannable" amount of output per test, perhaps 5-15 lines. Which I
>personally think is an insane restriction for something that was
>intended for debugging in the first place.
Oh, I hadn't tried -i with -v. This does mimic "|&".
(cd t && ./t5512-ls-remote.sh -v -i) | less
(cd t && ./t5512-ls-remote.sh -v) |& less
So, please ignore my suggestion.
Thanks,
TomG
^ permalink raw reply [flat|nested] 83+ messages in thread
* [PATCH-w 102/105] t5512 (ls-remote): modernize style
2012-02-23 0:22 ` Tom Grennan
` (7 preceding siblings ...)
2012-03-01 1:45 ` [PATCH-w 101/105] t6300 (for-each-ref): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH-w 103/105] t3200 (branch): " Tom Grennan
` (2 subsequent siblings)
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t5512-ls-remote.sh | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 5c546c9..bbe650f 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -2,14 +2,22 @@
test_description='git ls-remote'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+
test_expect_success setup '
>file &&
git add file &&
test_tick &&
- git commit -m initial &&
+ git commit -q -m initial &&
git tag mark &&
git show-ref --tags -d | sed -e "s/ / /" >expected.tag &&
(
@@ -51,7 +59,7 @@ test_expect_success 'ls-remote self' '
test_expect_success 'dies when no remote specified and no default remotes found' '
- test_must_fail git ls-remote
+ silent test_must_fail git ls-remote
'
@@ -70,8 +78,8 @@ test_expect_success 'use "origin" when no remote specified' '
test_expect_success 'suppress "From <url>" with -q' '
- git ls-remote -q 2>actual_err &&
- test_must_fail test_cmp exp_err actual_err
+ quiet git ls-remote -q 2>actual_err &&
+ test_must_fail cmp -s exp_err actual_err
'
@@ -83,7 +91,7 @@ test_expect_success 'use branch.<name>.remote if possible' '
#
# setup a new remote to differentiate from "origin"
- git clone . other.git &&
+ git clone -q . other.git &&
(
cd other.git &&
echo "$(git rev-parse HEAD) HEAD"
@@ -102,11 +110,13 @@ test_expect_success 'use branch.<name>.remote if possible' '
'
-cat >exp <<EOF
+test_expect_success 'confuses pattern as remote when no remote specified' '
+ '"
+ cat >exp <<-EOF
fatal: 'refs*master' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
EOF
-test_expect_success 'confuses pattern as remote when no remote specified' '
+ "'
#
# Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly,
# confuses <pattern> for <remote>. Although ugly, this behaviour is akin
@@ -124,7 +134,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' '
'
test_expect_success 'die with non-2 for wrong repository even with --exit-code' '
- git ls-remote --exit-code ./no-such-repository ;# not &&
+ silent git ls-remote --exit-code ./no-such-repository ;# not &&
status=$? &&
test $status != 2 && test $status != 0
'
@@ -136,7 +146,8 @@ test_expect_success 'Report success even when nothing matches' '
'
test_expect_success 'Report no-match with --exit-code' '
- test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual &&
+ test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" \
+ >actual &&
>expect &&
test_cmp expect actual
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH-w 103/105] t3200 (branch): modernize style
2012-02-23 0:22 ` Tom Grennan
` (8 preceding siblings ...)
2012-03-01 1:45 ` [PATCH-w 102/105] t5512 (ls-remote): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH-w 104/105] t0040 (parse-options): " Tom Grennan
2012-03-01 1:45 ` [PATCH-w 105/105] t7004 (tag): " Tom Grennan
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
- Use a "here" filter for expect generation
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t3200-branch.sh | 457 +++++++++++++++++++++++++++--------------------------
1 files changed, 236 insertions(+), 221 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index dd1aceb..93c35cd 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -5,125 +5,132 @@
test_description='git branch assorted tests'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+here () { sed 's/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g' $@; }
+
+test_expect_success 'prepare a trivial repository' '
+ echo Hello >A &&
git update-index --add A &&
- git commit -m "Initial commit." &&
+ git commit -q -m "Initial commit." &&
echo World >> A &&
git update-index --add A &&
- git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
+ git commit -q -m "Second commit." &&
+ HEAD=$(git rev-parse --verify HEAD)
+'
-test_expect_success \
- 'git branch --help should not have created a bogus branch' '
- test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
+test_expect_success 'git branch --help should not have created a bogus branch' '
+ silent test_might_fail git branch --help </dev/null &&
test_path_is_missing .git/refs/heads/--help
'
test_expect_success 'branch -h in broken repository' '
- mkdir broken &&
- (
- cd broken &&
- git init &&
- >.git/refs/heads/master &&
- test_expect_code 129 git branch -h >usage 2>&1
- ) &&
- grep "[Uu]sage" broken/usage
+ git init -q broken &&
+ test_when_finished rm -rf broken usage &&
+ >broken/.git/refs/heads/master &&
+ >usage 2>&1 test_expect_code 129 git --git-dir=broken/.git branch -h &&
+ grep -q "[Uu]sage" usage
'
-test_expect_success \
- 'git branch abc should create a branch' \
- 'git branch abc && test_path_is_file .git/refs/heads/abc'
+test_expect_success 'git branch abc should create a branch' '
+ git branch abc && test_path_is_file .git/refs/heads/abc
+'
-test_expect_success \
- 'git branch a/b/c should create a branch' \
- 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
+test_expect_success 'git branch a/b/c should create a branch' '
+ git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
+'
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+ id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+ date="1117150200 +0000"
+ msg="branch: Created from master"
+ here >expect <<-EOF
+ $_z40 $HEAD $id $date\t$msg
EOF
-test_expect_success \
- 'git branch -l d/e/f should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git branch -l d/e/f &&
+ GIT_COMMITTER_DATE="2005-05-26 23:30" git branch -l d/e/f &&
test_path_is_file .git/refs/heads/d/e/f &&
test_path_is_file .git/logs/refs/heads/d/e/f &&
- test_cmp expect .git/logs/refs/heads/d/e/f'
+ test_cmp expect .git/logs/refs/heads/d/e/f
+'
-test_expect_success \
- 'git branch -d d/e/f should delete a branch and a log' \
- 'git branch -d d/e/f &&
+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
+ quiet git branch -d d/e/f &&
test_path_is_missing .git/refs/heads/d/e/f &&
- test_path_is_missing .git/logs/refs/heads/d/e/f'
-
-test_expect_success \
- 'git branch j/k should work after branch j has been deleted' \
- 'git branch j &&
- git branch -d j &&
- git branch j/k'
-
-test_expect_success \
- 'git branch l should work after branch l/m has been deleted' \
- 'git branch l/m &&
- git branch -d l/m &&
- git branch l'
-
-test_expect_success \
- 'git branch -m dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- grep "[Uu]sage: git branch" err'
-
-test_expect_success \
- 'git branch -m m m/m should work' \
- 'git branch -l m &&
+ test_path_is_missing .git/logs/refs/heads/d/e/f
+'
+
+test_expect_success 'git branch j/k should work after branch j has been deleted' '
+ git branch j &&
+ quiet git branch -d j &&
+ git branch j/k
+'
+
+test_expect_success 'git branch l should work after branch l/m has been deleted' '
+ git branch l/m &&
+ quiet git branch -d l/m &&
+ git branch l
+'
+
+test_expect_success 'git branch -m dumps usage' '
+ test_expect_code 129 git branch -m 2>err &&
+ grep -q "[Uu]sage: git branch" err
+'
+
+test_expect_success 'git branch -m m m/m should work' '
+ git branch -l m &&
git branch -m m m/m &&
- test_path_is_file .git/logs/refs/heads/m/m'
+ test_path_is_file .git/logs/refs/heads/m/m
+'
-test_expect_success \
- 'git branch -m n/n n should work' \
- 'git branch -l n/n &&
+test_expect_success 'git branch -m n/n n should work' '
+ git branch -l n/n &&
git branch -m n/n n &&
- test_path_is_file .git/logs/refs/heads/n'
+ test_path_is_file .git/logs/refs/heads/n
+'
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
git branch o/o &&
git branch o/p &&
- test_must_fail git branch -m o/o o
+ silent test_must_fail git branch -m o/o o
'
test_expect_success 'git branch -m q r/q should fail when r exists' '
git branch q &&
git branch r &&
- test_must_fail git branch -m q r/q
+ silent test_must_fail git branch -m q r/q
'
test_expect_success 'git branch -M foo bar should fail when bar is checked out' '
git branch bar &&
- git checkout -b foo &&
- test_must_fail git branch -M bar foo
+ git checkout -q -b foo &&
+ silent test_must_fail git branch -M bar foo
'
test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '
- git checkout -b baz &&
+ git checkout -q -b baz &&
git branch bam &&
git branch -M baz bam
'
test_expect_success 'git branch -M master should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch -M master
'
test_expect_success 'git branch -M master master should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch -M master master
'
test_expect_success 'git branch -M master2 master2 should work when master is checked out' '
- git checkout master &&
+ git checkout -q master &&
git branch master2 &&
git branch -M master2 master2
'
@@ -131,7 +138,7 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch
test_expect_success 'git branch -v -d t should work' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- git branch -v -d t &&
+ quiet git branch -v -d t &&
test_path_is_missing .git/refs/heads/t
'
@@ -141,188 +148,198 @@ test_expect_success 'git branch -v -m t s should work' '
git branch -v -m t s &&
test_path_is_missing .git/refs/heads/t &&
test_path_is_file .git/refs/heads/s &&
- git branch -d s
+ quiet git branch -d s
'
test_expect_success 'git branch -m -d t s should fail' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- test_must_fail git branch -m -d t s &&
- git branch -d t &&
+ silent test_must_fail git branch -m -d t s &&
+ quiet git branch -d t &&
test_path_is_missing .git/refs/heads/t
'
test_expect_success 'git branch --list -d t should fail' '
git branch t &&
test_path_is_file .git/refs/heads/t &&
- test_must_fail git branch --list -d t &&
- git branch -d t &&
+ silent test_must_fail git branch --list -d t &&
+ quiet git branch -d t &&
test_path_is_missing .git/refs/heads/t
'
-mv .git/config .git/config-saved
-
test_expect_success 'git branch -m q q2 without config should succeed' '
+ mv .git/config .git/config-saved &&
+ test_when_finished mv .git/config-saved .git/config &&
git branch -m q q2 &&
git branch -m q2 q
'
-mv .git/config-saved .git/config
-
+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
git config branch.s/s.dummy Hello
-
-test_expect_success \
- 'git branch -m s/s s should work when s/t is deleted' \
- 'git branch -l s/s &&
+ git branch -l s/s &&
test_path_is_file .git/logs/refs/heads/s/s &&
git branch -l s/t &&
test_path_is_file .git/logs/refs/heads/s/t &&
- git branch -d s/t &&
+ quiet git branch -d s/t &&
git branch -m s/s s &&
- test_path_is_file .git/logs/refs/heads/s'
-
-test_expect_success 'config information was renamed, too' \
- "test $(git config branch.s.dummy) = Hello &&
- test_must_fail git config branch.s/s/dummy"
+ test_path_is_file .git/logs/refs/heads/s
+'
-test_expect_success 'renaming a symref is not allowed' \
+test_expect_success 'config information was renamed, too' '
+ test $(git config branch.s.dummy) = Hello &&
+ silent test_must_fail git config branch.s/s/dummy
'
+
+test_expect_success 'renaming a symref is not allowed' '
git symbolic-ref refs/heads/master2 refs/heads/master &&
- test_must_fail git branch -m master2 master3 &&
- git symbolic-ref refs/heads/master2 &&
+ silent test_must_fail git branch -m master2 master3 &&
+ quiet git symbolic-ref refs/heads/master2 &&
test_path_is_file .git/refs/heads/master &&
test_path_is_missing .git/refs/heads/master3
'
-test_expect_success SYMLINKS \
- 'git branch -m u v should fail when the reflog for u is a symlink' '
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
git branch -l u &&
mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u &&
- test_must_fail git branch -m u v
+ silent test_must_fail git branch -m u v
'
-test_expect_success 'test tracking setup via --track' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup via --track' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my1 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track my1 local/master &&
test $(git config branch.my1.remote) = local &&
- test $(git config branch.my1.merge) = refs/heads/master'
+ test $(git config branch.my1.merge) = refs/heads/master
+'
-test_expect_success 'test tracking setup (non-wildcard, matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
+test_expect_success 'test tracking setup (non-wildcard, matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch \
+ refs/heads/master:refs/remotes/local/master &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my4 local/master &&
+ quiet git branch --track my4 local/master &&
test $(git config branch.my4.remote) = local &&
- test $(git config branch.my4.merge) = refs/heads/master'
+ test $(git config branch.my4.merge) = refs/heads/master
+'
-test_expect_success 'test tracking setup (non-wildcard, not matching)' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup (non-wildcard, not matching)' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my5 local/master &&
+ quiet git branch --track my5 local/master &&
! test "$(git config branch.my5.remote)" = local &&
- ! test "$(git config branch.my5.merge)" = refs/heads/master'
+ ! test "$(git config branch.my5.merge)" = refs/heads/master
+'
-test_expect_success 'test tracking setup via config' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'test tracking setup via config' '
+ git config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch my3 local/master &&
+ quiet git branch my3 local/master &&
test $(git config branch.my3.remote) = local &&
- test $(git config branch.my3.merge) = refs/heads/master'
+ test $(git config branch.my3.merge) = refs/heads/master
+'
-test_expect_success 'test overriding tracking setup via --no-track' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'test overriding tracking setup via --no-track' '
+ git config branch.autosetupmerge true &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git branch --no-track my2 local/master &&
git config branch.autosetupmerge false &&
! test "$(git config branch.my2.remote)" = local &&
- ! test "$(git config branch.my2.merge)" = refs/heads/master'
+ ! test "$(git config branch.my2.merge)" = refs/heads/master
+'
-test_expect_success 'no tracking without .fetch entries' \
- 'git config branch.autosetupmerge true &&
+test_expect_success 'no tracking without .fetch entries' '
+ git config branch.autosetupmerge true &&
git branch my6 s &&
git config branch.automsetupmerge false &&
test -z "$(git config branch.my6.remote)" &&
- test -z "$(git config branch.my6.merge)"'
+ test -z "$(git config branch.my6.merge)"
+'
-test_expect_success 'test tracking setup via --track but deeper' \
- 'git config remote.local.url . &&
+test_expect_success 'test tracking setup via --track but deeper' '
+ git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/o/o || git fetch local) &&
- git branch --track my7 local/o/o &&
+ quiet git branch --track my7 local/o/o &&
test "$(git config branch.my7.remote)" = local &&
- test "$(git config branch.my7.merge)" = refs/heads/o/o'
+ test "$(git config branch.my7.merge)" = refs/heads/o/o
+'
-test_expect_success 'test deleting branch deletes branch config' \
- 'git branch -d my7 &&
+test_expect_success 'test deleting branch deletes branch config' '
+ quiet git branch -d my7 &&
test -z "$(git config branch.my7.remote)" &&
- test -z "$(git config branch.my7.merge)"'
+ test -z "$(git config branch.my7.merge)"
+'
-test_expect_success 'test deleting branch without config' \
- 'git branch my7 s &&
+test_expect_success 'test deleting branch without config' '
+ git branch my7 s &&
sha1=$(git rev-parse my7 | cut -c 1-7) &&
echo "Deleted branch my7 (was $sha1)." >expect &&
git branch -d my7 >actual 2>&1 &&
- test_i18ncmp expect actual'
+ test_i18ncmp expect actual
+'
-test_expect_success 'test --track without .fetch entries' \
- 'git branch --track my8 &&
+test_expect_success 'test --track without .fetch entries' '
+ quiet git branch --track my8 &&
test "$(git config branch.my8.remote)" &&
- test "$(git config branch.my8.merge)"'
+ test "$(git config branch.my8.merge)"
+'
-test_expect_success \
- 'branch from non-branch HEAD w/autosetupmerge=always' \
- 'git config branch.autosetupmerge always &&
+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
+ git config branch.autosetupmerge always &&
git branch my9 HEAD^ &&
- git config branch.autosetupmerge false'
+ git config branch.autosetupmerge false
+'
-test_expect_success \
- 'branch from non-branch HEAD w/--track causes failure' \
- 'test_must_fail git branch --track my10 HEAD^'
+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
+ silent test_must_fail git branch --track my10 HEAD^
+'
-test_expect_success \
- 'branch from tag w/--track causes failure' \
- 'git tag foobar &&
- test_must_fail git branch --track my11 foobar'
+test_expect_success 'branch from tag w/--track causes failure' '
+ git tag foobar &&
+ silent test_must_fail git branch --track my11 foobar
+'
# Keep this test last, as it changes the current branch
-cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
+ id="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+ date="1117150200 +0000"
+ msg="branch: Created from master"
+ here >expect <<-EOF
+ $_z40 $HEAD $id $date\t$msg
EOF
-test_expect_success \
- 'git checkout -b g/h/i -l should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git checkout -b g/h/i -l master &&
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git checkout -q -b g/h/i -l master &&
test_path_is_file .git/refs/heads/g/h/i &&
test_path_is_file .git/logs/refs/heads/g/h/i &&
- test_cmp expect .git/logs/refs/heads/g/h/i'
+ test_cmp expect .git/logs/refs/heads/g/h/i
+'
test_expect_success 'checkout -b makes reflog by default' '
- git checkout master &&
+ git checkout -q master &&
git config --unset core.logAllRefUpdates &&
- git checkout -b alpha &&
- git rev-parse --verify alpha@{0}
+ git checkout -q -b alpha &&
+ quiet git rev-parse --verify alpha@{0}
'
test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
- git checkout master &&
+ git checkout -q master &&
git config core.logAllRefUpdates false &&
- git checkout -b beta &&
- test_must_fail git rev-parse --verify beta@{0}
+ git checkout -q -b beta &&
+ silent test_must_fail git rev-parse --verify beta@{0}
'
test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
- git checkout master &&
- git checkout -lb gamma &&
+ git checkout -q master &&
+ git checkout -q -lb gamma &&
git config --unset core.logAllRefUpdates &&
- git rev-parse --verify gamma@{0}
+ quiet git rev-parse --verify gamma@{0}
'
test_expect_success 'avoid ambiguous track' '
@@ -331,7 +348,7 @@ test_expect_success 'avoid ambiguous track' '
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
git config remote.ambi2.url lilili &&
git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
- git branch all1 master &&
+ silent git branch all1 master &&
test -z "$(git config branch.all1.merge)"
'
@@ -339,9 +356,9 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase local &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase &&
- git branch --track myr1 mybase &&
+ quiet git branch --track myr1 mybase &&
test "$(git config branch.myr1.remote)" = . &&
test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
test "$(git config branch.myr1.rebase)" = true
@@ -351,9 +368,9 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase always &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase2 &&
- git branch --track myr2 mybase &&
+ quiet git branch --track myr2 mybase &&
test "$(git config branch.myr2.remote)" = . &&
test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
test "$(git config branch.myr2.rebase)" = true
@@ -363,9 +380,9 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase3 &&
- git branch --track myr3 mybase2 &&
+ quiet git branch --track myr3 mybase2 &&
test "$(git config branch.myr3.remote)" = . &&
test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
! test "$(git config branch.myr3.rebase)" = true
@@ -375,9 +392,9 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase never &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase4 &&
- git branch --track myr4 mybase2 &&
+ quiet git branch --track myr4 mybase2 &&
test "$(git config branch.myr4.remote)" = . &&
test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
! test "$(git config branch.myr4.rebase)" = true
@@ -387,8 +404,8 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase local &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr5 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr5 local/master &&
test "$(git config branch.myr5.remote)" = local &&
test "$(git config branch.myr5.merge)" = refs/heads/master &&
! test "$(git config branch.myr5.rebase)" = true
@@ -398,8 +415,8 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase never &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr6 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr6 local/master &&
test "$(git config branch.myr6.remote)" = local &&
test "$(git config branch.myr6.merge)" = refs/heads/master &&
! test "$(git config branch.myr6.rebase)" = true
@@ -409,8 +426,8 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr7 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr7 local/master &&
test "$(git config branch.myr7.remote)" = local &&
test "$(git config branch.myr7.merge)" = refs/heads/master &&
test "$(git config branch.myr7.rebase)" = true
@@ -420,8 +437,8 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
git config branch.autosetuprebase remote &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr8 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr8 local/master &&
test "$(git config branch.myr8.remote)" = local &&
test "$(git config branch.myr8.merge)" = refs/heads/master &&
test "$(git config branch.myr8.rebase)" = true
@@ -431,8 +448,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
git config --unset branch.autosetuprebase &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track myr9 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --track myr9 local/master &&
test "$(git config branch.myr9.remote)" = local &&
test "$(git config branch.myr9.merge)" = refs/heads/master &&
test "z$(git config branch.myr9.rebase)" = z
@@ -441,9 +458,9 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/o || git fetch local) &&
+ (git show-ref -q refs/remotes/local/o || git fetch -q local) &&
git branch mybase10 &&
- git branch --track myr10 mybase2 &&
+ quiet git branch --track myr10 mybase2 &&
test "$(git config branch.myr10.remote)" = . &&
test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
test "z$(git config branch.myr10.rebase)" = z
@@ -452,8 +469,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr11 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr11 mybase2 &&
test "z$(git config branch.myr11.remote)" = z &&
test "z$(git config branch.myr11.merge)" = z &&
test "z$(git config branch.myr11.rebase)" = z
@@ -462,8 +479,8 @@ test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr12 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr12 local/master &&
test "z$(git config branch.myr12.remote)" = z &&
test "z$(git config branch.myr12.merge)" = z &&
test "z$(git config branch.myr12.rebase)" = z
@@ -473,8 +490,8 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '
git config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr13 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr13 mybase2 &&
test "z$(git config branch.myr13.remote)" = z &&
test "z$(git config branch.myr13.merge)" = z &&
test "z$(git config branch.myr13.rebase)" = z
@@ -484,8 +501,8 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '
git config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr14 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr14 mybase2 &&
test "z$(git config branch.myr14.remote)" = z &&
test "z$(git config branch.myr14.merge)" = z &&
test "z$(git config branch.myr14.rebase)" = z
@@ -495,8 +512,8 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '
git config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr15 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr15 mybase2 &&
test "z$(git config branch.myr15.remote)" = z &&
test "z$(git config branch.myr15.merge)" = z &&
test "z$(git config branch.myr15.rebase)" = z
@@ -506,8 +523,8 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '
git config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr16 mybase2 &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr16 mybase2 &&
test "z$(git config branch.myr16.remote)" = z &&
test "z$(git config branch.myr16.merge)" = z &&
test "z$(git config branch.myr16.rebase)" = z
@@ -517,8 +534,8 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '
git config branch.autosetuprebase never &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr17 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr17 local/master &&
test "z$(git config branch.myr17.remote)" = z &&
test "z$(git config branch.myr17.merge)" = z &&
test "z$(git config branch.myr17.rebase)" = z
@@ -528,8 +545,8 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '
git config branch.autosetuprebase local &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr18 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr18 local/master &&
test "z$(git config branch.myr18.remote)" = z &&
test "z$(git config branch.myr18.merge)" = z &&
test "z$(git config branch.myr18.rebase)" = z
@@ -539,8 +556,8 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '
git config branch.autosetuprebase remote &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr19 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr19 local/master &&
test "z$(git config branch.myr19.remote)" = z &&
test "z$(git config branch.myr19.merge)" = z &&
test "z$(git config branch.myr19.rebase)" = z
@@ -550,8 +567,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
git config branch.autosetuprebase always &&
git config remote.local.url . &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track myr20 local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch -q local) &&
+ quiet git branch --no-track myr20 local/master &&
test "z$(git config branch.myr20.remote)" = z &&
test "z$(git config branch.myr20.merge)" = z &&
test "z$(git config branch.myr20.rebase)" = z
@@ -559,8 +576,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
test_expect_success 'autosetuprebase always on detached HEAD' '
git config branch.autosetupmerge always &&
- test_when_finished git checkout master &&
- git checkout HEAD^0 &&
+ test_when_finished git checkout -q master &&
+ git checkout -q HEAD^0 &&
git branch my11 &&
test -z "$(git config branch.my11.remote)" &&
test -z "$(git config branch.my11.merge)"
@@ -568,20 +585,20 @@ test_expect_success 'autosetuprebase always on detached HEAD' '
test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
git config branch.autosetuprebase garbage &&
- test_must_fail git branch
+ silent test_must_fail git branch
'
test_expect_success 'detect misconfigured autosetuprebase (no value)' '
git config --unset branch.autosetuprebase &&
echo "[branch] autosetuprebase" >> .git/config &&
- test_must_fail git branch &&
+ silent test_must_fail git branch &&
git config --unset branch.autosetuprebase
'
test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
- git checkout my9 &&
+ git checkout -q my9 &&
git config --unset branch.my8.merge &&
- test_must_fail git branch -d my8
+ silent test_must_fail git branch -d my8
'
test_expect_success 'attempt to delete a branch merged to its base' '
@@ -589,32 +606,30 @@ test_expect_success 'attempt to delete a branch merged to its base' '
# we would not have allowed deleting my8 that is not merged
# to my9, but it is set to track master that already has my8
git config branch.my8.merge refs/heads/master &&
- git branch -d my8
+ silent git branch -d my8
'
test_expect_success 'attempt to delete a branch merged to its base' '
- git checkout master &&
+ git checkout -q master &&
echo Third >>A &&
- git commit -m "Third commit" A &&
- git branch -t my10 my9 &&
- git branch -f my10 HEAD^ &&
+ git commit -q -m "Third commit" A &&
+ quiet git branch -t my10 my9 &&
+ quiet git branch -f my10 HEAD^ &&
# we are on master which is at the third commit, and my10
# is behind us, so traditionally we would have allowed deleting
# it; but my10 is set to track my9 that is further behind.
- test_must_fail git branch -d my10
+ silent test_must_fail git branch -d my10
'
test_expect_success 'use set-upstream on the current branch' '
- git checkout master &&
- git --bare init myupstream.git &&
- git push myupstream.git master:refs/heads/frotz &&
+ git checkout -q master &&
+ git --bare init -q myupstream.git &&
+ git push -q myupstream.git master:refs/heads/frotz &&
git remote add origin myupstream.git &&
- git fetch &&
- git branch --set-upstream master origin/frotz &&
-
+ git fetch -q &&
+ quiet git branch --set-upstream master origin/frotz &&
test "z$(git config branch.master.remote)" = "zorigin" &&
test "z$(git config branch.master.merge)" = "zrefs/heads/frotz"
-
'
test_expect_success 'use --edit-description' '
@@ -637,7 +652,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
(
EDITOR=./editor &&
export EDITOR &&
- test_must_fail git branch --edit-description no-such-branch
+ silent test_must_fail git branch --edit-description no-such-branch
)
'
@@ -645,11 +660,11 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
write_script editor <<-\EOF &&
echo "New contents" >"$1"
EOF
- git checkout --orphan unborn &&
+ git checkout -q --orphan unborn &&
(
EDITOR=./editor &&
export EDITOR &&
- test_must_fail git branch --edit-description
+ silent test_must_fail git branch --edit-description
)
'
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH-w 104/105] t0040 (parse-options): modernize style
2012-02-23 0:22 ` Tom Grennan
` (9 preceding siblings ...)
2012-03-01 1:45 ` [PATCH-w 103/105] t3200 (branch): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
2012-03-01 1:45 ` [PATCH-w 105/105] t7004 (tag): " Tom Grennan
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t0040-parse-options.sh | 283 +++++++++++++++++++++-------------------------
1 files changed, 127 insertions(+), 156 deletions(-)
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index a1e4616..6416d77 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -5,55 +5,60 @@
test_description='our own option parser'
-. ./test-lib.sh
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
-cat > expect << EOF
-usage: test-parse-options <options>
-
- -b, --boolean get a boolean
- -4, --or4 bitwise-or boolean with ...0100
- --neg-or4 same as --no-or4
-
- -i, --integer <n> get a integer
- -j <n> get a integer, too
- --set23 set integer to 23
- -t <time> get timestamp of <time>
- -L, --length <str> get length of <str>
- -F, --file <file> set file to <file>
-
-String options
- -s, --string <string>
- get a string
- --string2 <str> get another string
- --st <st> get another string (pervert ordering)
- -o <str> get another string
- --default-string set string to default
- --list <str> add str to list
-
-Magic arguments
- --quux means --quux
- -NUM set integer to NUM
- + same as -b
- --ambiguous positive ambiguity
- --no-ambiguous negative ambiguity
-
-Standard options
- --abbrev[=<n>] use <n> digits to display SHA-1s
- -v, --verbose be verbose
- -n, --dry-run dry run
- -q, --quiet be quiet
+. ./test-lib.sh
-EOF
+silent () { "$@" >/dev/null 2>&1; }
test_expect_success 'test help' '
- test_must_fail test-parse-options -h > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
-'
+ sed -e "s/^|//" >expect <<-\EOF &&
+ |usage: test-parse-options <options>
+
+ | -b, --boolean get a boolean
+ | -4, --or4 bitwise-or boolean with ...0100
+ | --neg-or4 same as --no-or4
+
+ | -i, --integer <n> get a integer
+ | -j <n> get a integer, too
+ | --set23 set integer to 23
+ | -t <time> get timestamp of <time>
+ | -L, --length <str> get length of <str>
+ | -F, --file <file> set file to <file>
+
+ |String options
+ | -s, --string <string>
+ | get a string
+ | --string2 <str> get another string
+ | --st <st> get another string (pervert ordering)
+ | -o <str> get another string
+ | --default-string set string to default
+ | --list <str> add str to list
+
+ |Magic arguments
+ | --quux means --quux
+ | -NUM set integer to NUM
+ | + same as -b
+ | --ambiguous positive ambiguity
+ | --no-ambiguous negative ambiguity
+
+ |Standard options
+ | --abbrev[=<n>] use <n> digits to display SHA-1s
+ | -v, --verbose be verbose
+ | -n, --dry-run dry run
+ | -q, --quiet be quiet
-mv expect expect.err
+ EOF
+ cp expect expect.err
+ test_must_fail test-parse-options -h 2>err | test_cmp expect - &&
+ test ! -s err
+'
-cat > expect << EOF
+test_expect_success 'short options' '
+ cat >expect <<-\EOF &&
boolean: 2
integer: 1729
timestamp: 0
@@ -64,15 +69,13 @@ quiet: no
dry run: yes
file: prefix/my.file
EOF
-
-test_expect_success 'short options' '
- test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \
- > output 2> output.err &&
- test_cmp expect output &&
- test ! -s output.err
+ test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file 2>err |
+ test_cmp expect - &&
+ test ! -s err
'
-cat > expect << EOF
+test_expect_success 'long options' '
+ cat >expect <<-\EOF &&
boolean: 2
integer: 1729
timestamp: 0
@@ -83,25 +86,20 @@ quiet: no
dry run: no
file: prefix/fi.le
EOF
-
-test_expect_success 'long options' '
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\
- --obsolete > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ --obsolete 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'missing required value' '
- test-parse-options -s;
- test $? = 129 &&
- test-parse-options --string;
- test $? = 129 &&
- test-parse-options --file;
- test $? = 129
+ silent test_expect_code 129 test-parse-options -s &&
+ silent test_expect_code 129 test-parse-options --string &&
+ silent test_expect_code 129 test-parse-options --file
'
-cat > expect << EOF
+test_expect_success 'intermingled arguments' '
+ cat >expect <<-\EOF &&
boolean: 1
integer: 13
timestamp: 0
@@ -115,15 +113,13 @@ arg 00: a1
arg 01: b1
arg 02: --boolean
EOF
-
-test_expect_success 'intermingled arguments' '
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
- > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect << EOF
+test_expect_success 'unambiguously abbreviated option' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 2
timestamp: 0
@@ -134,25 +130,22 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'unambiguously abbreviated option' '
- test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --int 2 --boolean --no-bo 2>err |
+ test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'unambiguously abbreviated option with "="' '
- test-parse-options --int=2 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --int=2 2>err | test_cmp expect -&&
+ test ! -s err
'
test_expect_success 'ambiguously abbreviated option' '
- test-parse-options --strin 123;
- test $? = 129
+ silent test_expect_code 129 test-parse-options --strin 123
'
-cat > expect << EOF
+test_expect_success 'non ambiguous option (after two options it abbreviates)' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -163,24 +156,21 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'non ambiguous option (after two options it abbreviates)' '
- test-parse-options --st 123 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --st 123 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > typo.err << EOF
-error: did you mean \`--boolean\` (with two dashes ?)
-EOF
-
test_expect_success 'detect possible typos' '
- test_must_fail test-parse-options -boolean > output 2> output.err &&
- test ! -s output &&
- test_cmp typo.err output.err
+ cat >typo.err <<-\EOF &&
+ error: did you mean `--boolean` (with two dashes ?)
+ EOF
+ >expect
+ test_must_fail test-parse-options -boolean 2>err | test_cmp expect - &&
+ test_cmp typo.err err
'
-cat > expect <<EOF
+test_expect_success 'keep some options as arguments' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -192,14 +182,12 @@ dry run: no
file: (not set)
arg 00: --quux
EOF
-
-test_expect_success 'keep some options as arguments' '
- test-parse-options --quux > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --quux 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
+test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 1
@@ -211,15 +199,13 @@ dry run: no
file: (not set)
arg 00: foo
EOF
-
-test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
- foo -q > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options -t "1970-01-01 00:00:01 +0000" \
+ --default-string foo -q 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
+test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
+ cat >expect <<-\EOF &&
Callback: "four", 0
boolean: 5
integer: 4
@@ -231,24 +217,21 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
- test-parse-options --length=four -b -4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --length=four -b -4 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
+test_expect_success 'OPT_CALLBACK() and callback errors work' '
+ cat >expect <<-\EOF &&
Callback: "not set", 1
EOF
-
-test_expect_success 'OPT_CALLBACK() and callback errors work' '
- test_must_fail test-parse-options --no-length > output 2> output.err &&
- test_cmp expect output &&
- test_cmp expect.err output.err
+ test_must_fail test-parse-options --no-length 2>err |
+ test_cmp expect - &&
+ test_cmp expect.err err
'
-cat > expect <<EOF
+test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
+ cat >expect <<-\EOF &&
boolean: 1
integer: 23
timestamp: 0
@@ -259,20 +242,17 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --set23 -bbbbb --no-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --set23 -bbbbb --neg-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
+test_expect_success 'OPT_BIT() works' '
+ cat >expect <<-\EOF &&
boolean: 6
integer: 0
timestamp: 0
@@ -283,26 +263,23 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_BIT() works' '
- test-parse-options -bb --or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options -bb --or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_NEGBIT() works' '
- test-parse-options -bb --no-neg-or4 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options -bb --no-neg-or4 2>err | test_cmp expect - &&
+ test ! -s err
'
test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '
- test-parse-options + + + + + + > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options + + + + + + 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat > expect <<EOF
+
+test_expect_success 'OPT_NUMBER_CALLBACK() works' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 12345
timestamp: 0
@@ -313,14 +290,12 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'OPT_NUMBER_CALLBACK() works' '
- test-parse-options -12345 > output 2> output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options -12345 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat >expect <<EOF
+test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
+ cat >expect <<-\EOF &&
boolean: 0
integer: 0
timestamp: 0
@@ -331,27 +306,23 @@ quiet: no
dry run: no
file: (not set)
EOF
-
-test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
- test-parse-options --no-ambig >output 2>output.err &&
- test ! -s output.err &&
- test_cmp expect output
+ test-parse-options --no-ambig 2>err | test_cmp expect - &&
+ test ! -s err
'
-cat >>expect <<'EOF'
+test_expect_success '--list keeps list of strings' '
+ cat >>expect <<-\EOF &&
list: foo
list: bar
list: baz
EOF
-test_expect_success '--list keeps list of strings' '
- test-parse-options --list foo --list=bar --list=baz >output &&
- test_cmp expect output
+ test-parse-options --list foo --list=bar --list=baz | test_cmp expect -
'
test_expect_success '--no-list resets list' '
- test-parse-options --list=other --list=irrelevant --list=options \
- --no-list --list=foo --list=bar --list=baz >output &&
- test_cmp expect output
+ test-parse-options --list=other --list=irrelevant \
+ --list=options --no-list --list=foo --list=bar --list=baz |
+ test_cmp expect -
'
test_done
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread
* [PATCH-w 105/105] t7004 (tag): modernize style
2012-02-23 0:22 ` Tom Grennan
` (10 preceding siblings ...)
2012-03-01 1:45 ` [PATCH-w 104/105] t0040 (parse-options): " Tom Grennan
@ 2012-03-01 1:45 ` Tom Grennan
11 siblings, 0 replies; 83+ messages in thread
From: Tom Grennan @ 2012-03-01 1:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Carlos Rica, Andy Parkins, Shawn O. Pearce,
Amos Waterland, Johannes Schindelin
- Guard setup with test_expect_success
- Single-quoted, tab prefaced test blocks of < 80 cols
- Redirect unwanted output
- Use a "here" filter for expect generation
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t7004-tag.sh | 1400 ++++++++++++++++++++++++++------------------------------
1 files changed, 643 insertions(+), 757 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f8c247a..6704046 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -7,15 +7,37 @@ test_description='git tag
Tests for operations with tags.'
+if ! test -r test-lib.sh ; then
+ (cd ${0%/*} && ./${0##*/} $@)
+ exit $?
+fi
+
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
-# creating and listing lightweight tags:
+quiet () { "$@" >/dev/null; }
+silent () { "$@" >/dev/null 2>&1; }
+here () { sed 's/\\s/ /g; s/\\t/\t/g; s/\\n/\n/g' $@; }
tag_exists () {
git show-ref --quiet --verify refs/tags/"$1"
}
+gen_header () { # name, object, type, time
+ cat <<-EOF &&
+ object $2
+ type $3
+ tag $1
+ tagger C O Mitter <committer@example.com> $4 -0700
+
+ EOF
+ here
+}
+
+get_header () {
+ git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
+}
+
# todo: git tag -l now returns always zero, when fixed, change this test
test_expect_success 'listing all tags in an empty tree should succeed' '
git tag -l &&
@@ -27,36 +49,38 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git tag | wc -l` -eq 0
'
-test_expect_success 'looking for a tag in an empty tree should fail' \
- '! (tag_exists mytag)'
+test_expect_success 'looking for a tag in an empty tree should fail' '
+ ! tag_exists mytag
+'
test_expect_success 'creating a tag in an empty tree should fail' '
- test_must_fail git tag mynotag &&
+ silent test_must_fail git tag mynotag &&
! tag_exists mynotag
'
test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
- test_must_fail git tag mytaghead HEAD &&
+ silent test_must_fail git tag mytaghead HEAD &&
! tag_exists mytaghead
'
test_expect_success 'creating a tag for an unknown revision should fail' '
- test_must_fail git tag mytagnorev aaaaaaaaaaa &&
+ silent test_must_fail git tag mytagnorev aaaaaaaaaaa &&
! tag_exists mytagnorev
'
-# commit used in the tests, test_tick is also called here to freeze the date:
test_expect_success 'creating a tag using default HEAD should succeed' '
+ # commit used in the tests
+ # test_tick is also called here to freeze the date:
test_tick &&
- echo foo >foo &&
+ echo >foo foo &&
git add foo &&
- git commit -m Foo &&
+ git commit -q -m Foo &&
git tag mytag
'
test_expect_success 'listing all tags if one exists should succeed' '
- git tag -l &&
- git tag
+ quiet git tag -l &&
+ quiet git tag
'
test_expect_success 'listing all tags if one exists should output that tag' '
@@ -66,36 +90,36 @@ test_expect_success 'listing all tags if one exists should output that tag' '
# pattern matching:
-test_expect_success 'listing a tag using a matching pattern should succeed' \
- 'git tag -l mytag'
+test_expect_success 'listing a tag using a matching pattern should succeed' '
+ quiet git tag -l mytag
+'
-test_expect_success \
- 'listing a tag using a matching pattern should output that tag' \
- 'test `git tag -l mytag` = mytag'
+test_expect_success 'listing a tag using a matching pattern should output that tag' '
+ test `git tag -l mytag` = mytag
+'
# todo: git tag -l now returns always zero, when fixed, change this test
-test_expect_success \
- 'listing tags using a non-matching pattern should suceed' \
- 'git tag -l xxx'
+test_expect_success 'listing tags using a non-matching pattern should suceed' '
+ git tag -l xxx
+'
-test_expect_success \
- 'listing tags using a non-matching pattern should output nothing' \
- 'test `git tag -l xxx | wc -l` -eq 0'
+test_expect_success 'listing tags using a non-matching pattern should output nothing' '
+ test `git tag -l xxx | wc -l` -eq 0
+'
# special cases for creating tags:
-test_expect_success \
- 'trying to create a tag with the name of one existing should fail' \
- 'test_must_fail git tag mytag'
+test_expect_success 'trying to create a tag with the name of one existing should fail' '
+ silent test_must_fail git tag mytag
+'
-test_expect_success \
- 'trying to create a tag with a non-valid name should fail' '
+test_expect_success 'trying to create a tag with a non-valid name should fail' '
test `git tag -l | wc -l` -eq 1 &&
- test_must_fail git tag "" &&
- test_must_fail git tag .othertag &&
- test_must_fail git tag "other tag" &&
- test_must_fail git tag "othertag^" &&
- test_must_fail git tag "other~tag" &&
+ silent test_must_fail git tag "" &&
+ silent test_must_fail git tag .othertag &&
+ silent test_must_fail git tag "other tag" &&
+ silent test_must_fail git tag "othertag^" &&
+ silent test_must_fail git tag "other~tag" &&
test `git tag -l | wc -l` -eq 1
'
@@ -108,51 +132,49 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
test_expect_success 'trying to delete an unknown tag should fail' '
! tag_exists unknown-tag &&
- test_must_fail git tag -d unknown-tag
+ silent test_must_fail git tag -d unknown-tag
'
-cat >expect <<EOF
+test_expect_success 'trying to delete tags without params should succeed and do nothing' '
+ cat >expect <<-EOF &&
myhead
mytag
EOF
-test_expect_success \
- 'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && test_cmp expect actual &&
+ git tag -l | test_cmp expect - &&
git tag -d &&
- git tag -l > actual && test_cmp expect actual
+ git tag -l | test_cmp expect -
'
-test_expect_success \
- 'deleting two existing tags in one command should succeed' '
+test_expect_success 'deleting two existing tags in one command should succeed' '
tag_exists mytag &&
tag_exists myhead &&
- git tag -d mytag myhead &&
+ quiet git tag -d mytag myhead &&
! tag_exists mytag &&
! tag_exists myhead
'
-test_expect_success \
- 'creating a tag with the name of another deleted one should succeed' '
+test_expect_success 'creating a tag with the name of another deleted one should succeed' '
! tag_exists mytag &&
git tag mytag &&
tag_exists mytag
'
-test_expect_success \
- 'trying to delete two tags, existing and not, should fail in the 2nd' '
+test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' '
tag_exists mytag &&
! tag_exists myhead &&
- test_must_fail git tag -d mytag anothertag &&
+ silent test_must_fail git tag -d mytag anothertag &&
! tag_exists mytag &&
! tag_exists myhead
'
-test_expect_success 'trying to delete an already deleted tag should fail' \
- 'test_must_fail git tag -d mytag'
+test_expect_success 'trying to delete an already deleted tag should fail' '
+ silent test_must_fail git tag -d mytag
+'
# listing various tags with pattern matching:
-cat >expect <<EOF
+test_expect_success 'listing all tags should print them ordered' '
+ cat >expect <<-EOF &&
a1
aa1
cba
@@ -163,7 +185,6 @@ v1.0
v1.0.1
v1.1.3
EOF
-test_expect_success 'listing all tags should print them ordered' '
git tag v1.0.1 &&
git tag t211 &&
git tag aa1 &&
@@ -173,217 +194,189 @@ test_expect_success 'listing all tags should print them ordered' '
git tag a1 &&
git tag v1.0 &&
git tag t210 &&
- git tag -l > actual &&
- test_cmp expect actual &&
- git tag > actual &&
- test_cmp expect actual
+ git tag -l | test_cmp expect - &&
+ git tag | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags with substring as pattern must print those matching' '
+ cat >expect <<-EOF &&
a1
aa1
cba
EOF
-test_expect_success \
- 'listing tags with substring as pattern must print those matching' '
- rm *a* &&
- git tag -l "*a*" > current &&
- test_cmp expect current
+ git tag -l "*a*" | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags with a suffix as pattern must print those matching' '
+ cat >expect <<-EOF &&
v0.2.1
v1.0.1
EOF
-test_expect_success \
- 'listing tags with a suffix as pattern must print those matching' '
- git tag -l "*.1" > actual &&
- test_cmp expect actual
+ git tag -l "*.1" | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags with a prefix as pattern must print those matching' '
+ cat >expect <<-EOF &&
t210
t211
EOF
-test_expect_success \
- 'listing tags with a prefix as pattern must print those matching' '
- git tag -l "t21*" > actual &&
- test_cmp expect actual
+ git tag -l "t21*" | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
a1
EOF
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
- git tag -l a1 > actual &&
- test_cmp expect actual
+ git tag -l a1 | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-EOF &&
v1.0
EOF
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
- git tag -l v1.0 > actual &&
- test_cmp expect actual
+ git tag -l v1.0 | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags with ? in the pattern should print those matching' '
+ cat >expect <<-EOF &&
v1.0.1
v1.1.3
EOF
-test_expect_success \
- 'listing tags with ? in the pattern should print those matching' '
- git tag -l "v1.?.?" > actual &&
- test_cmp expect actual
+ git tag -l "v1.?.?" | test_cmp expect -
'
->expect
-test_expect_success \
- 'listing tags using v.* should print nothing because none have v.' '
- git tag -l "v.*" > actual &&
- test_cmp expect actual
+test_expect_success 'listing tags using v.* should print nothing because none have v.' '
+ >expect &&
+ git tag -l "v.*" | test_cmp expect -
'
-cat >expect <<EOF
+test_expect_success 'listing tags using v* should print only those having v' '
+ cat >expect <<-EOF &&
v0.2.1
v1.0
v1.0.1
v1.1.3
EOF
-test_expect_success \
- 'listing tags using v* should print only those having v' '
- git tag -l "v*" > actual &&
- test_cmp expect actual
+ git tag -l "v*" | test_cmp expect -
'
test_expect_success 'tag -l can accept multiple patterns' '
- git tag -l "v1*" "v0*" >actual &&
- test_cmp expect actual
+ git tag -l "v1*" "v0*" | test_cmp expect -
'
# creating and verifying lightweight tags:
-test_expect_success \
- 'a non-annotated tag created without parameters should point to HEAD' '
+test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '
git tag non-annotated-tag &&
test $(git cat-file -t non-annotated-tag) = commit &&
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_success 'trying to verify an unknown tag should fail' \
- 'test_must_fail git tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' '
+ silent test_must_fail git tag -v unknown-tag
+'
-test_expect_success \
- 'trying to verify a non-annotated and non-signed tag should fail' \
- 'test_must_fail git tag -v non-annotated-tag'
+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' '
+ silent test_must_fail git tag -v non-annotated-tag
+'
-test_expect_success \
- 'trying to verify many non-annotated or unknown tags, should fail' \
- 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' '
+ silent test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2
+'
# creating annotated tags:
-get_tag_msg () {
- git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
-}
-
-# run test_tick before committing always gives the time in that timezone
-get_tag_header () {
-cat <<EOF
-object $2
-type $3
-tag $1
-tagger C O Mitter <committer@example.com> $4 -0700
-
+test_expect_success 'creating an annotated tag with -m message should succeed' '
+ commit=$(git rev-parse HEAD) &&
+ time=$test_tick &&
+ name="annotated-tag" &&
+ msg="A message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
EOF
-}
-
-commit=$(git rev-parse HEAD)
-time=$test_tick
-
-get_tag_header annotated-tag $commit commit $time >expect
-echo "A message" >>expect
-test_expect_success \
- 'creating an annotated tag with -m message should succeed' '
- git tag -m "A message" annotated-tag &&
- get_tag_msg annotated-tag >actual &&
- test_cmp expect actual
+ git tag -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
-cat >msgfile <<EOF
+test_expect_success 'creating an annotated tag with -F messagefile should succeed' '
+ name="file-annotated-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
Another message
in a file.
EOF
-get_tag_header file-annotated-tag $commit commit $time >expect
-cat msgfile >>expect
-test_expect_success \
- 'creating an annotated tag with -F messagefile should succeed' '
- git tag -F msgfile file-annotated-tag &&
- get_tag_msg file-annotated-tag >actual &&
- test_cmp expect actual
+ tail -n 2 expect >msgfile &&
+ git tag -F msgfile $name &&
+ get_header $name | test_cmp expect -
'
-cat >inputmsg <<EOF
+test_expect_success 'creating an annotated tag with -F - should succeed' '
+ name="stdin-annotated-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
A message from the
standard input
EOF
-get_tag_header stdin-annotated-tag $commit commit $time >expect
-cat inputmsg >>expect
-test_expect_success 'creating an annotated tag with -F - should succeed' '
- git tag -F - stdin-annotated-tag <inputmsg &&
- get_tag_msg stdin-annotated-tag >actual &&
- test_cmp expect actual
+ tail -n 2 expect | git tag -F - $name &&
+ get_header $name | test_cmp expect -
'
-test_expect_success \
- 'trying to create a tag with a non-existing -F file should fail' '
+test_expect_success 'trying to create a tag with a non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists notag &&
- test_must_fail git tag -F nonexistingfile notag &&
+ silent test_must_fail git tag -F nonexistingfile notag &&
! tag_exists notag
'
-test_expect_success \
- 'trying to create tags giving both -m or -F options should fail' '
- echo "message file 1" >msgfile1 &&
- echo "message file 2" >msgfile2 &&
+test_expect_success 'trying to create tags giving both -m or -F options should fail' '
+ echo >msgfile1 "message file 1" &&
+ echo >msgfile2 "message file 2" &&
! tag_exists msgtag &&
- test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
+ silent test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
! tag_exists msgtag &&
- test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
+ silent test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
! tag_exists msgtag &&
- test_must_fail git tag -m "message 1" -F msgfile1 \
+ silent test_must_fail git tag -m "message 1" -F msgfile1 \
-m "message 2" msgtag &&
! tag_exists msgtag
'
# blank and empty messages:
-get_tag_header empty-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with an empty -m message should succeed' '
- git tag -m "" empty-annotated-tag &&
- get_tag_msg empty-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with an empty -m message should succeed' '
+ name="empty-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -m "" $name &&
+ get_header $name | test_cmp expect -
'
->emptyfile
-get_tag_header emptyfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with an empty -F messagefile should succeed' '
- git tag -F emptyfile emptyfile-annotated-tag &&
- get_tag_msg emptyfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with an empty -F messagefile should succeed' '
+ >emptyfile &&
+ name="emptyfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F emptyfile $name &&
+ get_header $name | test_cmp expect -
'
-printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
-printf '\n\n\nTrailing spaces \t \n' >>blanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
-get_tag_header blanks-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
+test_expect_success 'extra blanks in the message for an annotated tag should be removed' '
+ here >blanksfile <<-\EOF &&
+
+ \s\s
+ \t
+ Leading blank lines
+
+ \t\s\t\s\s
+ Repeated blank lines
+
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ name="blanks-annotated-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
Leading blank lines
Repeated blank lines
@@ -392,44 +385,41 @@ Trailing spaces
Trailing blank lines
EOF
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
- git tag -F blanksfile blanks-annotated-tag &&
- get_tag_msg blanks-annotated-tag >actual &&
- test_cmp expect actual
+ git tag -F blanksfile $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header blank-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with blank -m message with spaces should succeed' '
- git tag -m " " blank-annotated-tag &&
- get_tag_msg blank-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with blank -m message with spaces should succeed' '
+ name="blank-annotated-tag" &&
+ gen_header $name $commit commit $time </dev/null >expect &&
+ git tag -m " " $name &&
+ get_header $name | test_cmp expect -
'
-echo ' ' >blankfile
-echo '' >>blankfile
-echo ' ' >>blankfile
-get_tag_header blankfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with blank -F messagefile with spaces should succeed' '
- git tag -F blankfile blankfile-annotated-tag &&
- get_tag_msg blankfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' '
+ here >blankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ name="blankfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F blankfile $name &&
+ get_header $name | test_cmp expect -
'
-printf ' ' >blanknonlfile
-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with -F file of spaces and no newline should succeed' '
- git tag -F blanknonlfile blanknonlfile-annotated-tag &&
- get_tag_msg blanknonlfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' '
+ printf >blanknonlfile " " &&
+ name="blanknonlfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F blanknonlfile $name &&
+ get_header $name | test_cmp expect -
'
# messages with commented lines:
-cat >commentsfile <<EOF
+test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' '
+ cat >commentsfile <<-EOF &&
# A comment
############
@@ -446,8 +436,8 @@ Another line.
Last line.
EOF
-get_tag_header comments-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
+ name="comments-annotated-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
The message.
One line.
@@ -455,279 +445,235 @@ Another line.
Last line.
EOF
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
- git tag -F commentsfile comments-annotated-tag &&
- get_tag_msg comments-annotated-tag >actual &&
- test_cmp expect actual
+ git tag -F commentsfile $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header comment-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with a #comment in the -m message should succeed' '
- git tag -m "#comment" comment-annotated-tag &&
- get_tag_msg comment-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with a #comment in the -m message should succeed' '
+ name="comment-annotated-tag" &&
+ gen_header $name $commit commit $time >expect </dev/null &&
+ git tag -m "#comment" $name &&
+ get_header $name | test_cmp expect -
'
-echo '#comment' >commentfile
-echo '' >>commentfile
-echo '####' >>commentfile
-get_tag_header commentfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with #comments in the -F messagefile should succeed' '
- git tag -F commentfile commentfile-annotated-tag &&
- get_tag_msg commentfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' '
+ cat >commentfile <<-EOF &&
+ #comment
+
+ ####
+ EOF
+ name="commentfile-annotated-tag" &&
+ gen_header $name $commit commit $time >expect </dev/null &&
+ git tag -F commentfile $name &&
+ get_header $name | test_cmp expect -
'
-printf '#comment' >commentnonlfile
-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
-test_expect_success \
- 'creating a tag with a file of #comment and no newline should succeed' '
- git tag -F commentnonlfile commentnonlfile-annotated-tag &&
- get_tag_msg commentnonlfile-annotated-tag >actual &&
- test_cmp expect actual
+test_expect_success 'creating a tag with a file of #comment and no newline should succeed' '
+ printf >commentnonlfile "#comment" &&
+ name="commentnonlfile-annotated-tag" &&
+ gen_header >expect $name $commit commit $time </dev/null &&
+ git tag -F commentnonlfile $name &&
+ get_header $name | test_cmp expect -
'
# listing messages for annotated non-signed tags:
-test_expect_success \
- 'listing the one-line message of a non-signed tag should succeed' '
+test_expect_success 'listing the one-line message of a non-signed tag should succeed' '
git tag -m "A msg" tag-one-line &&
- echo "tag-one-line" >expect &&
- git tag -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-one-line >actual &&
- test_cmp expect actual &&
-
- echo "tag-one-line A msg" >expect &&
- git tag -n1 -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n999 -l tag-one-line >actual &&
- test_cmp expect actual
+ echo >expect "tag-one-line" &&
+ git tag -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n0 -l tag-one-line | test_cmp expect - &&
+
+ echo >expect "tag-one-line A msg" &&
+ git tag -n1 -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-one-line" | test_cmp expect - &&
+ git tag -n1 -l tag-one-line | test_cmp expect - &&
+ git tag -n2 -l tag-one-line | test_cmp expect - &&
+ git tag -n999 -l tag-one-line | test_cmp expect -
'
-test_expect_success \
- 'listing the zero-lines message of a non-signed tag should succeed' '
+test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' '
git tag -m "" tag-zero-lines &&
- echo "tag-zero-lines" >expect &&
- git tag -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
-
- echo "tag-zero-lines " >expect &&
- git tag -n1 -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n999 -l tag-zero-lines >actual &&
- test_cmp expect actual
+ echo >expect "tag-zero-lines" &&
+ git tag -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l tag-zero-lines | test_cmp expect - &&
+
+ echo >expect "tag-zero-lines " &&
+ git tag -n1 -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-zero-lines" | test_cmp expect - &&
+ git tag -n1 -l tag-zero-lines | test_cmp expect - &&
+ git tag -n2 -l tag-zero-lines | test_cmp expect - &&
+ git tag -n999 -l tag-zero-lines | test_cmp expect -
'
-echo 'tag line one' >annotagmsg
-echo 'tag line two' >>annotagmsg
-echo 'tag line three' >>annotagmsg
-test_expect_success \
- 'listing many message lines of a non-signed tag should succeed' '
+test_expect_success 'listing many message lines of a non-signed tag should succeed' '
+ cat >annotagmsg <<-EOF &&
+ tag line one
+ tag line two
+ tag line three
+ EOF
git tag -F annotagmsg tag-lines &&
-
echo "tag-lines" >expect &&
- git tag -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n0 -l tag-lines | test_cmp expect - &&
echo "tag-lines tag line one" >expect &&
- git tag -n1 -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^tag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n1 -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^tag-lines" | test_cmp expect - &&
+ git tag -n1 -l tag-lines | test_cmp expect - &&
echo " tag line two" >>expect &&
- git tag -n2 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n2 -l tag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n2 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n2 -l tag-lines | test_cmp expect - &&
echo " tag line three" >>expect &&
- git tag -n3 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n3 -l tag-lines >actual &&
- test_cmp expect actual &&
- git tag -n4 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n4 -l tag-lines >actual &&
- test_cmp expect actual &&
- git tag -n99 -l | grep "^ *tag.line" >actual &&
- test_cmp expect actual &&
- git tag -n99 -l tag-lines >actual &&
- test_cmp expect actual
+ git tag -n3 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n3 -l tag-lines | test_cmp expect - &&
+ git tag -n4 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n4 -l tag-lines | test_cmp expect - &&
+ git tag -n99 -l | grep "^.*tag.line" | test_cmp expect - &&
+ git tag -n99 -l tag-lines | test_cmp expect -
'
test_expect_success 'annotations for blobs are empty' '
- blob=$(git hash-object -w --stdin <<-\EOF
+ blob=$(git hash-object -w --stdin <<-EOF
Blob paragraph 1.
Blob paragraph 2.
EOF
) &&
git tag tag-blob $blob &&
- echo "tag-blob " >expect &&
- git tag -n1 -l tag-blob >actual &&
- test_cmp expect actual
+ echo >expect "tag-blob " &&
+ git tag -n1 -l tag-blob | test_cmp expect -
'
# trying to verify annotated non-signed tags:
-test_expect_success GPG \
- 'trying to verify an annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' '
tag_exists annotated-tag &&
- test_must_fail git tag -v annotated-tag
+ silent test_must_fail git tag -v annotated-tag
'
-test_expect_success GPG \
- 'trying to verify a file-annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' '
tag_exists file-annotated-tag &&
- test_must_fail git tag -v file-annotated-tag
+ silent test_must_fail git tag -v file-annotated-tag
'
-test_expect_success GPG \
- 'trying to verify two annotated non-signed tags should fail' '
+test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' '
tag_exists annotated-tag file-annotated-tag &&
- test_must_fail git tag -v annotated-tag file-annotated-tag
+ silent test_must_fail git tag -v annotated-tag file-annotated-tag
'
# creating and verifying signed tags:
-get_tag_header signed-tag $commit commit $time >expect
-echo 'A signed tag message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -m message should succeed' '
- git tag -s -m "A signed tag message" signed-tag &&
- get_tag_msg signed-tag >actual &&
- test_cmp expect actual
+ name="signed-tag" &&
+ msg="A signed tag message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header u-signed-tag $commit commit $time >expect
-echo 'Another message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'sign with a given key id' '
-
- git tag -u committer@example.com -m "Another message" u-signed-tag &&
- get_tag_msg u-signed-tag >actual &&
- test_cmp expect actual
-
+ name="u-signed-tag" &&
+ msg="Another message" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -u committer@example.com -m "$msg" $name &&
+ get_header $name | test_cmp expect -
'
test_expect_success GPG 'sign with an unknown id (1)' '
-
- test_must_fail git tag -u author@example.com \
+ silent test_must_fail git tag -u author@example.com \
-m "Another message" o-signed-tag
-
'
test_expect_success GPG 'sign with an unknown id (2)' '
-
- test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
-
+ silent test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
+test_expect_success GPG '-u implies signed tag' '
+ cat <<-\EOF | write_script fakeeditor &&
test -n "$1" && exec >"$1"
echo A signed tag message
echo from a fake editor.
EOF
-chmod +x fakeeditor
-
-get_tag_header implied-sign $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG '-u implies signed tag' '
- GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
- get_tag_msg implied-sign >actual &&
- test_cmp expect actual
+ name="implied-signed" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ GIT_EDITOR=./fakeeditor git tag -u CDDE430D $name &&
+ get_header $name | test_cmp expect -
'
-cat >sigmsgfile <<EOF
+test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' '
+ name="file-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
Another signed tag
message in a file.
+ -----BEGIN PGP SIGNATURE-----
EOF
-get_tag_header file-signed-tag $commit commit $time >expect
-cat sigmsgfile >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with -F messagefile should succeed' '
- git tag -s -F sigmsgfile file-signed-tag &&
- get_tag_msg file-signed-tag >actual &&
- test_cmp expect actual
+ tail -n 3 expect | head -n 2 >sigmsgfile
+ git tag -s -F sigmsgfile $name &&
+ get_header $name | test_cmp expect -
'
-cat >siginputmsg <<EOF
+test_expect_success GPG 'creating a signed tag with -F - should succeed' '
+ name="stdin-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
A signed tag message from
the standard input
+ -----BEGIN PGP SIGNATURE-----
EOF
-get_tag_header stdin-signed-tag $commit commit $time >expect
-cat siginputmsg >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG 'creating a signed tag with -F - should succeed' '
- git tag -s -F - stdin-signed-tag <siginputmsg &&
- get_tag_msg stdin-signed-tag >actual &&
- test_cmp expect actual
+ tail -n 3 expect | head -n 2 | git tag -s -F - $name &&
+ get_header $name | test_cmp expect -
'
-get_tag_header implied-annotate $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-s implies annotated tag' '
- GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
- get_tag_msg implied-annotate >actual &&
- test_cmp expect actual
+ name="implied-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ A signed tag message
+ from a fake editor.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ GIT_EDITOR=./fakeeditor git tag -s $name &&
+ get_header $name | test_cmp expect -
'
-test_expect_success GPG \
- 'trying to create a signed tag with non-existing -F file should fail' '
+test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists nosigtag &&
- test_must_fail git tag -s -F nonexistingfile nosigtag &&
+ silent test_must_fail git tag -s -F nonexistingfile nosigtag &&
! tag_exists nosigtag
'
-test_expect_success GPG 'verifying a signed tag should succeed' \
- 'git tag -v signed-tag'
+test_expect_success GPG 'verifying a signed tag should succeed' '
+ silent git tag -v signed-tag
+'
-test_expect_success GPG 'verifying two signed tags in one command should succeed' \
- 'git tag -v signed-tag file-signed-tag'
+test_expect_success GPG 'verifying two signed tags in one command should succeed' '
+ silent git tag -v signed-tag file-signed-tag
+'
-test_expect_success GPG \
- 'verifying many signed and non-signed tags should fail' '
- test_must_fail git tag -v signed-tag annotated-tag &&
- test_must_fail git tag -v file-annotated-tag file-signed-tag &&
- test_must_fail git tag -v annotated-tag \
+test_expect_success GPG 'verifying many signed and non-signed tags should fail' '
+ silent test_must_fail git tag -v signed-tag annotated-tag &&
+ silent test_must_fail git tag -v file-annotated-tag file-signed-tag &&
+ silent test_must_fail git tag -v annotated-tag \
file-signed-tag file-annotated-tag &&
- test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
+ silent test_must_fail git tag -v signed-tag \
+ annotated-tag file-signed-tag
'
test_expect_success GPG 'verifying a forged tag should fail' '
@@ -735,38 +681,53 @@ test_expect_success GPG 'verifying a forged tag should fail' '
sed -e "s/signed-tag/forged-tag/" |
git mktag) &&
git tag forged-tag $forged &&
- test_must_fail git tag -v forged-tag
+ silent test_must_fail git tag -v forged-tag
'
# blank and empty messages for signed tags:
-get_tag_header empty-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with an empty -m message should succeed' '
- git tag -s -m "" empty-signed-tag &&
- get_tag_msg empty-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v empty-signed-tag
-'
-
->sigemptyfile
-get_tag_header emptyfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with an empty -F messagefile should succeed' '
- git tag -s -F sigemptyfile emptyfile-signed-tag &&
- get_tag_msg emptyfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v emptyfile-signed-tag
-'
-
-printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
-printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
-get_tag_header blanks-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
+test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' '
+ name="empty-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "" $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' '
+ >sigemptyfile &&
+ name="emptyfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigemptyfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' '
+ here >sigblanksfile <<-\EOF &&
+
+ \s\s
+ \t
+ Leading blank lines
+
+ \t\s\t\s\s
+ Repeated blank lines
+
+
+
+ Trailing spaces\s\s\s\s\s\s\t\s\s
+
+ Trailing blank lines
+
+ \t\s
+
+ EOF
+ name="blanks-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
Leading blank lines
Repeated blank lines
@@ -774,53 +735,53 @@ Repeated blank lines
Trailing spaces
Trailing blank lines
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblanksfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' '
+ name="blank-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
- git tag -s -F sigblanksfile blanks-signed-tag &&
- get_tag_msg blanks-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blanks-signed-tag
-'
-
-get_tag_header blank-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a blank -m message should succeed' '
- git tag -s -m " " blank-signed-tag &&
- get_tag_msg blank-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blank-signed-tag
-'
-
-echo ' ' >sigblankfile
-echo '' >>sigblankfile
-echo ' ' >>sigblankfile
-get_tag_header blankfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with blank -F file with spaces should succeed' '
- git tag -s -F sigblankfile blankfile-signed-tag &&
- get_tag_msg blankfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v blankfile-signed-tag
-'
-
-printf ' ' >sigblanknonlfile
-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with spaces and no newline should succeed' '
- git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
- get_tag_msg blanknonlfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v signed-tag
+ git tag -s -m " " $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' '
+ here >sigblankfile <<-\EOF &&
+ \s\s\s\s\s
+
+ \s\s
+ EOF
+ name="blankfile-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblankfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' '
+ printf >sigblanknonlfile " " &&
+ name="blanknonlfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigblanknonlfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
'
# messages with commented lines for signed tags:
-cat >sigcommentsfile <<EOF
+test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' '
+ cat >sigcommentsfile <<-EOF &&
# A comment
############
@@ -837,303 +798,257 @@ Another line.
Last line.
EOF
-get_tag_header comments-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
+ name="comments-signed-tag" &&
+ gen_header >expect $name $commit commit $time <<-EOF &&
The message.
One line.
Another line.
Last line.
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentsfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' '
+ name="comment-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "#comment" $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' '
+ cat >sigcommentfile <<-EOF &&
+ #comment
+
+ ####
EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
- git tag -s -F sigcommentsfile comments-signed-tag &&
- get_tag_msg comments-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v comments-signed-tag
-'
-
-get_tag_header comment-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with #commented -m message should succeed' '
- git tag -s -m "#comment" comment-signed-tag &&
- get_tag_msg comment-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v comment-signed-tag
-'
-
-echo '#comment' >sigcommentfile
-echo '' >>sigcommentfile
-echo '####' >>sigcommentfile
-get_tag_header commentfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with #commented -F messagefile should succeed' '
- git tag -s -F sigcommentfile commentfile-signed-tag &&
- get_tag_msg commentfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v commentfile-signed-tag
-'
-
-printf '#comment' >sigcommentnonlfile
-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a #comment and no newline should succeed' '
- git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
- get_tag_msg commentnonlfile-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -v commentnonlfile-signed-tag
+ name="commentfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
+'
+
+test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' '
+ printf "#comment" >sigcommentnonlfile &&
+ name="commentnonlfile-signed-tag" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -F sigcommentnonlfile $name &&
+ get_header $name | test_cmp expect - &&
+ silent git tag -v $name
'
# listing messages for signed tags:
-test_expect_success GPG \
- 'listing the one-line message of a signed tag should succeed' '
+test_expect_success GPG 'listing the one-line message of a signed tag should succeed' '
git tag -s -m "A message line signed" stag-one-line &&
echo "stag-one-line" >expect &&
- git tag -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-one-line >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n0 -l stag-one-line | test_cmp expect - &&
echo "stag-one-line A message line signed" >expect &&
- git tag -n1 -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-one-line" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-one-line >actual &&
- test_cmp expect actual &&
- git tag -n999 -l stag-one-line >actual &&
- test_cmp expect actual
+ git tag -n1 -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-one-line" | test_cmp expect - &&
+ git tag -n1 -l stag-one-line | test_cmp expect - &&
+ git tag -n2 -l stag-one-line | test_cmp expect - &&
+ git tag -n999 -l stag-one-line | test_cmp expect -
'
-test_expect_success GPG \
- 'listing the zero-lines message of a signed tag should succeed' '
+test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' '
git tag -s -m "" stag-zero-lines &&
echo "stag-zero-lines" >expect &&
- git tag -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n0 -l stag-zero-lines | test_cmp expect - &&
echo "stag-zero-lines " >expect &&
- git tag -n1 -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-zero-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-zero-lines >actual &&
- test_cmp expect actual &&
- git tag -n999 -l stag-zero-lines >actual &&
- test_cmp expect actual
-'
-
-echo 'stag line one' >sigtagmsg
-echo 'stag line two' >>sigtagmsg
-echo 'stag line three' >>sigtagmsg
-test_expect_success GPG \
- 'listing many message lines of a signed tag should succeed' '
+ git tag -n1 -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-zero-lines" | test_cmp expect - &&
+ git tag -n1 -l stag-zero-lines | test_cmp expect - &&
+ git tag -n2 -l stag-zero-lines | test_cmp expect - &&
+ git tag -n999 -l stag-zero-lines | test_cmp expect -
+'
+
+test_expect_success GPG 'listing many message lines of a signed tag should succeed' '
+ cat >sigtagmsg <<-EOF &&
+ stag line one
+ stag line two
+ stag line three
+ EOF
git tag -s -F sigtagmsg stag-lines &&
echo "stag-lines" >expect &&
- git tag -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n0 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n0 -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n0 -l stag-lines | test_cmp expect - &&
echo "stag-lines stag line one" >expect &&
- git tag -n1 -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n -l | grep "^stag-lines" >actual &&
- test_cmp expect actual &&
- git tag -n1 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n1 -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n -l | grep "^stag-lines" | test_cmp expect - &&
+ git tag -n1 -l stag-lines | test_cmp expect - &&
echo " stag line two" >>expect &&
- git tag -n2 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n2 -l stag-lines >actual &&
- test_cmp expect actual &&
+ git tag -n2 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n2 -l stag-lines | test_cmp expect - &&
echo " stag line three" >>expect &&
- git tag -n3 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n3 -l stag-lines >actual &&
- test_cmp expect actual &&
- git tag -n4 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n4 -l stag-lines >actual &&
- test_cmp expect actual &&
- git tag -n99 -l | grep "^ *stag.line" >actual &&
- test_cmp expect actual &&
- git tag -n99 -l stag-lines >actual &&
- test_cmp expect actual
+ git tag -n3 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n3 -l stag-lines | test_cmp expect - &&
+ git tag -n4 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n4 -l stag-lines | test_cmp expect - &&
+ git tag -n99 -l | grep "^.*stag.line" | test_cmp expect - &&
+ git tag -n99 -l stag-lines | test_cmp expect -
'
-# tags pointing to objects different from commits:
-tree=$(git rev-parse HEAD^{tree})
-blob=$(git rev-parse HEAD:foo)
-tag=$(git rev-parse signed-tag 2>/dev/null)
-
-get_tag_header tree-signed-tag $tree tree $time >expect
-echo "A message for a tree" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to a tree should succeed' '
- git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
- get_tag_msg tree-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' '
+ # tags pointing to objects different from commits:
+ tree=$(git rev-parse HEAD^{tree}) &&
+ blob=$(git rev-parse HEAD:foo) &&
+ tag=$(git rev-parse signed-tag) &&
+ name="tree-signed-tag" &&
+ msg="A message for a tree" &&
+ gen_header $name $tree tree $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name HEAD^{tree} &&
+ get_header $name | test_cmp expect -
'
-get_tag_header blob-signed-tag $blob blob $time >expect
-echo "A message for a blob" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to a blob should succeed' '
- git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
- get_tag_msg blob-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' '
+ msg="A message for a blob" &&
+ name="blob-signed-tag" &&
+ gen_header $name $blob blob $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name HEAD:foo &&
+ get_header $name | test_cmp expect -
'
-get_tag_header tag-signed-tag $tag tag $time >expect
-echo "A message for another tag" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag pointing to another tag should succeed' '
- git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
- get_tag_msg tag-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' '
+ msg="A message for another tag" &&
+ name="tag-signed-tag" &&
+ gen_header $name $tag tag $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP SIGNATURE-----
+ EOF
+ git tag -s -m "$msg" $name signed-tag &&
+ get_header $name | test_cmp expect -
'
# usage with rfc1991 signatures
-echo "rfc1991" > gpghome/gpg.conf
-get_tag_header rfc1991-signed-tag $commit commit $time >expect
-echo "RFC1991 signed tag" >>expect
-echo '-----BEGIN PGP MESSAGE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with rfc1991' '
- git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
- get_tag_msg rfc1991-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'creating a signed tag with rfc1991' '
+ echo "rfc1991" >gpghome/gpg.conf &&
+ msg="RFC1991 signed tag" &&
+ name="rfc1991-signed-tag"
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ $msg
+ -----BEGIN PGP MESSAGE-----
+ EOF
+ git tag -s -m "$msg" $name $commit &&
+ get_header $name | test_cmp expect -
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
+test_expect_success GPG 'reediting a signed tag body omits signature' '
+ cat <<-\EOF | write_script fakeeditor &&
cp "$1" actual
EOF
-chmod +x fakeeditor
-
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
- GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ GIT_EDITOR=./fakeeditor \
+ quiet git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
-test_expect_success GPG \
- 'verifying rfc1991 signature' '
- git tag -v rfc1991-signed-tag
+test_expect_success GPG 'verifying rfc1991 signature' '
+ silent git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature' '
+test_expect_success GPG 'list tag with rfc1991 signature' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
- git tag -l -n1 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n2 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n999 rfc1991-signed-tag >actual &&
- test_cmp expect actual
+ git tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n999 rfc1991-signed-tag | test_cmp expect -
'
-rm -f gpghome/gpg.conf
-
-test_expect_success GPG \
- 'verifying rfc1991 signature without --rfc1991' '
- git tag -v rfc1991-signed-tag
+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '
+ rm -f gpghome/gpg.conf &&
+ silent git tag -v rfc1991-signed-tag
'
-test_expect_success GPG \
- 'list tag with rfc1991 signature without --rfc1991' '
- echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
- git tag -l -n1 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n2 rfc1991-signed-tag >actual &&
- test_cmp expect actual &&
- git tag -l -n999 rfc1991-signed-tag >actual &&
- test_cmp expect actual
+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '
+ echo >expect "rfc1991-signed-tag RFC1991 signed tag" &&
+ git tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&
+ git tag -l -n999 rfc1991-signed-tag | test_cmp expect -
'
-test_expect_success GPG \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
- GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ GIT_EDITOR=./fakeeditor \
+ quiet git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '
# try to sign with bad user.signingkey
-git config user.signingkey BobTheMouse
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured' \
- 'test_must_fail git tag -s -m tail tag-gpg-failure'
+ git config user.signingkey BobTheMouse &&
+ silent test_must_fail git tag -s -m tail tag-gpg-failure &&
git config --unset user.signingkey
+'
+test_expect_success GPG 'verify signed tag fails when public key is not present' '
# try to verify without gpg:
+ rm -rf gpghome &&
+ silent test_must_fail git tag -v signed-tag
+'
-rm -rf gpghome
-test_expect_success GPG \
- 'verify signed tag fails when public key is not present' \
- 'test_must_fail git tag -v signed-tag'
-
-test_expect_success \
- 'git tag -a fails if tag annotation is empty' '
- ! (GIT_EDITOR=cat git tag -a initial-comment)
+test_expect_success 'git tag -a fails if tag annotation is empty' '
+ ! (GIT_EDITOR=cat silent git tag -a initial-comment)
'
-test_expect_success \
- 'message in editor has initial comment' '
- ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
+test_expect_success 'message in editor has initial comment' '
+ ! (GIT_EDITOR=cat git tag -a initial-comment >actual 2>/dev/null)
'
test_expect_success 'message in editor has initial comment: first line' '
# check the first line --- should be empty
echo >first.expect &&
- sed -e 1q <actual >first.actual &&
+ sed -e 1q actual >first.actual &&
test_i18ncmp first.expect first.actual
'
-test_expect_success \
- 'message in editor has initial comment: remainder' '
+test_expect_success 'message in editor has initial comment: remainder' '
# remove commented lines from the remainder -- should be empty
>rest.expect
sed -e 1d -e '/^#/d' <actual >rest.actual &&
test_cmp rest.expect rest.actual
'
-get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >> expect
-test_expect_success \
- 'overwriting an annoted tag should use its previous body' '
- git tag -a -m "An annotation to be reused" reuse &&
- GIT_EDITOR=true git tag -f -a reuse &&
- get_tag_msg reuse >actual &&
- test_cmp expect actual
+test_expect_success 'overwriting an annoted tag should use its previous body' '
+ name="reuse" &&
+ msg="An annotation to be reused" &&
+ gen_header $name $commit commit $time >expect <<-EOF &&
+ reuse
+ EOF
+ git tag -a -m "$msg" $name &&
+ GIT_EDITOR=true git tag -f -a -m "reuse" $name &&
+ get_header $name | test_cmp expect -
'
test_expect_success 'filename for the message is relative to cwd' '
@@ -1144,7 +1059,7 @@ test_expect_success 'filename for the message is relative to cwd' '
cd subdir &&
git tag -a -F msgfile-5 tag-from-subdir
) &&
- git cat-file tag tag-from-subdir | grep "in sub directory"
+ git cat-file tag tag-from-subdir | grep -q "in sub directory"
'
test_expect_success 'filename for the message is relative to cwd' '
@@ -1153,110 +1068,91 @@ test_expect_success 'filename for the message is relative to cwd' '
cd subdir &&
git tag -a -F msgfile-6 tag-from-subdir-2
) &&
- git cat-file tag tag-from-subdir-2 | grep "in sub directory"
+ git cat-file tag tag-from-subdir-2 | grep -q "in sub directory"
'
-# create a few more commits to test --contains
-
-hash1=$(git rev-parse HEAD)
-
test_expect_success 'creating second commit and tag' '
+ # create a few more commits to test --contains
+ hash1=$(git rev-parse HEAD) &&
echo foo-2.0 >foo &&
git add foo &&
- git commit -m second &&
+ git commit -q -m second &&
+ hash2=$(git rev-parse HEAD) &&
git tag v2.0
'
-hash2=$(git rev-parse HEAD)
-
test_expect_success 'creating third commit without tag' '
echo foo-dev >foo &&
git add foo &&
- git commit -m third
-'
-
+ git commit -q -m third &&
hash3=$(git rev-parse HEAD)
+'
-# simple linear checks of --continue
-
-cat > expected <<EOF
+test_expect_success 'checking that first commit is in all tags (hash)' '
+ # simple linear checks of --contains
+ cat >expect <<-EOF &&
v0.2.1
v1.0
v1.0.1
v1.1.3
v2.0
EOF
+ git tag -l --contains $hash1 v* | test_cmp expect -
+'
-test_expect_success 'checking that first commit is in all tags (hash)' "
- git tag -l --contains $hash1 v* >actual &&
- test_cmp expected actual
-"
-
+test_expect_success 'checking that first commit is in all tags (tag)' '
# other ways of specifying the commit
-test_expect_success 'checking that first commit is in all tags (tag)' "
- git tag -l --contains v1.0 v* >actual &&
- test_cmp expected actual
-"
+ git tag -l --contains v1.0 v* | test_cmp expect -
+'
-test_expect_success 'checking that first commit is in all tags (relative)' "
- git tag -l --contains HEAD~2 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that first commit is in all tags (relative)' '
+ git tag -l --contains HEAD~2 v* | test_cmp expect -
+'
-cat > expected <<EOF
+test_expect_success 'checking that second commit only has one tag' '
+ cat >expect <<-EOF &&
v2.0
EOF
+ git tag -l --contains $hash2 v* | test_cmp expect -
+'
-test_expect_success 'checking that second commit only has one tag' "
- git tag -l --contains $hash2 v* >actual &&
- test_cmp expected actual
-"
-
-
-cat > expected <<EOF
-EOF
-
-test_expect_success 'checking that third commit has no tags' "
- git tag -l --contains $hash3 v* >actual &&
- test_cmp expected actual
-"
+test_expect_success 'checking that third commit has no tags' '
+ >expect
+ git tag -l --contains $hash3 v* | test_cmp expect -
+'
# how about a simple merge?
test_expect_success 'creating simple branch' '
git branch stable v2.0 &&
- git checkout stable &&
+ git checkout -q stable &&
echo foo-3.0 > foo &&
- git commit foo -m fourth &&
+ git commit -q foo -m fourth &&
+ hash4=$(git rev-parse HEAD) &&
git tag v3.0
'
-hash4=$(git rev-parse HEAD)
-
-cat > expected <<EOF
+test_expect_success 'checking that branch head only has one tag' '
+ cat >expect <<-EOF &&
v3.0
EOF
-
-test_expect_success 'checking that branch head only has one tag' "
- git tag -l --contains $hash4 v* >actual &&
- test_cmp expected actual
-"
+ git tag -l --contains $hash4 v* | test_cmp expect -
+'
test_expect_success 'merging original branch into this branch' '
- git merge --strategy=ours master &&
+ git merge -q --strategy=ours master &&
git tag v4.0
'
-cat > expected <<EOF
+test_expect_success 'checking that original branch head has one tag now' '
+ cat >expect <<-EOF &&
v4.0
EOF
+ git tag -l --contains $hash3 v* | test_cmp expect -
+'
-test_expect_success 'checking that original branch head has one tag now' "
- git tag -l --contains $hash3 v* >actual &&
- test_cmp expected actual
-"
-
-cat > expected <<EOF
+test_expect_success 'checking that initial commit is in all tags' '
+ cat >expect <<-EOF &&
v0.2.1
v1.0
v1.0.1
@@ -1265,60 +1161,50 @@ v2.0
v3.0
v4.0
EOF
+ git tag -l --contains $hash1 v* | test_cmp expect -
+'
-test_expect_success 'checking that initial commit is in all tags' "
- git tag -l --contains $hash1 v* >actual &&
- test_cmp expected actual
-"
-
-# mixing modes and options:
test_expect_success 'mixing incompatibles modes and options is forbidden' '
- test_must_fail git tag -a &&
- test_must_fail git tag -l -v &&
- test_must_fail git tag -n 100 &&
- test_must_fail git tag -l -m msg &&
- test_must_fail git tag -l -F some file &&
- test_must_fail git tag -v -s
+ # mixing modes and options:
+ silent test_must_fail git tag -a &&
+ silent test_must_fail git tag -l -v &&
+ silent test_must_fail git tag -n 100 &&
+ silent test_must_fail git tag -l -m msg &&
+ silent test_must_fail git tag -l -F some file &&
+ silent test_must_fail git tag -v -s &&
+ silent test_must_fail git tag --points-at=v4.0 foo
'
# check points-at
-test_expect_success '--points-at cannot be used in non-list mode' '
- test_must_fail git tag --points-at=v4.0 foo
-'
-
test_expect_success '--points-at finds lightweight tags' '
echo v4.0 >expect &&
- git tag --points-at v4.0 >actual &&
- test_cmp expect actual
+ git tag --points-at v4.0 | test_cmp expect -
'
test_expect_success '--points-at finds annotated tags of commits' '
git tag -m "v4.0, annotated" annotated-v4.0 v4.0 &&
echo annotated-v4.0 >expect &&
- git tag -l --points-at v4.0 "annotated*" >actual &&
- test_cmp expect actual
+ git tag -l --points-at v4.0 "annotated*" | test_cmp expect -
'
test_expect_success '--points-at finds annotated tags of tags' '
git tag -m "describing the v4.0 tag object" \
annotated-again-v4.0 annotated-v4.0 &&
- cat >expect <<-\EOF &&
+ cat >expect <<-EOF &&
annotated-again-v4.0
annotated-v4.0
EOF
- git tag --points-at=annotated-v4.0 >actual &&
- test_cmp expect actual
+ git tag --points-at=annotated-v4.0 | test_cmp expect -
'
test_expect_success 'multiple --points-at are OR-ed together' '
- cat >expect <<-\EOF &&
+ cat >expect <<-EOF &&
v2.0
v3.0
EOF
- git tag --points-at=v2.0 --points-at=v3.0 >actual &&
- test_cmp expect actual
+ git tag --points-at=v2.0 --points-at=v3.0 | test_cmp expect -
'
test_done
--
1.7.8
^ permalink raw reply related [flat|nested] 83+ messages in thread