Commit Diff


commit - 9270e621f7d5356871bae1d9d6a82373234a8987
commit + b7165be31e6f0e737f415f628abe4cd4e7e1a53a
blob - b4d264aa69372c6b8bce412448e7c419f1590e54
blob + ff123af7b716478317257a00a538cf50668c4311
--- tog/tog.c
+++ tog/tog.c
@@ -47,6 +47,7 @@
 #include "got_utf8.h"
 #include "got_blame.h"
 #include "got_privsep.h"
+#include "got_worktree.h"
 
 #ifndef MIN
 #define	MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
@@ -1686,7 +1687,16 @@ cmd_log(int argc, char *argv[])
 		goto done;
 	}
 	if (repo_path == NULL) {
-		repo_path = strdup(cwd);
+		struct got_worktree *worktree;
+		error = got_worktree_open(&worktree, cwd);
+		if (error && error->code != GOT_ERR_NOT_WORKTREE)
+			goto done;
+		if (worktree) {
+			repo_path =
+			    strdup(got_worktree_get_repo_path(worktree));
+			got_worktree_close(worktree);
+		} else
+			repo_path = strdup(cwd);
 		if (repo_path == NULL) {
 			error = got_error_from_errno();
 			goto done;