commit - 1b3893a25b982a0bd7329a9da23581024c6ac50d
commit + b70703ad8ae920fd55bd7976d1632e05975e5c63
blob - afdfaad9d4c767b121a5b9f0e740aac323254097
blob + fac0482213450d23be35c6155dd21d22aff4d48e
--- lib/repository.c
+++ lib/repository.c
{
const struct got_error *err = NULL;
const char *repo_abspath = NULL;
- struct stat sb;
size_t repolen, cwdlen, len;
char *cwd, *canonpath, *path = NULL;
goto done;
repo_abspath = got_repo_get_path(repo);
-
- /* TODO: Call "get in-repository path of work-tree node" API. */
- if (!check_disk)
+ if (!check_disk) {
path = strdup(canonpath);
- else if (lstat(canonpath, &sb) != 0) {
- if (errno != ENOENT) {
+ if (path == NULL) {
err = got_error_from_errno();
goto done;
}
- /*
- * Path is not on disk.
- * Assume it is already relative to repository root.
- */
- path = strdup(canonpath);
} else {
int is_repo_child = 0, is_cwd_child = 0;
path = realpath(canonpath, NULL);
if (path == NULL) {
- err = got_error_from_errno();
- goto done;
+ if (errno != ENOENT) {
+ err = got_error_from_errno();
+ goto done;
+ }
+ /*
+ * Path is not on disk.
+ * Assume it is already relative to repository root.
+ */
+ path = strdup(canonpath);
+ if (path == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
}
repolen = strlen(repo_abspath);
}
} else if (is_repo_child && is_cwd_child) {
char *child;
- /* TODO: Is path inside a got worktree? */
/* Strip common prefix with repository path. */
err = got_path_skip_common_ancestor(&child,
repo_abspath, path);
}
} else if (is_cwd_child) {
char *child;
- /* TODO: Is path inside a got worktree? */
/* Strip common prefix with cwd. */
err = got_path_skip_common_ancestor(&child, cwd,
path);
blob - 2d890ea4314893d12659cc3245962719a2d2d08a
blob + a5272f0679c901661f2534ddda6379d6a402314d
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
fi
done
+ for p in "" "." zeta; do
+ (cd $testroot/repo/epsilon && 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_bare_repo {
+ local testroot=`test_init log_in_bare_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/.git && 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`
}
run_test test_log_in_repo
+run_test test_log_in_bare_repo
run_test test_log_in_worktree