[ostree] refs: Add argument --list to print the full ref name
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] refs: Add argument --list to print the full ref name
- Date: Wed, 2 Mar 2016 19:53:46 +0000 (UTC)
commit 6d73a620e19dfc982fa08363aed441e0175c8d7b
Author: Giuseppe Scrivano <gscrivan redhat com>
Date: Wed Mar 2 10:48:52 2016 +0100
refs: Add argument --list to print the full ref name
Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
man/ostree-refs.xml | 10 ++++++++++
src/ostree/ot-builtin-refs.c | 16 ++++++++++------
tests/test-refs.sh | 3 +++
3 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/man/ostree-refs.xml b/man/ostree-refs.xml
index 6d75d36..43e934f 100644
--- a/man/ostree-refs.xml
+++ b/man/ostree-refs.xml
@@ -66,6 +66,16 @@ Boston, MA 02111-1307, USA.
<variablelist>
<varlistentry>
+ <term><option>--list</option></term>
+
+ <listitem><para> For historical reasons, <literal>refs</literal>
+ without this option will strip the specified prefix
+ from the output. Normally, one wants to see the full
+ ref, so providing this option ensures the refs are
+ printed in full, rather than
+ truncated. </para></listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--delete</option></term>
<listitem><para>
diff --git a/src/ostree/ot-builtin-refs.c b/src/ostree/ot-builtin-refs.c
index dabb285..af90c84 100644
--- a/src/ostree/ot-builtin-refs.c
+++ b/src/ostree/ot-builtin-refs.c
@@ -27,9 +27,11 @@
#include "ostree.h"
static gboolean opt_delete;
+static gboolean opt_list;
static GOptionEntry options[] = {
{ "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Delete refs which match PREFIX, rather than listing
them", NULL },
+ { "list", 0, 0, G_OPTION_ARG_NONE, &opt_list, "Do not remove the prefix from the refs", NULL },
{ NULL }
};
@@ -40,11 +42,17 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
gpointer hashkey, hashvalue;
gboolean ret = FALSE;
- if (!opt_delete)
+ if (opt_delete || opt_list)
{
- if (!ostree_repo_list_refs (repo, refspec_prefix, &refs, cancellable, error))
+ if (!ostree_repo_list_refs_ext (repo, refspec_prefix, &refs, OSTREE_REPO_LIST_REFS_EXT_NONE,
+ cancellable, error))
goto out;
+ }
+ else if (!ostree_repo_list_refs (repo, refspec_prefix, &refs, cancellable, error))
+ goto out;
+ if (!opt_delete)
+ {
g_hash_table_iter_init (&hashiter, refs);
while (g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue))
{
@@ -54,10 +62,6 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
}
else
{
- if (!ostree_repo_list_refs_ext (repo, refspec_prefix, &refs, OSTREE_REPO_LIST_REFS_EXT_NONE,
- cancellable, error))
- goto out;
-
g_hash_table_iter_init (&hashiter, refs);
while (g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue))
{
diff --git a/tests/test-refs.sh b/tests/test-refs.sh
index b46ec9d..bcebae9 100644
--- a/tests/test-refs.sh
+++ b/tests/test-refs.sh
@@ -45,6 +45,9 @@ assert_file_has_content refscount "^10$"
${CMD_PREFIX} ostree --repo=repo refs foo > refs
assert_not_file_has_content refs foo
+${CMD_PREFIX} ostree --repo=repo refs --list foo > refs
+assert_file_has_content refs foo
+
${CMD_PREFIX} ostree --repo=repo refs foo | wc -l > refscount.foo
assert_file_has_content refscount.foo "^5$"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]