Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-11-30 02:41:47 +0300
committerJunio C Hamano <gitster@pobox.com>2021-11-30 02:41:47 +0300
commit5126145ba8e8327b41e2fc235351645e0eb959da (patch)
treeb5639b9588e632a09e6cb455e05bc0a908f79633 /ref-filter.c
parent44ac8fd1b4ce7598e2e5f4045dfbb6593a3f5b84 (diff)
parent98e7ab6d42beba8b35fefb3856b07ac20e89d1ca (diff)
Merge branch 'jc/fix-ref-sorting-parse'
Things like "git -c branch.sort=bogus branch new HEAD", i.e. the operation modes of the "git branch" command that do not need the sort key information, no longer errors out by seeing a bogus sort key. * jc/fix-ref-sorting-parse: for-each-ref: delay parsing of --sort=<atom> options
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/ref-filter.c b/ref-filter.c
index 08a3f839c9..7260fce31d 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2470,6 +2470,12 @@ static int memcasecmp(const void *vs1, const void *vs2, size_t n)
return 0;
}
+struct ref_sorting {
+ struct ref_sorting *next;
+ int atom; /* index into used_atom array (internal) */
+ enum ref_sorting_order sort_flags;
+};
+
static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, struct ref_array_item *b)
{
struct atom_value *va, *vb;
@@ -2663,7 +2669,7 @@ static int parse_sorting_atom(const char *atom)
}
/* If no sorting option is given, use refname to sort as default */
-struct ref_sorting *ref_default_sorting(void)
+static struct ref_sorting *ref_default_sorting(void)
{
static const char cstr_name[] = "refname";
@@ -2674,7 +2680,7 @@ struct ref_sorting *ref_default_sorting(void)
return sorting;
}
-void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
+static void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
{
struct ref_sorting *s;
@@ -2692,17 +2698,25 @@ void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
s->atom = parse_sorting_atom(arg);
}
-int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
+struct ref_sorting *ref_sorting_options(struct string_list *options)
{
+ struct string_list_item *item;
+ struct ref_sorting *sorting = NULL, **tail = &sorting;
+
+ if (!options->nr) {
+ sorting = ref_default_sorting();
+ } else {
+ for_each_string_list_item(item, options)
+ parse_ref_sorting(tail, item->string);
+ }
+
/*
- * NEEDSWORK: We should probably clear the list in this case, but we've
- * already munged the global used_atoms list, which would need to be
- * undone.
+ * From here on, the ref_sorting list should be used to talk
+ * about the sort order used for the output. The caller
+ * should not touch the string form anymore.
*/
- BUG_ON_OPT_NEG(unset);
-
- parse_ref_sorting(opt->value, arg);
- return 0;
+ string_list_clear(options, 0);
+ return sorting;
}
void ref_sorting_release(struct ref_sorting *sorting)