]> git.ipfire.org Git - thirdparty/git.git/blob - builtin-symbolic-ref.c
symbolit-ref: fix resolve_ref conversion.
[thirdparty/git.git] / builtin-symbolic-ref.c
1 #include "builtin.h"
2 #include "cache.h"
3
4 static const char git_symbolic_ref_usage[] =
5 "git-symbolic-ref name [ref]";
6
7 static void check_symref(const char *HEAD)
8 {
9 unsigned char sha1[20];
10 const char *refs_heads_master = resolve_ref(HEAD, sha1, 0);
11
12 if (!refs_heads_master)
13 die("No such ref: %s", HEAD);
14 puts(refs_heads_master);
15 }
16
17 int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
18 {
19 git_config(git_default_config);
20 switch (argc) {
21 case 2:
22 check_symref(argv[1]);
23 break;
24 case 3:
25 create_symref(argv[1], argv[2]);
26 break;
27 default:
28 usage(git_symbolic_ref_usage);
29 }
30 return 0;
31 }