git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: sxenos@google.com
To: git@vger.kernel.org
Cc: Stefan Xenos <sxenos@google.com>
Subject: [PATCH v5 8/8] evolve: add the git change list command
Date: Thu, 14 Feb 2019 20:31:05 -0800	[thread overview]
Message-ID: <20190215043105.163688-8-sxenos@google.com> (raw)
In-Reply-To: <20190215043105.163688-1-sxenos@google.com>

From: Stefan Xenos <sxenos@google.com>

This command lists the ongoing changes from the refs/metas
namespace.

Signed-off-by: Stefan Xenos <sxenos@google.com>
---
 builtin/change.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/builtin/change.c b/builtin/change.c
index 807d148805..a7db3cea04 100644
--- a/builtin/change.c
+++ b/builtin/change.c
@@ -6,15 +6,64 @@
 #include "config.h"
 
 static const char * const builtin_change_usage[] = {
+	N_("git change list [<pattern>...]"),
 	N_("git change update [--force] [--replace <treeish>...] [--origin <treesih>...] [--content <newtreeish>]"),
 	NULL
 };
 
+static const char * const builtin_list_usage[] = {
+	N_("git change list [<pattern>...]"),
+	NULL
+};
+
 static const char * const builtin_update_usage[] = {
 	N_("git change update [--force] [--replace <treeish>...] [--origin <treesih>...] [--content <newtreeish>]"),
 	NULL
 };
 
+static int change_list(int argc, const char **argv, const char* prefix)
+{
+	struct option options[] = {
+		OPT_END()
+	};
+	struct ref_filter filter;
+	/* TODO: Sorting temporarily disabled. See comments, below.
+	 * struct ref_sorting *sorting = ref_default_sorting(); */
+	struct ref_format format = REF_FORMAT_INIT;
+	struct ref_array array;
+	int i;
+
+	argc = parse_options(argc, argv, prefix, options, builtin_list_usage, 0);
+
+	setup_ref_filter_porcelain_msg();
+
+	memset(&filter, 0, sizeof(filter));
+	memset(&array, 0, sizeof(array));
+
+	filter.kind = FILTER_REFS_CHANGES;
+	filter.name_patterns = argv;
+
+	filter_refs(&array, &filter, FILTER_REFS_CHANGES);
+
+	/* TODO: This causes a crash. It sets one of the atom_value handlers to
+	 * something invalid, which causes a crash later when we call
+	 * show_ref_array_item. Figure out why this happens and put back the sorting.
+	 *ref_array_sort(sorting, &array); */
+
+	if (!format.format)
+		format.format = "%(refname:lstrip=1)";
+
+	if (verify_ref_format(&format))
+		die(_("unable to parse format string"));
+
+	for (i = 0; i < array.nr; i++)
+		show_ref_array_item(array.items[i], &format);
+
+	ref_array_clear(&array);
+
+	return 0;
+}
+
 struct update_state {
 	int options;
 	const char* change;
@@ -184,6 +233,8 @@ int cmd_change(int argc, const char **argv, const char *prefix)
 
 	if (argc < 1)
 		usage_with_options(builtin_change_usage, options);
+	else if (!strcmp(argv[0], "list"))
+		result = change_list(argc, argv, prefix);
 	else if (!strcmp(argv[0], "update"))
 		result = change_update(argc, argv, prefix);
 	else {
-- 
2.21.0.rc0.258.g878e2cd30e-goog


  parent reply	other threads:[~2019-02-15  4:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15  4:30 [PATCH v5 1/8] technical doc: add a design doc for the evolve command sxenos
2019-02-15  4:30 ` [PATCH v5 2/8] sha1-array: implement oid_array_readonly_contains sxenos
2019-02-15  4:31 ` [PATCH v5 3/8] ref-filter: add the metas namespace to ref-filter sxenos
2019-02-15  4:31 ` [PATCH v5 4/8] evolve: add support for parsing metacommits sxenos
2019-02-15  4:31 ` [PATCH v5 5/8] evolve: add the change-table structure sxenos
2019-02-15  4:31 ` [PATCH v5 6/8] evolve: add support for writing metacommits sxenos
2019-02-15  4:31 ` [PATCH v5 7/8] evolve: implement the git change command sxenos
2019-02-15  4:31 ` sxenos [this message]
2019-02-15 18:23 ` [PATCH v5 1/8] technical doc: add a design doc for the evolve command Junio C Hamano
2019-02-15 22:18   ` Stefan Xenos
2019-02-15 23:36     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190215043105.163688-8-sxenos@google.com \
    --to=sxenos@google.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).