[ostree] main: Support passing bare directory names to commit
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] main: Support passing bare directory names to commit
- Date: Wed, 28 Aug 2013 21:33:09 +0000 (UTC)
commit c9d7050d3dcbd76a92c0dbbfb3aa9146b4fe8e1a
Author: Colin Walters <walters verbum org>
Date: Wed Aug 28 17:32:21 2013 -0400
main: Support passing bare directory names to commit
It segfaulted before if you passed non-options, and a single directory
name is probably what people want.
src/ostree/ot-builtin-commit.c | 12 ++++++++++--
tests/test-basic.sh | 9 ++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 7558ef4..a62aa8b 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -212,7 +212,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
mtree = ostree_mutable_tree_new ();
- if (argc == 1 && (opt_trees == NULL || opt_trees[0] == NULL))
+ if (argc <= 1 && (opt_trees == NULL || opt_trees[0] == NULL))
{
char *current_dir = g_get_current_dir ();
arg = g_file_new_for_path (current_dir);
@@ -222,7 +222,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
cancellable, error))
goto out;
}
- else
+ else if (opt_trees != NULL)
{
const char *const*tree_iter;
const char *tree;
@@ -276,6 +276,14 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
}
}
}
+ else
+ {
+ g_assert (argc > 1);
+ arg = g_file_new_for_path (argv[1]);
+ if (!ostree_repo_stage_directory_to_mtree (repo, arg, mtree, modifier,
+ cancellable, error))
+ goto out;
+ }
if (mode_adds && g_hash_table_size (mode_adds) > 0)
{
diff --git a/tests/test-basic.sh b/tests/test-basic.sh
index de372bd..0c17fc5 100755
--- a/tests/test-basic.sh
+++ b/tests/test-basic.sh
@@ -19,7 +19,7 @@
set -e
-echo "1..39"
+echo "1..40"
. $(dirname $0)/libtest.sh
@@ -275,3 +275,10 @@ $OSTREE reset test6 $checksum1
$OSTREE show test6 > show-output
assert_file_has_content show-output "commit $checksum1"
echo "ok basic reset"
+
+cd ${test_tmpdir}
+rm checkout-test2 -rf
+$OSTREE checkout test2 checkout-test2
+touch checkout-test2/sometestfile
+$OSTREE commit -s sometest -b test2 checkout-test2
+echo "ok commit with directory filename"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]