git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix bad usage of mkpath in builtin-branch.sh

From
LHLars Hjemli <hjemli@gmail.com>
Date
Oct 24, 2006, 01:59 UTC
Message-ID
<1161655176461-git-send-email-hjemli@gmail.com>

When checking if a branch start point referred to a commit-object, the result of mkpath() was used as argument to get_sha1(), which didn't work out as planned.

Now it's xstrdup'd first.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 builtin-branch.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index ffc2db0..f86bf68 100755
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -125,6 +125,7 @@ static void create_branch(const char *na
 	struct ref_lock *lock;
 	unsigned char sha1[20];
 	char ref[PATH_MAX], msg[PATH_MAX + 20];
+	const char *commitref;
 
 	snprintf(ref, sizeof ref, "refs/heads/%s", name);
 	if (check_ref_format(ref))
@@ -137,8 +138,10 @@ static void create_branch(const char *na
 			die("Cannot force update the current branch.");
 	}
 
-	if (get_sha1(mkpath("%s^0", start), sha1))
+	commitref = xstrdup(mkpath("%s^0", start));
+	if (get_sha1(commitref, sha1))
 		die("Not a valid branch point: '%s'.", start);
+	free(commitref);
 
 	lock = lock_any_ref_for_update(ref, NULL);
 	if (!lock)
-- 
1.4.3.1.ga4cc-dirty
Next: Junio C Hamano
Message 1 of 7 in “Fix bad usage of mkpath in builtin-branch.sh”
  1. Fix bad usage of mkpath in builtin-branch.shLars Hjemli, Oct 24, 2006
  2. Junio C HamanoOct 24, 2006
  3. Petr BaudisOct 24, 2006
  4. Junio C HamanoOct 25, 2006
  5. Junio C HamanoOct 25, 2006
  6. Petr BaudisOct 25, 2006
  7. Junio C HamanoOct 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.