Download raw body.
fix reload of tog log work tree base commit marker
When run in a work tree, tog remembers the work tree's base commit ID
at startup and displays a ~ or a * next to this commit in the log view.
Problem: If the work tree is updated to a different base commit while
tog is running, tog will keep showing a marker on the previously cached
base commit, even if the log view is reloaded with Ctrl-L.
With the patch below, tog updates the base commit marker during Ctrl-L.
While here, drop the unused repo argument of set_tog_base_commit().
ok?
make tog log view reload work tree base commit info during Ctrl-L refresh
M tog/tog.c | 40+ 16-
1 file changed, 40 insertions(+), 16 deletions(-)
commit - d982353621b77ce15a0c2304c8dd4ab4bf58d377
commit + 4660133613429582d220b8d883b5b138a3cb1b0c
blob - f4120d83d6a20bb1906c735a5037e405bdfb9790
blob + fa1d997063a644a4ac763e75014f65aff610f0f3
--- tog/tog.c
+++ tog/tog.c
@@ -4883,11 +4883,23 @@ log_mark_commit(struct tog_log_view_state *s)
}
static const struct got_error *
+set_tog_base_commit(struct got_worktree *worktree)
+{
+ tog_base_commit.id = got_object_id_dup(
+ got_worktree_get_base_commit_id(worktree));
+ if (tog_base_commit.id == NULL)
+ return got_error_from_errno( "got_object_id_dup");
+
+ return NULL;
+}
+
+static const struct got_error *
input_log_view(struct tog_view **new_view, struct tog_view *view, int ch)
{
const struct got_error *err = NULL;
struct tog_log_view_state *s = &view->state.log;
int eos, nscroll;
+ char *cwd = NULL;
if (s->thread_args.load_all) {
if (ch == CTRL('g') || ch == KEY_BACKSPACE)
@@ -5048,6 +5060,29 @@ input_log_view(struct tog_view **new_view, struct tog_
} else /* 'B' */
s->log_branches = !s->log_branches;
+ cwd = getcwd(NULL, 0);
+ if (cwd) {
+ struct got_worktree *worktree;
+
+ err = got_worktree_open(&worktree, cwd, NULL);
+ free(cwd);
+ cwd = NULL;
+ if (err && err->code != GOT_ERR_NOT_WORKTREE)
+ return err;
+ if (worktree) {
+ err = got_worktree_get_state(
+ &tog_base_commit.marker, s->repo,
+ worktree, NULL, NULL);
+ if (err) {
+ got_worktree_close(worktree);
+ return err;
+ }
+ err = set_tog_base_commit(worktree);
+ got_worktree_close(worktree);
+ if (err)
+ return err;
+ }
+ }
if (s->thread_args.pack_fds == NULL) {
err = got_repo_pack_fds_open(&s->thread_args.pack_fds);
if (err)
@@ -5215,17 +5250,6 @@ init_curses(void)
}
static const struct got_error *
-set_tog_base_commit(struct got_repository *repo, struct got_worktree *worktree)
-{
- tog_base_commit.id = got_object_id_dup(
- got_worktree_get_base_commit_id(worktree));
- if (tog_base_commit.id == NULL)
- return got_error_from_errno( "got_object_id_dup");
-
- return NULL;
-}
-
-static const struct got_error *
get_in_repo_path_from_argv0(char **in_repo_path, int argc, char *argv[],
struct got_repository *repo, struct got_worktree *worktree)
{
@@ -5379,7 +5403,7 @@ cmd_log(int argc, char *argv[])
}
if (worktree) {
- error = set_tog_base_commit(repo, worktree);
+ error = set_tog_base_commit(worktree);
if (error != NULL)
goto done;
}
@@ -7753,7 +7777,7 @@ cmd_diff(int argc, char *argv[])
}
if (worktree) {
- error = set_tog_base_commit(repo, worktree);
+ error = set_tog_base_commit(worktree);
if (error != NULL)
goto done;
@@ -8918,7 +8942,7 @@ cmd_blame(int argc, char *argv[])
}
if (worktree) {
- error = set_tog_base_commit(repo, worktree);
+ error = set_tog_base_commit(worktree);
if (error != NULL)
goto done;
@@ -9923,7 +9947,7 @@ cmd_tree(int argc, char *argv[])
}
if (worktree) {
- error = set_tog_base_commit(repo, worktree);
+ error = set_tog_base_commit(worktree);
if (error != NULL)
goto done;
@@ -10717,7 +10741,7 @@ cmd_ref(int argc, char *argv[])
goto done;
if (worktree) {
- error = set_tog_base_commit(repo, worktree);
+ error = set_tog_base_commit(worktree);
if (error != NULL)
goto done;
fix reload of tog log work tree base commit marker