Commit Diff


commit - 29efeeddc18828c36f1a6df50e05297a51a1a396
commit + 9cd447eb681a736f222bbe134ca37c1fb30cfa89
blob - 6d3e738e1220743df1fd30ba6a2779ff5b504e3e
blob + b36e61c3235f83e985356cd25d8fb8657cc2f6c8
--- tog/tog.c
+++ tog/tog.c
@@ -2321,6 +2321,9 @@ build_refs_str(char **refs_str, struct got_reflist_hea
 	const char *name;
 
 	*refs_str = NULL;
+
+	if (refs == NULL)
+		return NULL;
 
 	TAILQ_FOREACH(re, refs, entry) {
 		struct got_tag_object *tag = NULL;
@@ -2496,8 +2499,7 @@ draw_commit(struct tog_view *view, struct got_commit_o
 
 	/* Prepend reference labels to log message if possible .*/
 	refs = got_reflist_object_id_map_lookup(tog_refs_idmap, id);
-	if (refs)
-		err = build_refs_str(&refs_str, refs, id, s->repo);
+	err = build_refs_str(&refs_str, refs, id, s->repo);
 	if (err)
 		goto done;
 	if (refs_str) {
@@ -2777,12 +2779,10 @@ draw_commits(struct tog_view *view)
 			return err;
 		refs = got_reflist_object_id_map_lookup(tog_refs_idmap,
 		    s->selected_entry->id);
-		if (refs) {
-			err = build_refs_str(&refs_str, refs,
-			    s->selected_entry->id, s->repo);
-			if (err)
-				goto done;
-		}
+		err = build_refs_str(&refs_str, refs, s->selected_entry->id,
+		    s->repo);
+		if (err)
+			goto done;
 	}
 
 	if (s->thread_args.commits_needed == 0 && !using_mock_io)
@@ -4965,11 +4965,9 @@ write_commit_info(struct got_diff_line **lines, size_t
 	off_t outoff = 0;
 	int n;
 
-	if (refs) {
-		err = build_refs_str(&refs_str, refs, commit_id, repo);
-		if (err)
-			return err;
-	}
+	err = build_refs_str(&refs_str, refs, commit_id, repo);
+	if (err)
+		return err;
 
 	err = got_object_open_as_commit(&commit, repo, commit_id);
 	if (err)