summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-06-13 11:20:52 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-06-13 11:20:52 -0700
commitde8c359786ac9ea825eca59403ef15c961e8caae (patch)
tree1db2132983f4acc38a9088c1e0f32a5572c4683d /builtin/commit.c
parentMerge branch 'rs/diff-no-minimal' (diff)
parentcommit --amend: cope with missing display name (diff)
downloadtgif-de8c359786ac9ea825eca59403ef15c961e8caae.tar.xz
Merge branch 'jn/maint-amend-missing-name'
* jn/maint-amend-missing-name: commit --amend: cope with missing display name
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index ddf77e48e1..a4e4966319 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -462,15 +462,21 @@ static void determine_author_info(void)
if (!a)
die("invalid commit: %s", use_message);
- lb = strstr(a + 8, " <");
- rb = strstr(a + 8, "> ");
- eol = strchr(a + 8, '\n');
- if (!lb || !rb || !eol)
+ lb = strchrnul(a + strlen("\nauthor "), '<');
+ rb = strchrnul(lb, '>');
+ eol = strchrnul(rb, '\n');
+ if (!*lb || !*rb || !*eol)
die("invalid commit: %s", use_message);
- name = xstrndup(a + 8, lb - (a + 8));
- email = xstrndup(lb + 2, rb - (lb + 2));
- date = xstrndup(rb + 2, eol - (rb + 2));
+ if (lb == a + strlen("\nauthor "))
+ /* \nauthor <foo@example.com> */
+ name = xcalloc(1, 1);
+ else
+ name = xmemdupz(a + strlen("\nauthor "),
+ (lb - strlen(" ") -
+ (a + strlen("\nauthor "))));
+ email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
+ date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
}
if (force_author) {