From: sxenos@google.com
To: git@vger.kernel.org
Cc: Stefan Xenos <sxenos@google.com>
Subject: [PATCH 8/8] evolve: Add the git change list command
Date: Mon, 21 Jan 2019 14:32:16 -0800 [thread overview]
Message-ID: <20190121223216.66659-8-sxenos@google.com> (raw)
In-Reply-To: <20190121223216.66659-1-sxenos@google.com>
From: Stefan Xenos <sxenos@google.com>
This command lists the ongoing changes from the refs/metas
namespace.
---
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.321.g9e740568ce-goog
prev parent reply other threads:[~2019-01-21 22:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 22:32 [PATCH 1/8] technical doc: add a design doc for the evolve command sxenos
2019-01-21 22:32 ` [PATCH 2/8] evolve: Implement oid_array_contains_nondestructive sxenos
2019-01-22 19:51 ` Stefan Beller
2019-01-27 19:08 ` Stefan Xenos
2019-01-21 22:32 ` [PATCH 3/8] evlove: Add the metas namespace to ref-filter sxenos
2019-01-21 22:32 ` [PATCH 4/8] evolve: Add support for parsing metacommits sxenos
2019-01-21 22:32 ` [PATCH 5/8] evolve: Add the change-table structure sxenos
2019-01-21 22:32 ` [PATCH 6/8] evolve: Add support for writing metacommits sxenos
2019-01-21 22:32 ` [PATCH 7/8] evolve: Implement the git change update command sxenos
2019-01-21 22:32 ` 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
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=20190121223216.66659-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).