aboutsummaryrefslogtreecommitdiff
path: root/builtin-symbolic-ref.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-21 00:29:37 -0700
committerJunio C Hamano <junkio@cox.net>2006-09-21 00:29:37 -0700
commit340adb8bccf48b9d933f0608fd99c75a5c28003c (patch)
tree7f56898365b94fcac608f3d25788fd864570d2ca /builtin-symbolic-ref.c
parent9f613ddd21cbd05bfc139d9b1551b5780aa171f6 (diff)
parent968846015229fe0fec28e3c85db722e131c15f93 (diff)
downloadgit-340adb8bccf48b9d933f0608fd99c75a5c28003c.tar.gz
git-340adb8bccf48b9d933f0608fd99c75a5c28003c.tar.xz
Merge branch 'lt/refs' into jc/for-each-ref-with-lt-refs
* lt/refs: (58 commits) git-pack-refs --prune pack-refs: do not pack symbolic refs. Tell between packed, unpacked and symbolic refs. Add callback data to for_each_ref() family. symbolit-ref: fix resolve_ref conversion. Fix broken sha1 locking fsck-objects: adjust to resolve_ref() clean-up. gitignore: git-pack-refs is a generated file. wt-status: use simplified resolve_ref to find current branch Fix t1400-update-ref test minimally Enable the packed refs file format Make ref resolution saner Add support for negative refs Start handling references internally as a sorted in-memory list gitweb fix validating pg (page) parameter git-repack(1): document --window and --depth git-apply(1): document --unidiff-zero gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export upload-archive: monitor child communication even more carefully. gitweb: export options ...
Diffstat (limited to 'builtin-symbolic-ref.c')
-rw-r--r--builtin-symbolic-ref.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index 1d3a5e229..d8be0527f 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "refs.h"
static const char git_symbolic_ref_usage[] =
"git-symbolic-ref name [ref]";
@@ -7,15 +8,14 @@ static const char git_symbolic_ref_usage[] =
static void check_symref(const char *HEAD)
{
unsigned char sha1[20];
- const char *git_HEAD = xstrdup(git_path("%s", HEAD));
- const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
- if (git_refs_heads_master) {
- /* we want to strip the .git/ part */
- int pfxlen = strlen(git_HEAD) - strlen(HEAD);
- puts(git_refs_heads_master + pfxlen);
- }
- else
+ int flag;
+ const char *refs_heads_master = resolve_ref(HEAD, sha1, 0, &flag);
+
+ if (!refs_heads_master)
die("No such ref: %s", HEAD);
+ else if (!(flag & REF_ISSYMREF))
+ die("ref %s is not a symbolic ref", HEAD);
+ puts(refs_heads_master);
}
int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
@@ -26,7 +26,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
check_symref(argv[1]);
break;
case 3:
- create_symref(xstrdup(git_path("%s", argv[1])), argv[2]);
+ create_symref(argv[1], argv[2]);
break;
default:
usage(git_symbolic_ref_usage);