Skip to content

Commit e002527

Browse files
committed
Merge branch 'jk/symbolic-ref-maint' into maint
"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()
2 parents e54d0f5 + f91b273 commit e002527

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

builtin/symbolic-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
6767
if (!strcmp(argv[0], "HEAD") &&
6868
!starts_with(argv[1], "refs/"))
6969
die("Refusing to point HEAD outside of refs/");
70-
create_symref(argv[0], argv[1], msg);
70+
ret = !!create_symref(argv[0], argv[1], msg);
7171
break;
7272
default:
7373
usage_with_options(git_symbolic_ref_usage, options);

t/t1401-symbolic-ref.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,26 @@ test_expect_success 'symbolic-ref fails to delete real ref' '
6363
'
6464
reset_to_sane
6565

66+
test_expect_success 'symbolic-ref reports failure in exit code' '
67+
test_when_finished "rm -f .git/HEAD.lock" &&
68+
>.git/HEAD.lock &&
69+
test_must_fail git symbolic-ref HEAD refs/heads/whatever
70+
'
71+
72+
test_expect_success 'symbolic-ref writes reflog entry' '
73+
git checkout -b log1 &&
74+
test_commit one &&
75+
git checkout -b log2 &&
76+
test_commit two &&
77+
git checkout --orphan orphan &&
78+
git symbolic-ref -m create HEAD refs/heads/log1 &&
79+
git symbolic-ref -m update HEAD refs/heads/log2 &&
80+
cat >expect <<-\EOF &&
81+
update
82+
create
83+
EOF
84+
git log --format=%gs -g >actual &&
85+
test_cmp expect actual
86+
'
87+
6688
test_done

0 commit comments

Comments
 (0)