git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 0/3] ref-filter: add a ref_sorting_release()
Date: Wed, 20 Oct 2021 20:27:18 +0200	[thread overview]
Message-ID: <cover-0.3-00000000000-20211020T182516Z-avarab@gmail.com> (raw)
In-Reply-To: <RFC-cover-v2-0.4-00000000000-20211020T131627Z-avarab@gmail.com>

A follow-up to
https://lore.kernel.org/git/RFC-cover-v2-0.4-00000000000-20211020T131627Z-avarab@gmail.com/;

Junio: Hopefully this addresses the things you noted, thank[s| you]!
:)

I ejected your patch from this iteration, if you'd like to build on
top of it it should address the build failures in "seen" when combined
with your patch.

Ævar Arnfjörð Bjarmason (3):
  tag: use a "goto cleanup" pattern, leak less memory
  ref-filter API user: add and use a ref_sorting_release()
  branch: use ref_sorting_release()

 builtin/branch.c       |  8 +++++---
 builtin/for-each-ref.c |  2 +-
 builtin/tag.c          | 29 +++++++++++++++++------------
 ref-filter.c           |  9 +++++++++
 ref-filter.h           |  2 ++
 5 files changed, 34 insertions(+), 16 deletions(-)

Range-diff:
1:  fc776c3f1cd ! 1:  8ccd07abf86 tag: use a "goto cleanup" pattern, leak less memory
    @@ Metadata
      ## Commit message ##
         tag: use a "goto cleanup" pattern, leak less memory
     
    -    Change cmd_tag() to free its "struct string_list"'s instead of using
    -    an UNLEAK() pattern. This changes code added in 886e1084d78 (builtin/:
    +    Change cmd_tag() to free its "struct strbuf"'s instead of using an
    +    UNLEAK() pattern. This changes code added in 886e1084d78 (builtin/:
         add UNLEAKs, 2017-10-01).
     
    -    As shown in the context of the deceleration of the "struct
    +    As shown in the context of the declaration of the "struct
         msg_arg" (which I'm changing to use a designated initializer while at
         it, and to show the context in this change), that struct is just a
         thin wrapper around an int and "struct strbuf".
2:  0ae71c19ab7 ! 2:  07062ca276a ref-filter API user: add and use a ref_sorting_release()
    @@ ref-filter.c: int parse_opt_ref_sorting(const struct option *opt, const char *ar
      
     +void ref_sorting_release(struct ref_sorting *sorting)
     +{
    -+	struct ref_sorting *next = sorting->next;
    -+	if (next)
    -+	       ref_sorting_release(next);
    -+	free(sorting);
    ++	while (sorting) {
    ++		struct ref_sorting *next = sorting->next;
    ++		free(sorting);
    ++		sorting = next;
    ++	}
     +}
     +
      int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
3:  7abbbe4468c < -:  ----------- for-each-ref: delay parsing of --sort=<atom> options
4:  f7d87aea384 ! 3:  c8e8bc46ac4 branch: use ref_sorting_release()
    @@ Commit message
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## builtin/branch.c ##
    -@@ builtin/branch.c: static const char *color_branch_slots[] = {
    - 	[BRANCH_COLOR_WORKTREE] = "worktree",
    - };
    - 
    --static struct string_list output = STRING_LIST_INIT_DUP;
    - static unsigned int colopts;
    - 
    - define_list_config_array(color_branch_slots);
     @@ builtin/branch.c: static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
      	return strbuf_detach(&fmt, NULL);
      }
    @@ builtin/branch.c: static void print_ref_list(struct ref_filter *filter, struct r
      		} else {
      			fwrite(out.buf, 1, out.len, stdout);
      			putchar('\n');
    -@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
    - 	enum branch_track track;
    - 	struct ref_filter filter;
    - 	int icase = 0;
    --	static struct ref_sorting *sorting;
    - 	struct string_list sorting_options = STRING_LIST_INIT_DUP;
    - 	struct ref_format format = REF_FORMAT_INIT;
    - 
    -@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
    - 		print_current_branch_name();
    - 		return 0;
    - 	} else if (list) {
    -+		struct ref_sorting *sorting;
    -+		static struct string_list output = STRING_LIST_INIT_DUP;
    -+
    - 		/*  git branch --list also shows HEAD when it is detached */
    - 		if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
    - 			filter.kind |= FILTER_REFS_DETACHED_HEAD;
     @@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
      		ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
      		ref_sorting_set_sort_flags_all(
-- 
2.33.1.1338.g20da966911a


  parent reply	other threads:[~2021-10-20 18:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 18:32 [PATCH] for-each-ref: delay parsing of --sort=<atom> options Junio C Hamano
2021-10-19 22:18 ` Jeff King
2021-10-20  2:20   ` Jeff King
2021-10-20 12:30     ` Ævar Arnfjörð Bjarmason
2021-10-20 13:24       ` [RFC PATCH v2 0/4] for-each-ref: delay parsing of --sort=<atom> options + linux-leaks fixes Ævar Arnfjörð Bjarmason
2021-10-20 13:24         ` [RFC PATCH v2 1/4] tag: use a "goto cleanup" pattern, leak less memory Ævar Arnfjörð Bjarmason
2021-10-20 14:37           ` Junio C Hamano
2021-10-20 13:24         ` [RFC PATCH v2 2/4] ref-filter API user: add and use a ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 14:39           ` Junio C Hamano
2021-10-20 13:24         ` [RFC PATCH v2 3/4] for-each-ref: delay parsing of --sort=<atom> options Ævar Arnfjörð Bjarmason
2021-10-20 13:24         ` [RFC PATCH v2 4/4] branch: use ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 14:43         ` [RFC PATCH v2 0/4] for-each-ref: delay parsing of --sort=<atom> options + linux-leaks fixes Junio C Hamano
2021-10-20 18:27         ` Ævar Arnfjörð Bjarmason [this message]
2021-10-20 18:27           ` [PATCH 1/3] tag: use a "goto cleanup" pattern, leak less memory Ævar Arnfjörð Bjarmason
2021-10-20 18:27           ` [PATCH 2/3] ref-filter API user: add and use a ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 18:27           ` [PATCH 3/3] branch: use ref_sorting_release() Ævar Arnfjörð Bjarmason
2021-10-20 13:58   ` [PATCH] for-each-ref: delay parsing of --sort=<atom> options Junio C Hamano
2021-10-20 20:48     ` Jeff King
2021-10-20 21:32       ` Junio C Hamano
2021-10-21 14:54         ` Jeff King

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=cover-0.3-00000000000-20211020T182516Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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 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 NNTP newsgroup(s).