symbolic-ref: propagate error code from create_symref()

If create_symref() fails, git-symbolic-ref will still exit with code 0, and our caller has no idea that the command did nothing. This appears to have been broken since the beginning of time (e.g., it is not a regression where create_symref() stopped calling die() or something similar). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 20, 2015 at 02:27 UTC 3e4068ed90fd3c6f24303560113aae6dbb758699
2 files changed +7 -1
builtin/symbolic-ref.c
+1 -1
@@ -67,7 +67,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
67 if (!strcmp(argv[0], "HEAD") &&
68 !starts_with(argv[1], "refs/"))
69 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);
71 break;
72 default:
73 usage_with_options(git_symbolic_ref_usage, options);
t/t1401-symbolic-ref.sh
+6
@@ -63,4 +63,10 @@ test_expect_success 'symbolic-ref fails to delete real ref' '
63 '
64 reset_to_sane
65
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_done