diff --git a/man/ostree-refs.xml b/man/ostree-refs.xml
index 6d75d365..43e934ff 100644
--- a/man/ostree-refs.xml
+++ b/man/ostree-refs.xml
@@ -65,6 +65,16 @@ Boston, MA 02111-1307, USA.
Options
+
+
+
+ For historical reasons, refs
+ 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.
+
diff --git a/src/ostree/ot-builtin-refs.c b/src/ostree/ot-builtin-refs.c
index dabb285c..af90c841 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 || opt_list)
+ {
+ 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)
{
- if (!ostree_repo_list_refs (repo, refspec_prefix, &refs, cancellable, error))
- goto out;
-
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 b46ec9da..bcebae9e 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$"