diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 7ec68a1e8089f74ce7c70fecd86d5c18264ce4bc..b6d957cb0d2659f2207287598b3566ed37a35ae0 100644 (file)
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -695,7 +695,10 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
check_aliased_updates(commands);
+ free((char *)head_name);
head_name = resolve_ref("HEAD", sha1, 0, NULL);
+ if (head_name)
+ head_name = xstrdup(head_name);
for (cmd = commands; cmd; cmd = cmd->next)
if (!cmd->skip_update)