Commit Diff


commit - 1137e0aea684188aea7444f9a2d2a82a6758c49f
commit + f43793a4e6eda593d67d4872bc7f03398fbd65d9
blob - addb2d0aed2e4857f120d66d175580a9cd586cb5
blob + 7d06061d7b3cf0058211f33baf47d15394a9028e
--- got/got.c
+++ got/got.c
@@ -2010,7 +2010,7 @@ cmd_log(int argc, char *argv[])
 			error = got_error_from_errno("asprintf");
 			goto done;
 		}
-		error = got_repo_map_path(&in_repo_path, repo, p, 1);
+		error = got_repo_map_path(&in_repo_path, repo, p, 0);
 		free(p);
 	} else
 		error = got_repo_map_path(&in_repo_path, repo, path, 1);
@@ -2909,7 +2909,7 @@ cmd_tree(int argc, char *argv[])
 				error = got_error_from_errno("asprintf");
 				goto done;
 			}
-			error = got_repo_map_path(&in_repo_path, repo, p, 1);
+			error = got_repo_map_path(&in_repo_path, repo, p, 0);
 			free(p);
 			if (error)
 				goto done;
blob - 3d2918610ec74a9c7bac32728fccb9655f178299
blob + 62d97e2d9119bef047e81d719545162be88565e2
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
@@ -71,9 +71,15 @@ function test_log_in_bare_repo {
 }
 
 function test_log_in_worktree {
-	local testroot=`test_init log_in_worktree`
-	local head_rev=`git_show_head $testroot/repo`
+	local testroot=`test_init log_in_worktree 1`
 
+	make_test_tree $testroot/repo
+	mkdir -p $testroot/repo/epsilon/d
+	echo foo > $testroot/repo/epsilon/d/foo
+	(cd $testroot/repo && git add .)
+	git_commit $testroot/repo -m "adding the test tree"
+	local head_commit=`git_show_head $testroot/repo`
+
 	got checkout $testroot/repo $testroot/wt > /dev/null
 	ret="$?"
 	if [ "$ret" != "0" ]; then
@@ -81,7 +87,7 @@ function test_log_in_worktree {
 		return 1
 	fi
 
-	echo "commit $head_rev (master)" > $testroot/stdout.expected
+	echo "commit $head_commit (master)" > $testroot/stdout.expected
 
 	for p in "" "." alpha epsilon; do
 		(cd $testroot/wt && got log $p | \
@@ -107,6 +113,18 @@ function test_log_in_worktree {
 		fi
 	done
 
+	for p in "" "." foo; do
+		(cd $testroot/wt/epsilon && got log d/$p | \
+			grep ^commit > $testroot/stdout)
+		cmp -s $testroot/stdout.expected $testroot/stdout
+		ret="$?"
+		if [ "$ret" != "0" ]; then
+			diff -u $testroot/stdout.expected $testroot/stdout
+			test_done "$testroot" "$ret"
+			return 1
+		fi
+	done
+
 	test_done "$testroot" "0"
 }
 
blob - ddf4b1a9ec47ef9b9c7ce57f81d79a49765d51ab
blob + 57bbc95ef4f3fde8a3ffa7aed1ece2043bc143e7
--- tog/tog.c
+++ tog/tog.c
@@ -2483,7 +2483,7 @@ cmd_log(int argc, char *argv[])
 	struct got_object_id *start_id = NULL;
 	char *path = NULL, *repo_path = NULL, *cwd = NULL;
 	char *start_commit = NULL, *head_ref_name = NULL;
-	int ch, log_branches = 0;
+	int ch, log_branches = 0, check_disk = 1;
 	struct tog_view *view;
 
 	SIMPLEQ_INIT(&refs);
@@ -2592,6 +2592,17 @@ cmd_log(int argc, char *argv[])
 		goto done;
 	}
 	if (worktree) {
+		const char *prefix = got_worktree_get_path_prefix(worktree);
+		char *p;
+		if (asprintf(&p, "%s%s%s", prefix,
+		    (strcmp(prefix, "/") != 0) ? "/" : "", path) == -1) {
+			error = got_error_from_errno("asprintf");
+			goto done;
+		}
+		free(path);
+		path = p;
+		check_disk = 0;
+
 		head_ref_name = strdup(
 		    got_worktree_get_head_ref_name(worktree));
 		if (head_ref_name == NULL) {
@@ -2600,7 +2611,7 @@ cmd_log(int argc, char *argv[])
 		}
 	}
 	error = open_log_view(view, start_id, &refs, repo, head_ref_name,
-	    path, 1, log_branches);
+	    path, check_disk, log_branches);
 	if (error)
 		goto done;
 	if (worktree) {