Commit 6570a66d534155e8cfc35bc2023b9f655a6f30eb

Stefan Sperling 2019-11-08T11:18:29

make 'tog log' show abbreviated commit IDs if the window is large enough suggested by landry@

diff --git a/tog/tog.c b/tog/tog.c
index 07efa35..0ff3b62 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1088,6 +1088,18 @@ draw_commit(struct tog_view *view, struct got_commit_object *commit,
 	if (col > avail)
 		goto done;
 
+	if (avail >= 120) {
+		char *id_str;
+		err = got_object_id_str(&id_str, id);
+		if (err)
+			goto done;
+		wprintw(view->window, "%.8s ", id_str);
+		free(id_str);
+		col += 9;
+		if (col > avail)
+			goto done;
+	}
+
 	author = strdup(got_object_commit_get_author(commit));
 	if (author == NULL) {
 		err = got_error_from_errno("strdup");