commit - 51a10b52c0575add67661e603b216358d68f8ed8
commit + 8924d611db93087fb80e3221b1876b5ebabe5f0b
blob - 44a8a5ca3e055d0daa449a5cf044c5995b7e64dc
blob + ee2324cc37e9714754f8a581d0e546d0ef5f385c
--- tog/tog.c
+++ tog/tog.c
TAILQ_HEAD(tog_reflist_head, tog_reflist_entry);
struct tog_ref_view_state {
- struct got_reflist_head simplerefs; /* SIMPLEQ */
struct tog_reflist_head refs; /* TAILQ */
struct tog_reflist_entry *first_displayed_entry;
struct tog_reflist_entry *last_displayed_entry;
static const struct got_error *
ref_view_load_refs(struct tog_ref_view_state *s)
{
- const struct got_error *err;
struct got_reflist_entry *sre;
struct tog_reflist_entry *re;
- err = got_ref_list(&s->simplerefs, s->repo, NULL,
- got_ref_cmp_by_name, NULL);
- if (err)
- return err;
-
s->nrefs = 0;
- SIMPLEQ_FOREACH(sre, &s->simplerefs, entry) {
+ SIMPLEQ_FOREACH(sre, &tog_refs, entry) {
if (strncmp(got_ref_get_name(sre->ref), "refs/got/", 9) == 0)
continue;
if (re == NULL)
return got_error_from_errno("malloc");
- re->ref = sre->ref;
+ re->ref = got_ref_dup(sre->ref);
+ if (re->ref == NULL)
+ return got_error_from_errno("got_ref_dup");
re->idx = s->nrefs++;
TAILQ_INSERT_TAIL(&s->refs, re, entry);
}
+ s->first_displayed_entry = TAILQ_FIRST(&s->refs);
return NULL;
}
while (!TAILQ_EMPTY(&s->refs)) {
re = TAILQ_FIRST(&s->refs);
TAILQ_REMOVE(&s->refs, re, entry);
+ got_ref_close(re->ref);
free(re);
}
- got_ref_list_free(&s->simplerefs);
}
static const struct got_error *
s->selected_entry = 0;
s->repo = repo;
- SIMPLEQ_INIT(&s->simplerefs);
TAILQ_INIT(&s->refs);
SIMPLEQ_INIT(&s->colors);
if (err)
return err;
- s->first_displayed_entry = TAILQ_FIRST(&s->refs);
-
if (has_colors() && getenv("TOG_COLORS") != NULL) {
err = add_color(&s->colors, "^refs/heads/",
TOG_COLOR_REFS_HEADS,
ref_scroll_down(s, view->nlines - 1);
break;
case CTRL('l'):
+ tog_free_refs();
+ err = tog_load_refs(s->repo);
+ if (err)
+ break;
ref_view_free_refs(s);
err = ref_view_load_refs(s);
break;