summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aac64c1)
raw | patch | inline | side by side (parent: aac64c1)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 26 Nov 2006 20:09:59 +0000 (21:09 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 26 Nov 2006 20:15:29 +0000 (21:15 +0100) |
This is also a nice cleanup so the code uses chomp_string() instead of
"custom" removal of spaces.
"custom" removal of spaces.
tig.c | patch | blob | history |
index 3b320e666911805feef2ad5a6ea2d359299f918c..8d5f6563d85809a1f2fc80a2e03b7cd47304550e 100644 (file)
--- a/tig.c
+++ b/tig.c
case LINE_AUTHOR:
{
+ /* Parse author lines where the name may be empty:
+ * author <email@address.tld> 1138474660 +0100
+ */
char *ident = line + STRING_SIZE("author ");
- char *end = strchr(ident, '<');
+ char *nameend = strchr(ident, '<');
+ char *emailend = strchr(ident, '>');
- if (!commit)
+ if (!commit || !nameend || !emailend)
break;
- if (end) {
- char *email = end + 1;
-
- for (; end > ident && isspace(end[-1]); end--) ;
-
- if (end == ident && *email) {
- ident = email;
- end = strchr(ident, '>');
- for (; end > ident && isspace(end[-1]); end--) ;
- }
- *end = 0;
+ *nameend = *emailend = 0;
+ ident = chomp_string(ident);
+ if (!*ident) {
+ ident = chomp_string(nameend + 1);
+ if (!*ident)
+ ident = "Unknown";
}
- /* End is NULL or ident meaning there's no author. */
- if (end <= ident)
- ident = "Unknown";
-
string_copy(commit->author, ident);
/* Parse epoch and timezone */
- if (end) {
- char *secs = strchr(end + 1, '>');
- char *zone;
- time_t time;
-
- if (!secs || secs[1] != ' ')
- break;
+ if (emailend[1] == ' ') {
+ char *secs = emailend + 2;
+ char *zone = strchr(secs, ' ');
+ time_t time = (time_t) atol(secs);
- secs += 2;
- time = (time_t) atol(secs);
- zone = strchr(secs, ' ');
if (zone && strlen(zone) == STRING_SIZE(" +0700")) {
long tz;
time -= tz;
}
+
gmtime_r(&time, &commit->time);
}
break;