trim author names in tog log view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/tog/tog.c b/tog/tog.c
index b730cfb..66799db 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -90,26 +90,43 @@ draw_commit(struct got_commit_object *commit, struct got_object_id *id,
{
const struct got_error *err = NULL;
char *logmsg0 = NULL, *logmsg = NULL;
- char *newline;
+ char *author0 = NULL, *author = NULL;
+ char *newline, *smallerthan;
char *line = NULL;
- char *id_str;
+ char *id_str = NULL;
size_t len;
err = got_object_id_str(&id_str, id);
if (err)
return err;
logmsg0 = strdup(commit->logmsg);
- if (logmsg0 == NULL)
- return got_error_from_errno();
+ if (logmsg0 == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
logmsg = logmsg0;
while (*logmsg == '\n')
logmsg++;
newline = strchr(logmsg, '\n');
- if (newline != NULL)
+ if (newline)
*newline = '\0';
- if (asprintf(&line, "%.8s %.35s %s", id_str, commit->author,
- logmsg) == -1) {
+ author0 = strdup(commit->author);
+ if (author0 == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
+ author = author0;
+ smallerthan = strchr(author, '<');
+ if (smallerthan)
+ *smallerthan = '\0';
+ else {
+ char *at = strchr(author, '@');
+ if (at)
+ *at = '\0';
+ }
+
+ if (asprintf(&line, "%.8s %.20s %s", id_str, author, logmsg) == -1) {
err = got_error_from_errno();
goto done;
}
@@ -123,7 +140,9 @@ draw_commit(struct got_commit_object *commit, struct got_object_id *id,
waddch(tog_log_view.window, '\n');
done:
free(logmsg0);
+ free(author0);
free(line);
+ free(id_str);
return err;
}
struct commit_queue_entry {