commit - 6c7ab9213e39b6a690152fe8ffb18fe1f15a9ccb
commit + e730157933b56de990631fcd0c36592713b32120
blob - 32ed25930a57db98595d201cd260b1d73b46142a
blob + c32eb50c74c9d25165e37c1ab0064520c45ea011
--- got/got.c
+++ got/got.c
goto done;
error = NULL;
- if (argc == 0)
+ if (argc == 0) {
path = strdup("");
- else if (argc == 1) {
- error = got_worktree_resolve_path(&path, worktree, argv[0]);
- if (error)
+ if (path == NULL) {
+ error = got_error_from_errno();
goto done;
+ }
+ } else if (argc == 1) {
+ if (worktree) {
+ error = got_worktree_resolve_path(&path, worktree,
+ argv[0]);
+ if (error)
+ goto done;
+ } else {
+ path = strdup(argv[0]);
+ if (path == NULL) {
+ error = got_error_from_errno();
+ goto done;
+ }
+ }
} else
usage_log();
- if (path == NULL)
- goto done;
repo_path = worktree ?
strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
blob - 1e0c31ab493c7eb86539cf585e80f33a4be1e856
blob + 2d890ea4314893d12659cc3245962719a2d2d08a
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
. ./common.sh
+function test_log_in_repo {
+ local testroot=`test_init log_in_repo`
+ local head_rev=`git_show_head $testroot/repo`
+
+ echo "commit $head_rev (master)" > $testroot/stdout.expected
+
+ for p in "" "." alpha epsilon epsilon/zeta; do
+ (cd $testroot/repo && got log $p | \
+ grep ^commit > $testroot/stdout)
+ cmp $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"
+}
+
function test_log_in_worktree {
local testroot=`test_init log_in_worktree`
local head_rev=`git_show_head $testroot/repo`
test_done "$testroot" "0"
}
+run_test test_log_in_repo
run_test test_log_in_worktree