git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff Hostetler <git@jeffhostetler.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, jonathantanmy@google.com,
	christian.couder@gmail.com,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH v6 2/3] list-objects-filter-options: support --no-filter
Date: Tue,  5 Dec 2017 16:50:13 +0000	[thread overview]
Message-ID: <20171205165014.64488-3-git@jeffhostetler.com> (raw)
In-Reply-To: <20171205165014.64488-1-git@jeffhostetler.com>

From: Jeff Hostetler <jeffhost@microsoft.com>

Teach opt_parse_list_objects_filter() to take --no-filter
option and to free the contents of struct filter_options.
This command line argument will be automatically inherited
by commands using OPT_PARSE_LIST_OBJECTS_FILTER(); this
includes pack-objects.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 Documentation/git-pack-objects.txt |  3 +++
 list-objects-filter-options.c      | 15 +++++++++++++--
 list-objects-filter-options.h      |  5 ++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index b924c6c..aa403d0 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt
@@ -242,6 +242,9 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
 	the resulting packfile.  See linkgit:git-rev-list[1] for valid
 	`<filter-spec>` forms.
 
+--no-filter::
+	Turns off any previous `--filter=` argument.
+
 --missing=<missing-action>::
 	A debug option to help with future "partial clone" development.
 	This option specifies how missing objects are handled.
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index 52bdec7..4c5b34e 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -74,8 +74,19 @@ int opt_parse_list_objects_filter(const struct option *opt,
 {
 	struct list_objects_filter_options *filter_options = opt->value;
 
-	assert(arg);
-	assert(!unset);
+	if (unset || !arg) {
+		list_objects_filter_release(filter_options);
+		return 0;
+	}
 
 	return parse_list_objects_filter(filter_options, arg);
 }
+
+void list_objects_filter_release(
+	struct list_objects_filter_options *filter_options)
+{
+	free(filter_options->filter_spec);
+	free(filter_options->sparse_oid_value);
+	free(filter_options->sparse_path_value);
+	memset(filter_options, 0, sizeof(*filter_options));
+}
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index dd7e5db..eea44a1 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -52,7 +52,10 @@ int opt_parse_list_objects_filter(const struct option *opt,
 
 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
 	{ OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
-	  N_("object filtering"), PARSE_OPT_NONEG, \
+	  N_("object filtering"), 0, \
 	  opt_parse_list_objects_filter }
 
+void list_objects_filter_release(
+	struct list_objects_filter_options *filter_options);
+
 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */
-- 
2.9.3


  parent reply	other threads:[~2017-12-05 16:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 16:50 [PATCH v6 0/3] Partial clone part 1: object filtering Jeff Hostetler
2017-12-05 16:50 ` [PATCH v6 1/3] list-objects-filter-options: fix 'keword' typo in comment Jeff Hostetler
2017-12-05 16:50 ` Jeff Hostetler [this message]
2017-12-05 16:50 ` [PATCH v6 3/3] rev-list: support --no-filter argument Jeff Hostetler
2017-12-11  6:17   ` Christian Couder
2017-12-13 18:38     ` Jeff Hostetler

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=20171205165014.64488-3-git@jeffhostetler.com \
    --to=git@jeffhostetler.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.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.
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).