From: sxenos@google.com
To: git@vger.kernel.org
Cc: Stefan Xenos <sxenos@google.com>
Subject: [PATCH v2 8/8] evolve: Add the git change list command
Date: Sun, 27 Jan 2019 11:41:28 -0800 [thread overview]
Message-ID: <20190127194128.161250-8-sxenos@google.com> (raw)
In-Reply-To: <20190127194128.161250-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 | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/builtin/change.c b/builtin/change.c
index ff7eb3b113..b63fe98665 100644
--- a/builtin/change.c
+++ b/builtin/change.c
@@ -5,15 +5,66 @@
#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;
@@ -164,6 +215,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.20.1.495.gaa96b0ce6b-goog
prev parent reply other threads:[~2019-01-27 19:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-27 19:41 [PATCH v2 1/8] technical doc: add a design doc for the evolve command sxenos
2019-01-27 19:41 ` [PATCH v2 2/8] sha1-array: Implement oid_array_readonly_contains sxenos
2019-01-28 13:05 ` SZEDER Gábor
[not found] ` <CABh8og41XhiYzg=X3to7M+zWszJq6a+n8bwHrwkU-GoxYa8-VQ@mail.gmail.com>
2019-01-29 11:15 ` SZEDER Gábor
2019-01-27 19:41 ` [PATCH v2 3/8] ref-filter: Add the metas namespace to ref-filter sxenos
2019-01-27 19:41 ` [PATCH v2 4/8] evolve: Add support for parsing metacommits sxenos
2019-01-27 19:41 ` [PATCH v2 5/8] evolve: Add the change-table structure sxenos
2019-01-27 19:41 ` [PATCH v2 6/8] evolve: Add support for writing metacommits sxenos
2019-01-29 11:15 ` SZEDER Gábor
2019-01-27 19:41 ` [PATCH v2 7/8] evolve: Implement the git change command sxenos
2019-01-27 19:41 ` sxenos [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190127194128.161250-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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.