commit - cc63216e4c9ca57c8711120fc6028ed5d5e2dde9
commit + 51a10b52c0575add67661e603b216358d68f8ed8
blob - a28a00571d687d94f4f9215df59a0fe82423e7c9
blob + 44a8a5ca3e055d0daa449a5cf044c5995b7e64dc
--- tog/tog.c
+++ tog/tog.c
};
SIMPLEQ_HEAD(tog_colors, tog_color);
+static struct got_reflist_head tog_refs = SIMPLEQ_HEAD_INITIALIZER(tog_refs);
+static struct got_reflist_object_id_map *tog_refs_idmap;
+
static const struct got_error *
+tog_load_refs(struct got_repository *repo)
+{
+ const struct got_error *err;
+
+ err = got_ref_list(&tog_refs, repo, NULL, got_ref_cmp_by_name, NULL);
+ if (err)
+ return err;
+
+ return got_reflist_object_id_map_create(&tog_refs_idmap, &tog_refs,
+ repo);
+}
+
+static void
+tog_free_refs(void)
+{
+ if (tog_refs_idmap) {
+ got_reflist_object_map_free(tog_refs_idmap);
+ tog_refs_idmap = NULL;
+ }
+ got_ref_list_free(&tog_refs);
+}
+
+static const struct got_error *
add_color(struct tog_colors *colors, const char *pattern,
int idx, short color)
{
int ignore_whitespace;
int force_text_diff;
struct got_repository *repo;
- struct got_reflist_head refs;
- struct got_reflist_object_id_map *idmap;
struct tog_colors colors;
size_t nlines;
off_t *line_offsets;
char *head_ref_name;
int log_branches;
struct got_repository *repo;
- struct got_reflist_head refs;
- struct got_reflist_object_id_map *idmap;
struct got_object_id *start_id;
sig_atomic_t quit;
pthread_t thread;
err = got_object_id_str(&id_str, s->selected_entry->id);
if (err)
return err;
- refs = got_reflist_object_id_map_lookup(s->idmap,
+ refs = got_reflist_object_id_map_lookup(tog_refs_idmap,
s->selected_entry->id);
if (refs) {
err = build_refs_str(&refs_str, refs,
s->start_id = NULL;
free(s->head_ref_name);
s->head_ref_name = NULL;
- if (s->idmap) {
- got_reflist_object_map_free(s->idmap);
- s->idmap = NULL;
- }
- got_ref_list_free(&s->refs);
return err;
}
struct got_commit_graph *thread_graph = NULL;
int errcode;
- SIMPLEQ_INIT(&s->refs);
-
if (in_repo_path != s->in_repo_path) {
free(s->in_repo_path);
s->in_repo_path = strdup(in_repo_path);
/* The commit queue only contains commits being displayed. */
TAILQ_INIT(&s->commits.head);
s->commits.ncommits = 0;
-
- err = got_ref_list(&s->refs, repo, NULL, got_ref_cmp_by_name, NULL);
- if (err)
- goto done;
- err = got_reflist_object_id_map_create(&s->idmap, &s->refs, repo);
- if (err)
- goto done;
s->repo = repo;
if (head_ref_name) {
got_repo_get_path(s->repo), NULL);
if (err)
return err;
- if (s->idmap) {
- got_reflist_object_map_free(s->idmap);
- s->idmap = NULL;
- }
- got_ref_list_free(&s->refs);
- err = got_ref_list(&s->refs, s->repo, NULL,
- got_ref_cmp_by_name, NULL);
- if (err)
- return err;
- err = got_reflist_object_id_map_create(&s->idmap, &s->refs,
- s->repo);
+ tog_free_refs();
+ err = tog_load_refs(s->repo);
if (err)
return err;
err = got_commit_graph_open(&s->thread_args.graph,
if (error)
goto done;
+ error = tog_load_refs(repo);
+ if (error)
+ goto done;
+
if (start_commit == NULL) {
error = got_repo_match_object_id(&start_id, &label,
worktree ? got_worktree_get_head_ref_name(worktree) :
got_repo_close(repo);
if (worktree)
got_worktree_close(worktree);
+ tog_free_refs();
return error;
}
err = got_object_open_as_commit(&commit2, s->repo, s->id2);
if (err)
goto done;
- refs = got_reflist_object_id_map_lookup(s->idmap, s->id2);
+ refs = got_reflist_object_id_map_lookup(tog_refs_idmap, s->id2);
/* Show commit info if we're diffing to a parent/root commit. */
if (s->id1 == NULL) {
err = write_commit_info(&s->line_offsets, &s->nlines,
const struct got_error *err;
struct tog_diff_view_state *s = &view->state.diff;
- SIMPLEQ_INIT(&s->refs);
-
if (id1 != NULL && id2 != NULL) {
int type1, type2;
err = got_object_get_type(&type1, repo, id1);
}
}
- err = got_ref_list(&s->refs, repo, NULL, got_ref_cmp_by_name, NULL);
- if (err) {
- free(s->id1);
- s->id1 = NULL;
- free(s->id2);
- s->id2 = NULL;
- free_colors(&s->colors);
- return err;
- }
- err = got_reflist_object_id_map_create(&s->idmap, &s->refs, repo);
- if (err) {
- free(s->id1);
- s->id1 = NULL;
- free(s->id2);
- s->id2 = NULL;
- free_colors(&s->colors);
- got_ref_list_free(&s->refs);
- return err;
- }
-
if (log_view && view_is_splitscreen(view))
show_log_view(log_view); /* draw vborder */
diff_view_indicate_progress(view);
free(s->id2);
s->id2 = NULL;
free_colors(&s->colors);
- got_ref_list_free(&s->refs);
- got_reflist_object_map_free(s->idmap);
- s->idmap = NULL;
return err;
}
free(s->line_offsets);
s->line_offsets = NULL;
s->nlines = 0;
- if (s->idmap) {
- got_reflist_object_map_free(s->idmap);
- s->idmap = NULL;
- }
- got_ref_list_free(&s->refs);
return err;
}
init_curses();
error = apply_unveil(got_repo_get_path(repo), NULL);
+ if (error)
+ goto done;
+
+ error = tog_load_refs(repo);
if (error)
goto done;
got_repo_close(repo);
if (worktree)
got_worktree_close(worktree);
+ tog_free_refs();
return error;
}
init_curses();
error = apply_unveil(got_repo_get_path(repo), NULL);
+ if (error)
+ goto done;
+
+ error = tog_load_refs(repo);
if (error)
goto done;
got_worktree_close(worktree);
if (repo)
got_repo_close(repo);
+ tog_free_refs();
return error;
}
if (error)
goto done;
+ error = tog_load_refs(repo);
+ if (error)
+ goto done;
+
if (commit_id_arg == NULL) {
error = got_repo_match_object_id(&commit_id, &label,
worktree ? got_worktree_get_head_ref_name(worktree) :
got_object_tree_close(tree);
if (repo)
got_repo_close(repo);
+ tog_free_refs();
return error;
}
init_curses();
error = apply_unveil(got_repo_get_path(repo), NULL);
+ if (error)
+ goto done;
+
+ error = tog_load_refs(repo);
if (error)
goto done;
free(cwd);
if (repo)
got_repo_close(repo);
+ tog_free_refs();
return error;
}