]>
Commit | Line | Data |
---|---|---|
640ce105 | 1 | #include "builtin.h" |
8098a178 | 2 | #include "cache.h" |
8da19775 | 3 | #include "refs.h" |
8098a178 JH |
4 | |
5 | static const char git_symbolic_ref_usage[] = | |
6 | "git-symbolic-ref name [ref]"; | |
7 | ||
f5a5e9b9 | 8 | static void check_symref(const char *HEAD) |
8098a178 JH |
9 | { |
10 | unsigned char sha1[20]; | |
8da19775 JH |
11 | int flag; |
12 | const char *refs_heads_master = resolve_ref(HEAD, sha1, 0, &flag); | |
ed378ec7 LT |
13 | |
14 | if (!refs_heads_master) | |
8098a178 | 15 | die("No such ref: %s", HEAD); |
8da19775 JH |
16 | else if (!(flag & REF_ISSYMREF)) |
17 | die("ref %s is not a symbolic ref", HEAD); | |
ed378ec7 | 18 | puts(refs_heads_master); |
8098a178 JH |
19 | } |
20 | ||
640ce105 | 21 | int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) |
8098a178 | 22 | { |
27dedf0c | 23 | git_config(git_default_config); |
8098a178 JH |
24 | switch (argc) { |
25 | case 2: | |
26 | check_symref(argv[1]); | |
27 | break; | |
28 | case 3: | |
ed378ec7 | 29 | create_symref(argv[1], argv[2]); |
8098a178 JH |
30 | break; |
31 | default: | |
32 | usage(git_symbolic_ref_usage); | |
33 | } | |
34 | return 0; | |
35 | } |