main: Support using repo from current directory
$ cd repo $ ostree ls foo / ... Can be a lot more convenient than typing --repo=repo a lot.
This commit is contained in:
parent
3de1d6589a
commit
187c75eae5
|
|
@ -115,9 +115,6 @@ ostree_run (int argc,
|
||||||
else if (g_file_test (host_repo_path, G_FILE_TEST_EXISTS))
|
else if (g_file_test (host_repo_path, G_FILE_TEST_EXISTS))
|
||||||
repo = host_repo_path;
|
repo = host_repo_path;
|
||||||
|
|
||||||
if (repo)
|
|
||||||
repo_file = g_file_new_for_path (repo);
|
|
||||||
|
|
||||||
if (!have_repo_arg)
|
if (!have_repo_arg)
|
||||||
{
|
{
|
||||||
arg_off = 2;
|
arg_off = 2;
|
||||||
|
|
@ -148,12 +145,23 @@ ostree_run (int argc,
|
||||||
|
|
||||||
if (repo == NULL && !(command->flags & OSTREE_BUILTIN_FLAG_NO_REPO))
|
if (repo == NULL && !(command->flags & OSTREE_BUILTIN_FLAG_NO_REPO))
|
||||||
{
|
{
|
||||||
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
if (g_file_test ("objects", G_FILE_TEST_IS_DIR)
|
||||||
"Command requires a --repo argument");
|
&& g_file_test ("config", G_FILE_TEST_IS_REGULAR))
|
||||||
ostree_usage (argv, commands, TRUE);
|
{
|
||||||
goto out;
|
repo = ".";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Command requires a --repo argument");
|
||||||
|
ostree_usage (argv, commands, TRUE);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (repo)
|
||||||
|
repo_file = g_file_new_for_path (repo);
|
||||||
|
|
||||||
ostree_prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
|
ostree_prep_builtin_argv (cmd, argc-arg_off, argv+arg_off, &cmd_argc, &cmd_argv);
|
||||||
|
|
||||||
if (!command->fn (cmd_argc, cmd_argv, repo_file, cancellable, &error))
|
if (!command->fn (cmd_argc, cmd_argv, repo_file, cancellable, &error))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "1..33"
|
echo "1..34"
|
||||||
|
|
||||||
. $(dirname $0)/libtest.sh
|
. $(dirname $0)/libtest.sh
|
||||||
|
|
||||||
|
|
@ -34,6 +34,9 @@ $OSTREE rev-parse 'test2^'
|
||||||
$OSTREE rev-parse 'test2^^' 2>/dev/null && (echo 1>&2 "rev-parse test2^^ unexpectedly succeeded!"; exit 1)
|
$OSTREE rev-parse 'test2^^' 2>/dev/null && (echo 1>&2 "rev-parse test2^^ unexpectedly succeeded!"; exit 1)
|
||||||
echo "ok rev-parse"
|
echo "ok rev-parse"
|
||||||
|
|
||||||
|
(cd repo && ostree rev-parse test2)
|
||||||
|
echo "ok repo-in-cwd"
|
||||||
|
|
||||||
$OSTREE refs > reflist
|
$OSTREE refs > reflist
|
||||||
assert_file_has_content reflist '^test2$'
|
assert_file_has_content reflist '^test2$'
|
||||||
rm reflist
|
rm reflist
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue