commit 00ddec2f20c1ce1b0136a7ae54efb790069126ec from: Omar Polo via: Thomas Adam date: Wed May 17 15:49:55 2023 UTC relax build_refs_str to allow a NULL reflist, simplifes the callers ok stsp@ commit - 5e43aca66f1762b7612d9efb4b000575f1b7a3ab commit + 00ddec2f20c1ce1b0136a7ae54efb790069126ec blob - ff292e9cadc7e6213f828308478d7827b79cb69a blob + 7dce0c320b49b2d997e618585f826a965d125d27 --- tog/tog.c +++ tog/tog.c @@ -2325,6 +2325,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; @@ -2500,8 +2503,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) { @@ -2781,12 +2783,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) @@ -4969,11 +4969,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)