diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-06-22 08:30:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-22 08:30:44 -0700 |
commit | 0d2416e06003da954f0335248c3dc7f76a3735e3 (patch) | |
tree | 51feb2bf8a2fadda52a8a293e63fe1d62502288f /builtin/commit.c | |
parent | 21919d396a3a05ccb8d6b538b246500f01585bb7 (diff) | |
parent | fb7749e4e4d4d9fef61f35b2f8b40f80c2d5942f (diff) | |
download | git-0d2416e06003da954f0335248c3dc7f76a3735e3.tar.gz git-0d2416e06003da954f0335248c3dc7f76a3735e3.tar.xz |
Merge branch 'jn/maint-amend-missing-name' into maint
* jn/maint-amend-missing-name:
commit --amend: cope with missing display name
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 3c14ade9d..278dcdfa6 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -455,15 +455,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) { |