Commit Diff


commit - ad112132d7338c5233c41e6152315a31f6795a29a0eec7e513983bf9784d3b98
commit + e9e7a0c254f546e81ec08157a6068ec6b87449b4cd5cd47f2a5218a218055bd5
blob - 0483db7a8b24e3f664a5ba114f8f2ba4b9694dc2e67e49988702ee90a1be2cda
blob + c1dcc9faed6da5cfc5535858f602fc898c134e748fe02fafc8b330ef3e3b6201
--- 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;