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