[ostree] Don't default to "master", require a branch
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] Don't default to "master", require a branch
- Date: Fri, 28 Oct 2011 01:43:37 +0000 (UTC)
commit ee4edf114bc4d5dc97b15031a7633d97292d6675
Author: Colin Walters <walters verbum org>
Date: Thu Oct 27 21:40:42 2011 -0400
Don't default to "master", require a branch
It doesn't really make sense to have a default branch, since we expect
people to have multiple roots. Thus, require a branch
specification always.
parallel-debian/gnomeos-make-image.sh | 8 +++---
src/libostree/ostree-repo.c | 36 ++++++++++++++++++-------------
src/libostree/ostree-repo.h | 6 +++-
src/ot-builtin-commit.c | 13 +++++++++-
src/ot-builtin-log.c | 12 ++++++++--
tests/libtest.sh | 8 +++---
tests/t0002-commit-one.sh | 4 +-
tests/t0003-commit-multiple.sh | 4 +-
tests/t0004-checkout-test1.sh | 2 +-
tests/t0005-nested-tree.sh | 2 +-
tests/t0006-removal.sh | 6 ++--
tests/t0007-commit-stdin.sh | 6 ++--
tests/t0008-log.sh | 2 +-
tests/t0009-commit-symlink.sh | 4 +-
tests/t0010-multiple-branches.sh | 37 +++++++++++++++++++++++++++++++++
15 files changed, 105 insertions(+), 45 deletions(-)
---
diff --git a/parallel-debian/gnomeos-make-image.sh b/parallel-debian/gnomeos-make-image.sh
index de3c30a..4a4fbc7 100755
--- a/parallel-debian/gnomeos-make-image.sh
+++ b/parallel-debian/gnomeos-make-image.sh
@@ -121,7 +121,7 @@ if ! test -d ${OBJ}; then
done
$OSTREE init --repo=ostree/repo
- (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Initial import' --repo=../repo --from-stdin)
+ (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -b gnomeos -s 'Initial import' --repo=../repo --from-stdin)
)
if test -d ${OBJ}; then
mv ${OBJ} ${OBJ}.old
@@ -142,15 +142,15 @@ if ! test -d ${OBJ}; then
cp ${SRCDIR}/debian-setup.sh ostree/gnomeos-origin/
chroot ostree/gnomeos-origin ./debian-setup.sh
rm ostree/gnomeos-origin/debian-setup.sh
- (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Run debian-setup.sh' --repo=../repo --from-stdin)
+ (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -b gnomeos -s 'Run debian-setup.sh' --repo=../repo --from-stdin)
# This is the name for the real rootfs, not the chroot
(cd ostree/gnomeos-origin;
mkdir sysroot;
- $OSTREE commit -s 'Add sysroot' --repo=../repo --add=sysroot)
+ $OSTREE commit -b gnomeos -s 'Add sysroot' --repo=../repo --add=sysroot)
(cd ostree;
- rev=$($OSTREE rev-parse --repo=repo master)
+ rev=$($OSTREE rev-parse --repo=repo gnomeos)
$OSTREE checkout --repo=repo ${rev} gnomeos-${rev}
$OSTREE run-triggers --repo=repo gnomeos-${rev}
ln -s gnomeos-${rev} current
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 2f9ff5d..964ce69 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1452,15 +1452,16 @@ import_root (OstreeRepo *self,
gboolean
ostree_repo_commit (OstreeRepo *self,
- const char *branch,
- const char *subject,
- const char *body,
- GVariant *metadata,
- const char *base,
- GPtrArray *modified_files,
- GPtrArray *removed_files,
- GChecksum **out_commit,
- GError **error)
+ const char *branch,
+ const char *parent,
+ const char *subject,
+ const char *body,
+ GVariant *metadata,
+ const char *base,
+ GPtrArray *modified_files,
+ GPtrArray *removed_files,
+ GChecksum **out_commit,
+ GError **error)
{
OstreeRepoPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE;
@@ -1473,11 +1474,13 @@ ostree_repo_commit (OstreeRepo *self,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (priv->inited, FALSE);
+ g_return_val_if_fail (branch != NULL, FALSE);
+ g_return_val_if_fail (subject != NULL, FALSE);
- if (branch == NULL)
- branch = "master";
+ if (parent == NULL)
+ parent = branch;
- if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
+ if (!resolve_rev (self, parent, TRUE, ¤t_head, error))
goto out;
if (current_head)
@@ -1529,6 +1532,7 @@ ostree_repo_commit (OstreeRepo *self,
gboolean
ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
const char *branch,
+ const char *parent,
const char *subject,
const char *body,
GVariant *metadata,
@@ -1553,15 +1557,17 @@ ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (priv->inited, FALSE);
+ g_return_val_if_fail (branch != NULL, FALSE);
+ g_return_val_if_fail (subject != NULL, FALSE);
- if (branch == NULL)
- branch = "master";
+ if (parent == NULL)
+ parent = branch;
/* We're overwriting the tree */
if (!import_root (self, base, &root, error))
goto out;
- if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
+ if (!resolve_rev (self, parent, TRUE, ¤t_head, error))
goto out;
in = (GUnixInputStream*)g_unix_input_stream_new (fd, FALSE);
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 2279109..c0159ea 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -70,8 +70,9 @@ gboolean ostree_repo_load_variant (OstreeRepo *self,
GVariant **out_variant,
GError **error);
-gboolean ostree_repo_commit (OstreeRepo *self,
+gboolean ostree_repo_commit (OstreeRepo *self,
const char *branch,
+ const char *parent,
const char *subject,
const char *body,
GVariant *metadata,
@@ -81,8 +82,9 @@ gboolean ostree_repo_commit (OstreeRepo *self,
GChecksum **out_commit,
GError **error);
-gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
+gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
const char *branch,
+ const char *parent,
const char *subject,
const char *body,
GVariant *metadata,
diff --git a/src/ot-builtin-commit.c b/src/ot-builtin-commit.c
index 339a026..19af39b 100644
--- a/src/ot-builtin-commit.c
+++ b/src/ot-builtin-commit.c
@@ -33,6 +33,7 @@ static gboolean from_stdin;
static char *from_file;
static char *subject;
static char *body;
+static char *parent;
static char *branch;
static char **additions;
static char **removals;
@@ -42,6 +43,7 @@ static GOptionEntry options[] = {
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
+ { "parent", 'p', 0, G_OPTION_ARG_STRING, &parent, "Parent commit", "commit" },
{ "from-fd", 0, 0, G_OPTION_ARG_INT, &from_fd, "Read new tree files from fd", "file descriptor" },
{ "from-stdin", 0, 0, G_OPTION_ARG_NONE, &from_stdin, "Read new tree files from stdin", "file descriptor" },
{ "from-file", 0, 0, G_OPTION_ARG_FILENAME, &from_file, "Read new tree files from another file", "path" },
@@ -95,6 +97,13 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
goto out;
}
+ if (!branch)
+ {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "A branch must be specified with --branch");
+ goto out;
+ }
+
if (!subject)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -115,7 +124,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
for (iter = removals; *iter; iter++)
g_ptr_array_add (removals_array, *iter);
- if (!ostree_repo_commit (repo, branch, subject, body, NULL,
+ if (!ostree_repo_commit (repo, branch, parent, subject, body, NULL,
prefix, additions_array,
removals_array,
&commit_checksum,
@@ -139,7 +148,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
}
from_fd = temp_fd;
}
- if (!ostree_repo_commit_from_filelist_fd (repo, branch, subject, body, NULL,
+ if (!ostree_repo_commit_from_filelist_fd (repo, branch, parent, subject, body, NULL,
prefix, from_fd, separator,
&commit_checksum, error))
{
diff --git a/src/ot-builtin-log.c b/src/ot-builtin-log.c
index 0bf5f68..11ca664 100644
--- a/src/ot-builtin-log.c
+++ b/src/ot-builtin-log.c
@@ -40,8 +40,8 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
GOutputStream *pager = NULL;
+ const char *rev;
GVariant *commit = NULL;
- const char *rev = "master";
char *resolved_rev;
context = g_option_context_new ("- Show revision log");
@@ -55,8 +55,14 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
if (prefix == NULL)
prefix = ".";
- if (argc > 1)
- rev = argv[1];
+ if (argc < 2)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "A revision must be specified");
+ goto out;
+ }
+
+ rev = argv[1];
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 3429345..cedf537 100644
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -60,8 +60,8 @@ setup_test_repository1 () {
ot_repo="--repo=../repo"
export ot_repo
ostree init $ot_repo
- ostree commit $ot_repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
- ostree commit $ot_repo -s "Test Commit 2" -m "Commit body second" --add=secondfile
+ ostree commit $ot_repo -b test -s "Test Commit 1" -m "Commit body first" --add=firstfile
+ ostree commit $ot_repo -b test -s "Test Commit 2" -m "Commit body second" --add=secondfile
ostree fsck -q $ot_repo
}
@@ -86,8 +86,8 @@ setup_test_repository2 () {
cd ../files
export ot_repo
ostree init $ot_repo
- ostree commit $ot_repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
- ostree commit $ot_repo -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
+ ostree commit $ot_repo -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile
+ ostree commit $ot_repo -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
ostree fsck -q $ot_repo
}
diff --git a/tests/t0002-commit-one.sh b/tests/t0002-commit-one.sh
index 0978d56..5f18159 100755
--- a/tests/t0002-commit-one.sh
+++ b/tests/t0002-commit-one.sh
@@ -32,9 +32,9 @@ mkdir ../repo
repo="--repo=../repo"
ostree init $repo
echo 'ok init'
-ostree commit $repo -s "Test Commit" -m "Commit body" --add=yy
+ostree commit $repo -b test -s "Test Commit" -m "Commit body" --add=yy
echo 'ok commit'
ostree fsck -q $repo
echo 'ok fsck'
-ostree rev-parse
+ostree rev-parse $repo test
echo 'ok rev-parse'
diff --git a/tests/t0003-commit-multiple.sh b/tests/t0003-commit-multiple.sh
index b517d96..74f8de6 100755
--- a/tests/t0003-commit-multiple.sh
+++ b/tests/t0003-commit-multiple.sh
@@ -33,9 +33,9 @@ mkdir ../repo
repo="--repo=../repo"
ostree init $repo
echo 'ok init'
-ostree commit $repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
+ostree commit $repo -b test -s "Test Commit 1" -m "Commit body first" --add=firstfile
echo 'ok commit 1'
-ostree commit $repo -s "Test Commit 2" -m "Commit body first" --add=secondfile
+ostree commit $repo -b test -s "Test Commit 2" -m "Commit body first" --add=secondfile
echo 'ok commit 2'
ostree fsck -q $repo
echo 'ok fsck'
diff --git a/tests/t0004-checkout-test1.sh b/tests/t0004-checkout-test1.sh
index 2e00b1f..7d2cb3d 100755
--- a/tests/t0004-checkout-test1.sh
+++ b/tests/t0004-checkout-test1.sh
@@ -26,7 +26,7 @@ echo '1..3'
setup_test_repository1
echo 'ok setup'
-ostree checkout $ot_repo master $test_tmpdir/checkout1-head
+ostree checkout $ot_repo test $test_tmpdir/checkout1-head
echo 'ok checkout cmd'
cd $test_tmpdir/checkout1-head
assert_has_file firstfile
diff --git a/tests/t0005-nested-tree.sh b/tests/t0005-nested-tree.sh
index 574e4c5..239a60e 100755
--- a/tests/t0005-nested-tree.sh
+++ b/tests/t0005-nested-tree.sh
@@ -26,7 +26,7 @@ echo '1..5'
setup_test_repository2
echo 'ok setup'
-ostree checkout $ot_repo master $test_tmpdir/checkout2-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
echo 'ok checkout cmd'
cd $test_tmpdir/checkout2-head
assert_has_file firstfile
diff --git a/tests/t0006-removal.sh b/tests/t0006-removal.sh
index 65174e4..4b2d431 100755
--- a/tests/t0006-removal.sh
+++ b/tests/t0006-removal.sh
@@ -25,14 +25,14 @@ set -e
echo '1..4'
setup_test_repository2
-ostree checkout $ot_repo master $test_tmpdir/checkout2-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
echo 'ok setup'
cd $test_tmpdir/checkout2-head
-ostree commit -s delete $ot_repo -r firstfile
+ostree commit $ot_repo -b test2 -s delete -r firstfile
echo 'ok rm firstfile'
assert_has_file firstfile # It should still exist in this checkout
cd $test_tmpdir
-ostree checkout $ot_repo master $test_tmpdir/checkout3-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout3-head
echo 'ok checkout 3'
cd $test_tmpdir/checkout3-head
assert_not_has_file firstfile
diff --git a/tests/t0007-commit-stdin.sh b/tests/t0007-commit-stdin.sh
index 79f1551..ce5a48c 100755
--- a/tests/t0007-commit-stdin.sh
+++ b/tests/t0007-commit-stdin.sh
@@ -25,7 +25,7 @@ set -e
echo "1..2"
setup_test_repository2
-ostree checkout $ot_repo master $test_tmpdir/checkout2-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
cd $test_tmpdir/checkout2-head
mkdir -p a/nested/tree
echo one > a/nested/tree/1
@@ -39,9 +39,9 @@ mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1
echo whee2 > another/whee
# FIXME - remove grep for .
-find | grep -v '^\.$' | ostree commit $ot_repo --from-stdin -s "From find"
+find | grep -v '^\.$' | ostree commit $ot_repo -b test2 -s "From find" --from-stdin
echo "ok commit stdin"
-ostree checkout $ot_repo master $test_tmpdir/checkout3-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout3-head
cd $test_tmpdir/checkout3-head
assert_has_file a/nested/2
assert_file_has_content a/nested/2 'two2'
diff --git a/tests/t0008-log.sh b/tests/t0008-log.sh
index d75893e..1916542 100755
--- a/tests/t0008-log.sh
+++ b/tests/t0008-log.sh
@@ -25,7 +25,7 @@ set -e
echo "1..1"
setup_test_repository2
-ostree log $ot_repo > $test_tmpdir/log.txt
+ostree log $ot_repo test2 > $test_tmpdir/log.txt
assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
echo "ok log"
diff --git a/tests/t0009-commit-symlink.sh b/tests/t0009-commit-symlink.sh
index ae725de..ad9ad98 100755
--- a/tests/t0009-commit-symlink.sh
+++ b/tests/t0009-commit-symlink.sh
@@ -26,10 +26,10 @@ echo "1..2"
setup_test_repository2
-ostree checkout $ot_repo master $test_tmpdir/checkout2-head
+ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
cd $ht_files
ln -s foo bar
-ostree commit $ot_repo -s "Add a symlink" -m "To test it" --add=bar
+ostree commit $ot_repo -b test2 -s "Add a symlink" -m "To test it" --add=bar
echo "ok commit symlink"
ostree fsck $ot_repo
echo "ok fsck"
diff --git a/tests/t0010-multiple-branches.sh b/tests/t0010-multiple-branches.sh
new file mode 100755
index 0000000..fc94baa
--- /dev/null
+++ b/tests/t0010-multiple-branches.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Author: Colin Walters <walters verbum org>
+
+set -e
+
+. libtest.sh
+
+echo '1..3'
+
+setup_test_repository2
+ostree checkout $ot_repo test2 $test_tmpdir/checkout2-head
+cd $test_tmpdir/checkout2-head
+echo test3file > test3file
+ostree commit $ot_repo -s 'Add test3file' -b test3 -p test2 --add test3file
+echo "ok commit test3 branch"
+ostree checkout $ot_repo test3 $test_tmpdir/checkout3-head
+echo "ok checkout test3 branch"
+cd $test_tmpdir/checkout3-head
+assert_has_file test3file
+echo "ok checkout test3file"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]