Add git-am, applymbox replacement.
[git/jnareb-git/bp-gitweb.git] / symbolic-ref.c
bloba72d7accb18092231c608a6ae7db4a4ce9dc8b73
1 #include "cache.h"
3 static const char git_symbolic_ref_usage[] =
4 "git-symbolic-ref name [ref]";
6 static void check_symref(const char *HEAD)
8 unsigned char sha1[20];
9 const char *git_HEAD = strdup(git_path("%s", HEAD));
10 const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
11 if (git_refs_heads_master) {
12 /* we want to strip the .git/ part */
13 int pfxlen = strlen(git_HEAD) - strlen(HEAD);
14 puts(git_refs_heads_master + pfxlen);
16 else
17 die("No such ref: %s", HEAD);
20 int main(int argc, const char **argv)
22 setup_git_directory();
23 switch (argc) {
24 case 2:
25 check_symref(argv[1]);
26 break;
27 case 3:
28 create_symref(strdup(git_path("%s", argv[1])), argv[2]);
29 break;
30 default:
31 usage(git_symbolic_ref_usage);
33 return 0;