path: root/builtin-fmt-merge-msg.c
diff options
authorLinus Torvalds <>2006-09-12 03:17:35 (GMT)
committerJunio C Hamano <>2006-09-18 02:09:11 (GMT)
commited378ec7e85fd2c5cfcc7bd64b454236357fdd97 (patch)
tree76a1666618aff73fd9184a533273b1e083858a6d /builtin-fmt-merge-msg.c
parentb37a562a1097af7403c649a5f903a93acaf279e8 (diff)
Make ref resolution saner
The old code used to totally mix up the notion of a ref-name and the path that that ref was associated with. That was not only horribly ugly (a number of users got the path, and then wanted to try to turn it back into a ref-name again), but it fundamnetally doesn't work at all once we do any setup where a ref doesn't have a 1:1 relationship with a particular pathname. This fixes things up so that we use the ref-name throughout, and only turn it into a pathname once we actually look it up in the filesystem. That makes a lot of things much clearer and more straightforward. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin-fmt-merge-msg.c')
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index c407c03..b93c17c 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -249,7 +249,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
FILE *in = stdin;
const char *sep = "";
unsigned char head_sha1[20];
- const char *head, *current_branch;
+ const char *current_branch;
@@ -277,10 +277,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
/* get current branch */
- head = xstrdup(git_path("HEAD"));
- current_branch = resolve_ref(head, head_sha1, 1);
- current_branch += strlen(head) - 4;
- free((char *)head);
+ current_branch = resolve_ref("HEAD", head_sha1, 1);
if (!strncmp(current_branch, "refs/heads/", 11))
current_branch += 11;