git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* [PATCH] list-objects: check if filter is NULL before using
@ 2018-06-11 21:51 Jonathan Tan
  2018-06-12 17:47 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Tan @ 2018-06-11 21:51 UTC (permalink / raw)
  To: git; +Cc: Jonathan Tan

In partial_clone_get_default_filter_spec(), the
core_partial_clone_filter_default variable may be NULL; ensure that it
is not NULL before using it.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
This was noticed by someone else at $DAY_JOB when trying to use a
partial clone with no core.partialclonefilter set.
---
 list-objects-filter-options.c | 2 ++
 t/t0410-partial-clone.sh      | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index 6a3cc985c4..c0e2bd6a06 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -146,6 +146,8 @@ void partial_clone_get_default_filter_spec(
 	/*
 	 * Parse default value, but silently ignore it if it is invalid.
 	 */
+	if (!core_partial_clone_filter_default)
+		return;
 	gently_parse_list_objects_filter(filter_options,
 					 core_partial_clone_filter_default,
 					 NULL);
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index cc18b75c03..4984ca583d 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -23,7 +23,15 @@ promise_and_delete () {
 	delete_object repo "$HASH"
 }
 
+test_expect_success 'extensions.partialclone without filter' '
+	test_create_repo server &&
+	git clone --filter="blob:none" "file://$(pwd)/server" client &&
+	git -C client config --unset core.partialclonefilter &&
+	git -C client fetch origin
+'
+
 test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '
+	rm -rf repo &&
 	test_create_repo repo &&
 	test_commit -C repo my_commit &&
 
-- 
2.17.0.582.gccdcbd54c4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] list-objects: check if filter is NULL before using
  2018-06-11 21:51 [PATCH] list-objects: check if filter is NULL before using Jonathan Tan
@ 2018-06-12 17:47 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2018-06-12 17:47 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: git

Jonathan Tan <jonathantanmy@google.com> writes:

> In partial_clone_get_default_filter_spec(), the
> core_partial_clone_filter_default variable may be NULL; ensure that it
> is not NULL before using it.
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
> This was noticed by someone else at $DAY_JOB when trying to use a
> partial clone with no core.partialclonefilter set.

Thanks, will queue.

> ---
>  list-objects-filter-options.c | 2 ++
>  t/t0410-partial-clone.sh      | 8 ++++++++
>  2 files changed, 10 insertions(+)
>
> diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
> index 6a3cc985c4..c0e2bd6a06 100644
> --- a/list-objects-filter-options.c
> +++ b/list-objects-filter-options.c
> @@ -146,6 +146,8 @@ void partial_clone_get_default_filter_spec(
>  	/*
>  	 * Parse default value, but silently ignore it if it is invalid.
>  	 */
> +	if (!core_partial_clone_filter_default)
> +		return;
>  	gently_parse_list_objects_filter(filter_options,
>  					 core_partial_clone_filter_default,
>  					 NULL);
> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
> index cc18b75c03..4984ca583d 100755
> --- a/t/t0410-partial-clone.sh
> +++ b/t/t0410-partial-clone.sh
> @@ -23,7 +23,15 @@ promise_and_delete () {
>  	delete_object repo "$HASH"
>  }
>  
> +test_expect_success 'extensions.partialclone without filter' '
> +	test_create_repo server &&
> +	git clone --filter="blob:none" "file://$(pwd)/server" client &&
> +	git -C client config --unset core.partialclonefilter &&
> +	git -C client fetch origin
> +'
> +
>  test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '
> +	rm -rf repo &&
>  	test_create_repo repo &&
>  	test_commit -C repo my_commit &&

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 21:51 [PATCH] list-objects: check if filter is NULL before using Jonathan Tan
2018-06-12 17:47 ` Junio C Hamano

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox