Merge branch 'jk/t6300-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Mar 2017 21:24:22 +0000 (13:24 -0800)
A test that creates a confusing branch whose name is HEAD has been
corrected not to do so.

* jk/t6300-cleanup:
t6300: avoid creating refs/heads/HEAD

1  2 
t/t6300-for-each-ref.sh
diff --combined t/t6300-for-each-ref.sh
index c87dc1f8bc92c13e11e8f8d8cd1468beb6669cba,37e021f30ea66b0e613b4ad5246b49540116c432..834a9ed168fad35258955447326e7d3d1f09b7d1
@@@ -38,7 -38,6 +38,7 @@@ test_atom() 
        case "$1" in
                head) ref=refs/heads/master ;;
                 tag) ref=refs/tags/testtag ;;
 +               sym) ref=refs/heads/sym ;;
                   *) ref=$1 ;;
        esac
        printf '%s\n' "$3" >expected
  
  test_atom head refname refs/heads/master
  test_atom head refname:short master
 +test_atom head refname:lstrip=1 heads/master
 +test_atom head refname:lstrip=2 master
 +test_atom head refname:lstrip=-1 master
 +test_atom head refname:lstrip=-2 heads/master
 +test_atom head refname:rstrip=1 refs/heads
 +test_atom head refname:rstrip=2 refs
 +test_atom head refname:rstrip=-1 refs
 +test_atom head refname:rstrip=-2 refs/heads
  test_atom head refname:strip=1 heads/master
  test_atom head refname:strip=2 master
 +test_atom head refname:strip=-1 master
 +test_atom head refname:strip=-2 heads/master
  test_atom head upstream refs/remotes/origin/master
  test_atom head upstream:short origin/master
 +test_atom head upstream:lstrip=2 origin/master
 +test_atom head upstream:lstrip=-2 origin/master
 +test_atom head upstream:rstrip=2 refs/remotes
 +test_atom head upstream:rstrip=-2 refs/remotes
 +test_atom head upstream:strip=2 origin/master
 +test_atom head upstream:strip=-2 origin/master
  test_atom head push refs/remotes/myfork/master
  test_atom head push:short myfork/master
 +test_atom head push:lstrip=1 remotes/myfork/master
 +test_atom head push:lstrip=-1 master
 +test_atom head push:rstrip=1 refs/remotes/myfork
 +test_atom head push:rstrip=-1 refs
 +test_atom head push:strip=1 remotes/myfork/master
 +test_atom head push:strip=-1 master
  test_atom head objecttype commit
  test_atom head objectsize 171
  test_atom head objectname $(git rev-parse refs/heads/master)
  test_atom head objectname:short $(git rev-parse --short refs/heads/master)
 +test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
 +test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master)
  test_atom head tree $(git rev-parse refs/heads/master^{tree})
  test_atom head parent ''
  test_atom head numparent 0
@@@ -124,8 -99,6 +124,8 @@@ test_atom tag objecttype ta
  test_atom tag objectsize 154
  test_atom tag objectname $(git rev-parse refs/tags/testtag)
  test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
 +test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
 +test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master)
  test_atom tag tree ''
  test_atom tag parent ''
  test_atom tag numparent ''
@@@ -161,6 -134,16 +161,6 @@@ test_expect_success 'Check invalid atom
        test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
  '
  
 -test_expect_success 'arguments to :strip must be positive integers' '
 -      test_must_fail git for-each-ref --format="%(refname:strip=0)" &&
 -      test_must_fail git for-each-ref --format="%(refname:strip=-1)" &&
 -      test_must_fail git for-each-ref --format="%(refname:strip=foo)"
 -'
 -
 -test_expect_success 'stripping refnames too far gives an error' '
 -      test_must_fail git for-each-ref --format="%(refname:strip=3)"
 -'
 -
  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 &&
@@@ -181,12 -164,6 +181,12 @@@ test_expect_success 'Check invalid form
        test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
  '
  
 +test_expect_success 'arguments to %(objectname:short=) must be positive integers' '
 +      test_must_fail git for-each-ref --format="%(objectname:short=0)" &&
 +      test_must_fail git for-each-ref --format="%(objectname:short=-1)" &&
 +      test_must_fail git for-each-ref --format="%(objectname:short=foo)"
 +'
 +
  test_date () {
        f=$1 &&
        committer_date=$2 &&
@@@ -385,8 -362,6 +385,8 @@@ test_expect_success 'setup for upstream
  
  test_atom head upstream:track '[ahead 1]'
  test_atom head upstream:trackshort '>'
 +test_atom head upstream:track,nobracket 'ahead 1'
 +test_atom head upstream:nobracket,track 'ahead 1'
  test_atom head push:track '[ahead 1]'
  test_atom head push:trackshort '>'
  
@@@ -397,7 -372,7 +397,7 @@@ test_expect_success 'Check that :track[
  
  test_expect_success 'Check that :track[short] works when upstream is invalid' '
        cat >expected <<-\EOF &&
 -
 +      [gone]
  
        EOF
        test_when_finished "git config branch.master.merge refs/heads/master" &&
@@@ -579,87 -554,13 +579,87 @@@ test_expect_success 'Verify sort with m
        test_cmp expected actual
  '
  
 +
  test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
        test_when_finished "git checkout master" &&
        git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
        sed -e "s/^\* /  /" actual >expect &&
-       git checkout --orphan HEAD &&
+       git checkout --orphan orphaned-branch &&
        git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
        test_cmp expect actual
  '
  
 +cat >trailers <<EOF
 +Reviewed-by: A U Thor <author@example.com>
 +Signed-off-by: A U Thor <author@example.com>
 +EOF
 +
 +test_expect_success 'basic atom: head contents:trailers' '
 +      echo "Some contents" > two &&
 +      git add two &&
 +      git commit -F - <<-EOF &&
 +      trailers: this commit message has trailers
 +
 +      Some message contents
 +
 +      $(cat trailers)
 +      EOF
 +      git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
 +      sanitize_pgp <actual >actual.clean &&
 +      # git for-each-ref ends with a blank line
 +      cat >expect <<-EOF &&
 +      $(cat trailers)
 +
 +      EOF
 +      test_cmp expect actual.clean
 +'
 +
 +test_expect_success 'Add symbolic ref for the following tests' '
 +      git symbolic-ref refs/heads/sym refs/heads/master
 +'
 +
 +cat >expected <<EOF
 +refs/heads/master
 +EOF
 +
 +test_expect_success 'Verify usage of %(symref) atom' '
 +      git for-each-ref --format="%(symref)" refs/heads/sym >actual &&
 +      test_cmp expected actual
 +'
 +
 +cat >expected <<EOF
 +heads/master
 +EOF
 +
 +test_expect_success 'Verify usage of %(symref:short) atom' '
 +      git for-each-ref --format="%(symref:short)" refs/heads/sym >actual &&
 +      test_cmp expected actual
 +'
 +
 +cat >expected <<EOF
 +master
 +heads/master
 +EOF
 +
 +test_expect_success 'Verify usage of %(symref:lstrip) atom' '
 +      git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
 +      git for-each-ref --format="%(symref:lstrip=-2)" refs/heads/sym >> actual &&
 +      test_cmp expected actual &&
 +
 +      git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
 +      git for-each-ref --format="%(symref:strip=-2)" refs/heads/sym >> actual &&
 +      test_cmp expected actual
 +'
 +
 +cat >expected <<EOF
 +refs
 +refs/heads
 +EOF
 +
 +test_expect_success 'Verify usage of %(symref:rstrip) atom' '
 +      git for-each-ref --format="%(symref:rstrip=2)" refs/heads/sym > actual &&
 +      git for-each-ref --format="%(symref:rstrip=-2)" refs/heads/sym >> actual &&
 +      test_cmp expected actual
 +'
 +
  test_done