commit - 20b7abb3fa8e5b46bacd07df9f85cfd7edc5a4c9
commit + 603cdeb0c7bcddc1abea9ced622f6eaa82c00f35
blob - f7f14b9cb2d386242d73d208d79ef3e9df874bab
blob + 5bfcaac31178afc5018d764b995989379c1ccfe7
--- got/got.c
+++ got/got.c
error = NULL;
}
- if (argc == 0) {
- path = strdup("");
- if (path == NULL) {
- error = got_error_from_errno("strdup");
- goto done;
- }
- } else if (argc == 1) {
+ if (argc == 1) {
if (worktree) {
error = got_worktree_resolve_path(&path, worktree,
argv[0]);
goto done;
}
}
- } else
+ } else if (argc != 0)
usage_log();
if (repo_path == NULL) {
}
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;
- }
- error = got_repo_map_path(&in_repo_path, repo, p, 0);
- free(p);
+ /*
+ * If a path was specified on the command line it was resolved
+ * to a path in the work tree above. Prepend the work tree's
+ * path prefix to obtain the corresponding in-repository path.
+ */
+ if (path) {
+ const char *prefix;
+ prefix = got_worktree_get_path_prefix(worktree);
+ if (asprintf(&in_repo_path, "%s%s%s", prefix,
+ (path[0] != '\0') ? "/" : "", path) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
+ }
} else
- error = got_repo_map_path(&in_repo_path, repo, path, 1);
+ error = got_repo_map_path(&in_repo_path, repo,
+ path ? path : "", 1);
if (error != NULL)
goto done;
if (in_repo_path) {
if (error)
goto done;
- error = print_commits(start_id, end_id, repo, path, show_changed_paths,
- show_patch, search_pattern, diff_context, limit, log_branches,
- reverse_display_order, &refs);
+ error = print_commits(start_id, end_id, repo, path ? path : "",
+ show_changed_paths, show_patch, search_pattern, diff_context,
+ limit, log_branches, reverse_display_order, &refs);
done:
free(path);
free(repo_path);
blob - 74ce60ea201a8a353667c2d1ef50a71807cd2377
blob + 6d76d8908d8e38ade06083ff93a4b8757b7dab89
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
echo "modified delta" > $testroot/repo/gamma/delta
git_commit $testroot/repo -m "modified delta"
+ local delta_rev=`git_show_head $testroot/repo`
got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "commit $delta_rev (master)" > $testroot/stdout.expected
+ echo "commit $zeta_rev" >> $testroot/stdout.expected
+ echo "commit $head_rev" >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got log | 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
echo "commit $zeta_rev" > $testroot/stdout.expected
echo "commit $head_rev" >> $testroot/stdout.expected
- for p in "" "." zeta; do
+ for p in "." zeta; do
(cd $testroot/wt && got log $p | \
grep ^commit > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout