]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/symbolic-ref-maint'
authorJunio C Hamano <gitster@pobox.com>
Mon, 28 Dec 2015 21:57:24 +0000 (13:57 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Dec 2015 21:57:24 +0000 (13:57 -0800)
"git symbolic-ref" forgot to report a failure with its exit status.

* jk/symbolic-ref-maint:
  t1401: test reflog creation for git-symbolic-ref
  symbolic-ref: propagate error code from create_symref()

1  2 
t/t1401-symbolic-ref.sh

index 20b022ae3397552fd3cd4e42553f4cd3575049f5,64968b789161bb5b88be59a80348a29924d26208..1f0dff3a0b1cedb95b900a01de972e8a02e29f90
@@@ -63,33 -63,26 +63,55 @@@ test_expect_success 'symbolic-ref fail
  '
  reset_to_sane
  
 +test_expect_success 'create large ref name' '
 +      # make 256+ character ref; some systems may not handle that,
 +      # so be gentle
 +      long=0123456789abcdef &&
 +      long=$long/$long/$long/$long &&
 +      long=$long/$long/$long/$long &&
 +      long_ref=refs/heads/$long &&
 +      tree=$(git write-tree) &&
 +      commit=$(echo foo | git commit-tree $tree) &&
 +      if git update-ref $long_ref $commit; then
 +              test_set_prereq LONG_REF
 +      else
 +              echo >&2 "long refs not supported"
 +      fi
 +'
 +
 +test_expect_success LONG_REF 'symbolic-ref can point to large ref name' '
 +      git symbolic-ref HEAD $long_ref &&
 +      echo $long_ref >expect &&
 +      git symbolic-ref HEAD >actual &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success LONG_REF 'we can parse long symbolic ref' '
 +      echo $commit >expect &&
 +      git rev-parse --verify HEAD >actual &&
 +      test_cmp expect actual
 +'
 +
+ test_expect_success 'symbolic-ref reports failure in exit code' '
+       test_when_finished "rm -f .git/HEAD.lock" &&
+       >.git/HEAD.lock &&
+       test_must_fail git symbolic-ref HEAD refs/heads/whatever
+ '
+ test_expect_success 'symbolic-ref writes reflog entry' '
+       git checkout -b log1 &&
+       test_commit one &&
+       git checkout -b log2  &&
+       test_commit two &&
+       git checkout --orphan orphan &&
+       git symbolic-ref -m create HEAD refs/heads/log1 &&
+       git symbolic-ref -m update HEAD refs/heads/log2 &&
+       cat >expect <<-\EOF &&
+       update
+       create
+       EOF
+       git log --format=%gs -g >actual &&
+       test_cmp expect actual
+ '
  test_done