path: root/builtin-fmt-merge-msg.c
diff options
authorLinus Torvalds <>2006-11-17 06:57:20 (GMT)
committerJunio C Hamano <>2006-11-17 07:45:57 (GMT)
commit6b1f8c32b1a602734f14b9cf8a9f59a767752677 (patch)
tree94da67b1ece907d6d3838c24a06686431d0fdca8 /builtin-fmt-merge-msg.c
parentd09e79cb1c474b3bb323356e6d1072922ab7ccb2 (diff)
"git fmt-merge-msg" SIGSEGV
Ok, this is a _really_ stupid case, and I don't think it matters, but hey, we should never SIGSEGV. Steps to reproduce: mkdir duh cd duh git init-db git-fmt-merge-msg < /dev/null will cause a SIGSEGV in cmd_fmt_merge_msg(), because we're doing a strncmp() with a NULL current_branch. And yeah, it's an insane schenario, and no, it doesn't really matter. The only reason I noticed was that a broken version of my "git pull" into an empty directory would cause this. This silly patch just replaces the SIGSEGV with a controlled exit with an error message. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin-fmt-merge-msg.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 3d3097d..87d3d63 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -278,6 +278,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
/* get current branch */
current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
+ if (!current_branch)
+ die("No current branch");
if (!strncmp(current_branch, "refs/heads/", 11))
current_branch += 11;