4 static const char git_symbolic_ref_usage[] =
5 "git-symbolic-ref name [ref]";
7 static void check_symref(const char *HEAD)
9 unsigned char sha1[20];
10 const char *git_HEAD = strdup(git_path("%s", HEAD));
11 const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
12 if (git_refs_heads_master) {
13 /* we want to strip the .git/ part */
14 int pfxlen = strlen(git_HEAD) - strlen(HEAD);
15 puts(git_refs_heads_master + pfxlen);
18 die("No such ref: %s", HEAD);
21 int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
23 git_config(git_default_config);
26 check_symref(argv[1]);
29 create_symref(strdup(git_path("%s", argv[1])), argv[2]);
32 usage(git_symbolic_ref_usage);