mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-13 00:58:43 +03:00
Require a PREFIX when deleting refs
Also fix the "ostree refs" help output to not give the impression that the --delete option takes its own PREFIX argument. https://bugzilla.gnome.org/show_bug.cgi?id=742454
This commit is contained in:
parent
1e8e070102
commit
7727fe84d9
@ -30,7 +30,7 @@
|
||||
static gboolean opt_delete;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Delete refs which match PREFIX, rather than listing them", "PREFIX" },
|
||||
{ "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Delete refs which match PREFIX, rather than listing them", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -53,6 +53,14 @@ ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
if (argc >= 2)
|
||||
refspec_prefix = argv[1];
|
||||
|
||||
/* Require a prefix when deleting to help avoid accidents. */
|
||||
if (opt_delete && refspec_prefix == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"PREFIX is required when deleting refs");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ostree_repo_list_refs (repo, refspec_prefix, &refs,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
@ -45,6 +45,8 @@ $OSTREE refs > reflist
|
||||
assert_file_has_content reflist '^test2$'
|
||||
rm reflist
|
||||
|
||||
$OSTREE refs --delete 2>/dev/null && (echo 1>&2 "refs --delete (without prefix) unexpectedly succeeded!"; exit 1)
|
||||
|
||||
echo "ok refs"
|
||||
|
||||
cd checkout-test2
|
||||
|
Loading…
x
Reference in New Issue
Block a user