core: Take --repo as the first argument

I kept doing this over and over...it feels more natural.  The "prefix"
thing was (almost) unused anyways, and it was easy enough to replace.
This commit is contained in:
Colin Walters 2011-11-03 23:08:28 -04:00
parent 3b61a21c0f
commit d6b3fb5118
21 changed files with 73 additions and 131 deletions

View File

@ -55,7 +55,7 @@ usage (char **argv, gboolean is_error)
else else
print_func = g_print; print_func = g_print;
print_func ("usage: %s COMMAND [options]\n", print_func ("usage: %s --repo=PATH COMMAND [options]\n",
argv[0]); argv[0]);
print_func ("Builtin commands:\n"); print_func ("Builtin commands:\n");
@ -74,6 +74,7 @@ main (int argc,
{ {
OstreeBuiltin *builtin; OstreeBuiltin *builtin;
const char *cmd; const char *cmd;
const char *repo;
g_type_init (); g_type_init ();
@ -81,10 +82,14 @@ main (int argc,
builtin = builtins; builtin = builtins;
if (argc < 2) if (argc < 3)
return usage (argv, 1); return usage (argv, 1);
cmd = argv[1]; if (!g_str_has_prefix (argv[1], "--repo="))
return usage (argv, 1);
repo = argv[1] + strlen ("--repo=");
cmd = argv[2];
while (builtin->name) while (builtin->name)
{ {
@ -95,13 +100,13 @@ main (int argc,
int tmp_argc; int tmp_argc;
char **tmp_argv; char **tmp_argv;
tmp_argc = argc - 1; tmp_argc = argc - 2;
tmp_argv = g_new0 (char *, tmp_argc + 1); tmp_argv = g_new0 (char *, tmp_argc + 1);
tmp_argv[0] = (char*)builtin->name; tmp_argv[0] = (char*)builtin->name;
for (i = 0; i < tmp_argc; i++) for (i = 0; i < tmp_argc; i++)
tmp_argv[i+1] = argv[i+2]; tmp_argv[i+1] = argv[i+3];
if (!builtin->fn (tmp_argc, tmp_argv, NULL, &error)) if (!builtin->fn (tmp_argc, tmp_argv, repo, &error))
{ {
g_free (tmp_argv); g_free (tmp_argv);
g_printerr ("%s\n", error->message); g_printerr ("%s\n", error->message);

View File

@ -26,15 +26,12 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_checkout (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -51,9 +48,6 @@ ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **err
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,7 +26,6 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static gboolean separator_null; static gboolean separator_null;
static int from_fd = -1; static int from_fd = -1;
static gboolean from_stdin; static gboolean from_stdin;
@ -39,7 +38,6 @@ static char **additions;
static char **removals; static char **removals;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" }, { "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" }, { "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" }, { "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
@ -54,11 +52,12 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_commit (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
OstreeRepo *repo = NULL; OstreeRepo *repo = NULL;
char *cwd;
gboolean using_filename_cmdline; gboolean using_filename_cmdline;
gboolean using_filedescriptors; gboolean using_filedescriptors;
GPtrArray *additions_array = NULL; GPtrArray *additions_array = NULL;
@ -66,17 +65,14 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
GChecksum *commit_checksum = NULL; GChecksum *commit_checksum = NULL;
char **iter; char **iter;
cwd = g_get_current_dir ();
context = g_option_context_new ("- Commit a new revision"); context = g_option_context_new ("- Commit a new revision");
g_option_context_add_main_entries (context, options, NULL); g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
if (prefix == NULL)
prefix = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
@ -125,7 +121,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
g_ptr_array_add (removals_array, *iter); g_ptr_array_add (removals_array, *iter);
if (!ostree_repo_commit (repo, branch, parent, subject, body, NULL, if (!ostree_repo_commit (repo, branch, parent, subject, body, NULL,
prefix, additions_array, cwd, additions_array,
removals_array, removals_array,
&commit_checksum, &commit_checksum,
error)) error))
@ -149,7 +145,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
from_fd = temp_fd; from_fd = temp_fd;
} }
if (!ostree_repo_commit_from_filelist_fd (repo, branch, parent, subject, body, NULL, if (!ostree_repo_commit_from_filelist_fd (repo, branch, parent, subject, body, NULL,
prefix, from_fd, separator, cwd, from_fd, separator,
&commit_checksum, error)) &commit_checksum, error))
{ {
if (temp_fd >= 0) if (temp_fd >= 0)
@ -163,6 +159,7 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
ret = TRUE; ret = TRUE;
g_print ("%s\n", g_checksum_get_string (commit_checksum)); g_print ("%s\n", g_checksum_get_string (commit_checksum));
out: out:
g_free (cwd);
if (context) if (context)
g_option_context_free (context); g_option_context_free (context);
g_clear_object (&repo); g_clear_object (&repo);

View File

@ -26,12 +26,9 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
#define FAST_QUERYINFO "standard::name,standard::type,standard::is-symlink,standard::symlink-target,unix::*" #define FAST_QUERYINFO "standard::name,standard::type,standard::is-symlink,standard::symlink-target,unix::*"
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
@ -214,7 +211,7 @@ compose_branch_on_dir (OstreeRepo *repo,
} }
gboolean gboolean
ostree_builtin_compose (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_compose (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -230,9 +227,6 @@ ostree_builtin_compose (int argc, char **argv, const char *prefix, GError **erro
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,11 +26,9 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static gboolean quiet; static gboolean quiet;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL }, { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL } { NULL }
}; };
@ -192,7 +190,7 @@ object_iter_callback (OstreeRepo *repo,
} }
gboolean gboolean
ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_fsck (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
HtFsckData data; HtFsckData data;
@ -205,9 +203,6 @@ ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error)
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
data.n_objects = 0; data.n_objects = 0;
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);

View File

@ -26,11 +26,9 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static gboolean archive; static gboolean archive;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", NULL },
{ "archive", 0, 0, G_OPTION_ARG_NONE, &archive, "Initialize repository as archive", NULL }, { "archive", 0, 0, G_OPTION_ARG_NONE, &archive, "Initialize repository as archive", NULL },
{ NULL } { NULL }
}; };
@ -40,7 +38,7 @@ static GOptionEntry options[] = {
gboolean gboolean
ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context = NULL; GOptionContext *context = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -55,9 +53,6 @@ ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error)
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repodir = ot_util_new_file_for_path (repo_path); repodir = ot_util_new_file_for_path (repo_path);
child = g_file_get_child (repodir, "config"); child = g_file_get_child (repodir, "config");

View File

@ -26,19 +26,17 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static gboolean ignore_exists; static gboolean ignore_exists;
static gboolean force; static gboolean force;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "ignore-exists", 'n', 0, G_OPTION_ARG_NONE, &ignore_exists, "Don't error if file exists", NULL }, { "ignore-exists", 'n', 0, G_OPTION_ARG_NONE, &ignore_exists, "Don't error if file exists", NULL },
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force, "If object exists, relink file", NULL }, { "force", 'f', 0, G_OPTION_ARG_NONE, &force, "If object exists, relink file", NULL },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_link_file (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -51,9 +49,6 @@ ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **er
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,15 +26,12 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_log (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -50,11 +47,6 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
if (prefix == NULL)
prefix = ".";
if (argc < 2) if (argc < 2)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,

View File

@ -28,10 +28,7 @@
#include <libsoup/soup-gnome.h> #include <libsoup/soup-gnome.h>
static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
@ -252,7 +249,7 @@ store_commit_recurse (OstreeRepo *repo,
} }
gboolean gboolean
ostree_builtin_pull (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_pull (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -276,9 +273,6 @@ ostree_builtin_pull (int argc, char **argv, const char *prefix, GError **error)
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,10 +26,7 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
@ -44,7 +41,7 @@ usage_error (GOptionContext *context, const char *message, GError **error)
} }
gboolean gboolean
ostree_builtin_remote (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_remote (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -59,9 +56,6 @@ ostree_builtin_remote (int argc, char **argv, const char *prefix, GError **error
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -29,12 +29,11 @@
static char *repo_path; static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_rev_parse (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_rev_parse (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -50,9 +49,6 @@ ostree_builtin_rev_parse (int argc, char **argv, const char *prefix, GError **er
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,17 +26,15 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static gboolean quiet; static gboolean quiet;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL }, { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_run_triggers (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_run_triggers (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -50,9 +48,6 @@ ostree_builtin_run_triggers (int argc, char **argv, const char *prefix, GError *
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -26,15 +26,12 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static char *repo_path;
static GOptionEntry options[] = { static GOptionEntry options[] = {
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
{ NULL } { NULL }
}; };
gboolean gboolean
ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_show (int argc, char **argv, const char *repo_path, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -51,9 +48,6 @@ ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error)
if (!g_option_context_parse (context, &argc, &argv, error)) if (!g_option_context_parse (context, &argc, &argv, error))
goto out; goto out;
if (repo_path == NULL)
repo_path = ".";
repo = ostree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;

View File

@ -32,22 +32,22 @@ typedef enum {
typedef struct { typedef struct {
const char *name; const char *name;
gboolean (*fn) (int argc, char **argv, const char *prefix, GError **error); gboolean (*fn) (int argc, char **argv, const char *repo, GError **error);
int flags; /* OstreeBuiltinFlags */ int flags; /* OstreeBuiltinFlags */
} OstreeBuiltin; } OstreeBuiltin;
gboolean ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_checkout (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_commit (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_compose (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_compose (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_init (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_log (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_link_file (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_pull (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_pull (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_run_triggers (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_run_triggers (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_fsck (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_show (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_rev_parse (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_rev_parse (int argc, char **argv, const char *repo, GError **error);
gboolean ostree_builtin_remote (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_remote (int argc, char **argv, const char *repo, GError **error);
G_END_DECLS G_END_DECLS

View File

@ -80,16 +80,16 @@ setup_test_repository () {
mkdir repo mkdir repo
cd repo cd repo
ot_repo="--repo=`pwd`" ot_repo="--repo=`pwd`"
export OSTREE="ostree ${ot_repo}"
cd ../files cd ../files
export ot_repo
if test "$mode" = "archive"; then if test "$mode" = "archive"; then
ostree init --archive $ot_repo $OSTREE init --archive
else else
ostree init $ot_repo $OSTREE init
fi fi
ostree commit $ot_repo -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile --add=somelink $OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first" --add=firstfile --add=somelink
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 --add=baz/alink $OSTREE commit -b test2 -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y --add=baz/alink
ostree fsck -q $ot_repo $OSTREE fsck -q
cd $oldpwd cd $oldpwd
} }
@ -99,20 +99,20 @@ setup_fake_remote_repo1() {
mkdir ostree-srv mkdir ostree-srv
cd ostree-srv cd ostree-srv
mkdir gnomerepo mkdir gnomerepo
ostree init --archive --repo=gnomerepo ostree --repo=gnomerepo init --archive
mkdir gnomerepo-files mkdir gnomerepo-files
cd gnomerepo-files cd gnomerepo-files
echo first > firstfile echo first > firstfile
mkdir baz mkdir baz
echo moo > baz/cow echo moo > baz/cow
echo alien > baz/saucer echo alien > baz/saucer
find | grep -v '^\.$' | ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "A remote commit" -m "Some Commit body" --from-stdin find | grep -v '^\.$' | ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "A remote commit" -m "Some Commit body" --from-stdin
mkdir baz/deeper mkdir baz/deeper
ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "Add deeper" --add=baz/deeper ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "Add deeper" --add=baz/deeper
echo hi > baz/deeper/ohyeah echo hi > baz/deeper/ohyeah
mkdir baz/another/ mkdir baz/another/
echo x > baz/another/y echo x > baz/another/y
find | grep -v '^\.$' | ostree commit --repo=${test_tmpdir}/ostree-srv/gnomerepo -b main -s "The rest" --from-stdin find | grep -v '^\.$' | ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "The rest" --from-stdin
cd .. cd ..
rm -rf gnomerepo-files rm -rf gnomerepo-files
@ -150,6 +150,8 @@ EOF
exit 1 exit 1
fi fi
cd ${oldpwd} cd ${oldpwd}
export OSTREE="ostree --repo=repo"
} }
trap 'die' EXIT trap 'die' EXIT

View File

@ -32,12 +32,12 @@ assert_streq "$(readlink ${test_tmpdir}/repo/objects/cf/443bea5eb400bc25b376c079
echo "ok check" echo "ok check"
ostree checkout $ot_repo test2 checkout-test2 $OSTREE checkout test2 checkout-test2
echo "ok checkout" echo "ok checkout"
ostree rev-parse $ot_repo test2 $OSTREE rev-parse test2
ostree rev-parse $ot_repo 'test2^' $OSTREE rev-parse 'test2^'
ostree rev-parse $ot_repo '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 checkout-test2 cd checkout-test2
@ -47,10 +47,10 @@ assert_file_has_content baz/cow moo
assert_has_file baz/deeper/ohyeah assert_has_file baz/deeper/ohyeah
echo "ok content" echo "ok content"
ostree commit $ot_repo -b test2 -s delete -r firstfile $OSTREE commit -b test2 -s delete -r firstfile
assert_has_file firstfile # It should still exist in this checkout assert_has_file firstfile # It should still exist in this checkout
cd $test_tmpdir cd $test_tmpdir
ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-2 $OSTREE checkout test2 $test_tmpdir/checkout-test2-2
cd $test_tmpdir/checkout-test2-2 cd $test_tmpdir/checkout-test2-2
assert_not_has_file firstfile assert_not_has_file firstfile
assert_has_file baz/saucer assert_has_file baz/saucer
@ -68,11 +68,11 @@ mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1 echo anotherone > another/nested/tree/1
echo whee2 > another/whee echo whee2 > another/whee
# FIXME - remove grep for . # FIXME - remove grep for .
find | grep -v '^\.$' | ostree commit $ot_repo -b test2 -s "From find" --from-stdin find | grep -v '^\.$' | $OSTREE commit -b test2 -s "From find" --from-stdin
echo "ok stdin commit" echo "ok stdin commit"
cd ${test_tmpdir} cd ${test_tmpdir}
ostree checkout $ot_repo test2 $test_tmpdir/checkout-test2-3 $OSTREE checkout test2 $test_tmpdir/checkout-test2-3
cd checkout-test2-3 cd checkout-test2-3
assert_has_file a/nested/2 assert_has_file a/nested/2
assert_file_has_content a/nested/2 'two2' assert_file_has_content a/nested/2 'two2'

View File

@ -27,7 +27,7 @@ echo '1..3'
setup_test_repository "archive" setup_test_repository "archive"
echo "ok setup" echo "ok setup"
ostree checkout $ot_repo test2 checkout-test2 $OSTREE checkout test2 checkout-test2
echo "ok checkout" echo "ok checkout"
cd checkout-test2 cd checkout-test2

View File

@ -25,7 +25,7 @@ set -e
echo "1..1" echo "1..1"
setup_test_repository "regular" setup_test_repository "regular"
ostree log $ot_repo test2 > $test_tmpdir/log.txt $OSTREE log 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 1"
assert_file_has_content $test_tmpdir/log.txt "Test Commit 2" assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
echo "ok log" echo "ok log"

View File

@ -25,7 +25,7 @@ set -e
echo '1..2' echo '1..2'
setup_test_repository "regular" setup_test_repository "regular"
ostree remote add $ot_repo origin http://example.com/ostree/gnome $OSTREE remote add origin http://example.com/ostree/gnome
echo "ok remote add" echo "ok remote add"
assert_file_has_content $test_tmpdir/repo/config "example.com" assert_file_has_content $test_tmpdir/repo/config "example.com"
echo "ok config" echo "ok config"

View File

@ -27,7 +27,7 @@ echo '1..1'
setup_fake_remote_repo1 setup_fake_remote_repo1
cd ${test_tmpdir} cd ${test_tmpdir}
mkdir repo mkdir repo
ostree init --repo=repo $OSTREE init
ostree remote --repo=repo add origin $(cat httpd-address)/ostree/gnomerepo $OSTREE remote add origin $(cat httpd-address)/ostree/gnomerepo
ostree pull --repo=repo origin main $OSTREE pull origin main
echo "ok pull" echo "ok pull"

View File

@ -26,7 +26,7 @@ echo "1..3"
setup_test_repository "regular" setup_test_repository "regular"
ostree checkout $ot_repo test2 checkout-test2 $OSTREE checkout test2 checkout-test2
cd "${test_tmpdir}" cd "${test_tmpdir}"
mkdir artifact-libfoo-runtime mkdir artifact-libfoo-runtime
@ -36,7 +36,7 @@ echo 'an ELF file' > usr/lib/libfoo.so
mkdir -p usr/share mkdir -p usr/share
echo 'some data' > usr/share/foo.data echo 'some data' > usr/share/foo.data
find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-libfoo-runtime -s 'Build 12345 of libfoo' --from-stdin find | grep -v '^\.$' | $OSTREE commit -b artifact-libfoo-runtime -s 'Build 12345 of libfoo' --from-stdin
cd "${test_tmpdir}" cd "${test_tmpdir}"
mkdir artifact-libfoo-devel mkdir artifact-libfoo-devel
@ -46,7 +46,7 @@ echo 'a header' > usr/include/foo.h
mkdir -p usr/share/doc mkdir -p usr/share/doc
echo 'some documentation' > usr/share/doc/foo.txt echo 'some documentation' > usr/share/doc/foo.txt
find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-libfoo-devel -s 'Build 12345 of libfoo' --from-stdin find | grep -v '^\.$' | $OSTREE commit -b artifact-libfoo-devel -s 'Build 12345 of libfoo' --from-stdin
cd "${test_tmpdir}" cd "${test_tmpdir}"
mkdir artifact-barapp mkdir artifact-barapp
@ -54,12 +54,12 @@ cd artifact-barapp
mkdir -p usr/bin mkdir -p usr/bin
echo 'another ELF file' > usr/bin/bar echo 'another ELF file' > usr/bin/bar
find | grep -v '^\.$' | ostree commit $ot_repo -b artifact-barapp -s 'Build 42 of barapp' --from-stdin find | grep -v '^\.$' | $OSTREE commit -b artifact-barapp -s 'Build 42 of barapp' --from-stdin
echo 'ok artifacts committed' echo 'ok artifacts committed'
cd "${test_tmpdir}" cd "${test_tmpdir}"
ostree compose $ot_repo some-compose artifact-libfoo-runtime artifact-libfoo-devel artifact-barapp $OSTREE compose some-compose artifact-libfoo-runtime artifact-libfoo-devel artifact-barapp
echo 'ok compose command' echo 'ok compose command'
cd some-compose cd some-compose