aboutsummaryrefslogtreecommitdiff
path: root/builtin-symbolic-ref.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-01-14 02:44:18 -0500
committerShawn O. Pearce <spearce@spearce.org>2007-01-14 02:44:18 -0500
commit1fcdd62adf81a172f45c7c6a58177212d500b9d9 (patch)
tree94acde078fd78c3d214fe09d45e85ed346a2f2d4 /builtin-symbolic-ref.c
parent9938ffc53a15c755bbd3894c02492b940ea34c4c (diff)
parent696b1b507f8ff9e80a2edc4eced59ca8cdda920e (diff)
downloadgit-1fcdd62adf81a172f45c7c6a58177212d500b9d9.tar.gz
git-1fcdd62adf81a172f45c7c6a58177212d500b9d9.tar.xz
Merge branch 'master' into sp/fast-import
I'm bringing master in early so that the OBJ_OFS_DELTA implementation is available as part of the topic. This way git-fast-import can learn about this new slightly smaller and faster packfile format, and can generate them directly rather than needing to have them be repacked with git-pack-objects. Due to the API changes in master during the period of development of git-fast-import, a few minor tweaks to fast-import.c are needed to produce a working merge. I've done them here as part of the merge to ensure bisection always works. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
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 b4ec6f28e..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 = strdup(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(strdup(git_path("%s", argv[1])), argv[2]);
+ create_symref(argv[1], argv[2]);
break;
default:
usage(git_symbolic_ref_usage);