summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-pack-refs.c2
-rw-r--r--builtin-show-branch.c6
-rw-r--r--builtin-update-index.c6
-rw-r--r--refs.c11
4 files changed, 14 insertions, 11 deletions
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 246dd6372e..db57fee72d 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -56,7 +56,7 @@ static void prune_ref(struct ref_to_prune *r)
struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1, 1);
if (lock) {
- unlink(git_path(r->name));
+ unlink(git_path("%s", r->name));
unlock_ref(lock);
}
}
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 5d6ce56836..fb1a4000d9 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -443,6 +443,12 @@ static int rev_is_head(char *head, int headlen, char *name,
if ((!head[0]) ||
(head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
return 0;
+ if (!strncmp(head, "refs/heads/", 11))
+ head += 11;
+ if (!strncmp(name, "refs/heads/", 11))
+ name += 11;
+ else if (!strncmp(name, "heads/", 6))
+ name += 6;
return !strcmp(head, name);
}
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 0620e779b0..09214c8a11 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -404,9 +404,9 @@ static int unresolve_one(const char *path)
static void read_head_pointers(void)
{
- if (read_ref(git_path("HEAD"), head_sha1))
+ if (read_ref("HEAD", head_sha1))
die("No HEAD -- no initial commit yet?\n");
- if (read_ref(git_path("MERGE_HEAD"), merge_head_sha1)) {
+ if (read_ref("MERGE_HEAD", merge_head_sha1)) {
fprintf(stderr, "Not in the middle of a merge.\n");
exit(0);
}
@@ -443,7 +443,7 @@ static int do_reupdate(int ac, const char **av,
int has_head = 1;
const char **pathspec = get_pathspec(prefix, av + 1);
- if (read_ref(git_path("HEAD"), head_sha1))
+ if (read_ref("HEAD", head_sha1))
/* If there is no HEAD, that means it is an initial
* commit. Update everything in the index.
*/
diff --git a/refs.c b/refs.c
index 40f16af185..2cef2b4f0e 100644
--- a/refs.c
+++ b/refs.c
@@ -447,9 +447,7 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
return lock;
}
-static struct ref_lock *lock_ref_sha1_basic(const char *ref,
- int plen,
- const unsigned char *old_sha1, int mustexist)
+static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1, int mustexist)
{
char *ref_file;
const char *orig_ref = ref;
@@ -472,7 +470,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref,
lock->ref_name = xstrdup(ref);
lock->log_file = xstrdup(git_path("logs/%s", ref));
- ref_file = git_path(ref);
+ ref_file = git_path("%s", ref);
lock->force_write = lstat(ref_file, &st) && errno == ENOENT;
if (safe_create_leading_directories(ref_file))
@@ -489,14 +487,13 @@ struct ref_lock *lock_ref_sha1(const char *ref,
if (check_ref_format(ref))
return NULL;
strcpy(refpath, mkpath("refs/%s", ref));
- return lock_ref_sha1_basic(refpath, strlen(refpath),
- old_sha1, mustexist);
+ return lock_ref_sha1_basic(refpath, old_sha1, mustexist);
}
struct ref_lock *lock_any_ref_for_update(const char *ref,
const unsigned char *old_sha1, int mustexist)
{
- return lock_ref_sha1_basic(ref, strlen(ref), old_sha1, mustexist);
+ return lock_ref_sha1_basic(ref, old_sha1, mustexist);
}
void unlock_ref(struct ref_lock *lock)