From: "Abhradeep Chakraborty via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Philip Oakley <philipoakley@iee.email>,
Junio C Hamano <gitster@pobox.com>,
Philippe Blain <levraiphilippeblain@gmail.com>,
Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>,
Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
Subject: [PATCH v4] builtin/remote.c: teach `-v` to list filters for promisor remotes
Date: Mon, 09 May 2022 11:32:48 +0000 [thread overview]
Message-ID: <pull.1227.v4.git.1652095969026.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1227.v3.git.1651933221216.gitgitgadget@gmail.com>
From: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
`git remote -v` (`--verbose`) lists down the names of remotes along with
their URLs. It would be beneficial for users to also specify the filter
types for promisor remotes. Something like this -
origin remote-url (fetch) [blob:none]
origin remote-url (push)
Teach `git remote -v` to also specify the filters for promisor remotes.
Closes: https://github.com/gitgitgadget/git/issues/1211
Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
---
builtin/remote.c: teach -v to list filters for promisor remotes
Fixes #1211 [1]
Changes since v3:
* tests are moved to t5505-remote.sh
* Documentation improved
* Added Closes trailer in the commit message
Changes since v2:
* added more test cases
* fixed broken indentations
Changes since v1:
* updated documentation
* renamed url_buf into remote_info_buf
[1] https://github.com/gitgitgadget/git/issues/1211
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1227%2FAbhra303%2Fpromisor_remote-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1227/Abhra303/promisor_remote-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1227
Range-diff vs v3:
1: 9ac6ca9a08e ! 1: a067435285b builtin/remote.c: teach `-v` to list filters for promisor remotes
@@ Commit message
builtin/remote.c: teach `-v` to list filters for promisor remotes
`git remote -v` (`--verbose`) lists down the names of remotes along with
- their urls. It would be beneficial for users to also specify the filter
+ their URLs. It would be beneficial for users to also specify the filter
types for promisor remotes. Something like this -
origin remote-url (fetch) [blob:none]
@@ Commit message
Teach `git remote -v` to also specify the filters for promisor remotes.
+ Closes: https://github.com/gitgitgadget/git/issues/1211
Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
## Documentation/git-remote.txt ##
@@ Documentation/git-remote.txt: OPTIONS
-v::
--verbose::
Be a little more verbose and show remote url after name.
-+ For promisor remotes it will show an extra information
-+ (wrapped in square brackets) describing which filter
-+ (`blob:none` etc.) that promisor remote use.
++ For promisor remotes, also show which filter (`blob:none` etc.)
++ are configured.
NOTE: This must be placed between `remote` and subcommand.
@@ builtin/remote.c: static int get_one_entry(struct remote *remote, void *priv)
return 0;
- ## t/t5616-partial-clone.sh ##
-@@ t/t5616-partial-clone.sh: test_expect_success 'do partial clone 1' '
- test "$(git -C pc1 config --local remote.origin.partialclonefilter)" = "blob:none"
+ ## t/t5505-remote.sh ##
+@@ t/t5505-remote.sh: test_expect_success 'add another remote' '
+ )
'
++test_expect_success 'setup bare clone for server' '
++ git clone --bare "file://$(pwd)/one" srv.bare &&
++ git -C srv.bare config --local uploadpack.allowfilter 1 &&
++ git -C srv.bare config --local uploadpack.allowanysha1inwant 1
++'
++
+test_expect_success 'filters for promisor remotes are listed by git remote -v' '
-+ test_when_finished "rm -rf pc2" &&
-+ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc2 &&
-+ git -C pc2 remote -v >out &&
++ test_when_finished "rm -rf pc" &&
++ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
++ git -C pc remote -v >out &&
+ grep "srv.bare (fetch) \[blob:none\]" out &&
+
-+ git -C pc2 config remote.origin.partialCloneFilter object:type=commit &&
-+ git -C pc2 remote -v >out &&
++ git -C pc config remote.origin.partialCloneFilter object:type=commit &&
++ git -C pc remote -v >out &&
+ grep "srv.bare (fetch) \[object:type=commit\]" out
+'
+
+test_expect_success 'filters should not be listed for non promisor remotes (remote -v)' '
-+ test_when_finished "rm -rf pc2" &&
-+ git clone "file://$(pwd)/srv.bare" pc2 &&
-+ git -C pc2 remote -v >out &&
++ test_when_finished "rm -rf pc" &&
++ git clone one pc &&
++ git -C pc remote -v >out &&
+ ! grep "(fetch) \[.*\]" out
+'
+
+test_expect_success 'filters are listed by git remote -v only' '
-+ test_when_finished "rm -rf pc2" &&
-+ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc2 &&
-+ git -C pc2 remote >out &&
++ test_when_finished "rm -rf pc" &&
++ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
++ git -C pc remote >out &&
+ ! grep "\[blob:none\]" out &&
+
-+ git -C pc2 remote show >out &&
++ git -C pc remote show >out &&
+ ! grep "\[blob:none\]" out
+'
+
- test_expect_success 'verify that .promisor file contains refs fetched' '
- ls pc1/.git/objects/pack/pack-*.promisor >promisorlist &&
- test_line_count = 1 promisorlist &&
+ test_expect_success 'check remote-tracking' '
+ (
+ cd test &&
Documentation/git-remote.txt | 2 ++
builtin/remote.c | 18 +++++++++++++-----
t/t5505-remote.sh | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index cde9614e362..1dec3148348 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -35,6 +35,8 @@ OPTIONS
-v::
--verbose::
Be a little more verbose and show remote url after name.
+ For promisor remotes, also show which filter (`blob:none` etc.)
+ are configured.
NOTE: This must be placed between `remote` and subcommand.
diff --git a/builtin/remote.c b/builtin/remote.c
index 5f4cde9d784..d4b69fe7789 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1185,14 +1185,22 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data)
static int get_one_entry(struct remote *remote, void *priv)
{
struct string_list *list = priv;
- struct strbuf url_buf = STRBUF_INIT;
+ struct strbuf remote_info_buf = STRBUF_INIT;
const char **url;
int i, url_nr;
if (remote->url_nr > 0) {
- strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
+ struct strbuf promisor_config = STRBUF_INIT;
+ const char *partial_clone_filter = NULL;
+
+ strbuf_addf(&promisor_config, "remote.%s.partialclonefilter", remote->name);
+ strbuf_addf(&remote_info_buf, "%s (fetch)", remote->url[0]);
+ if (!git_config_get_string_tmp(promisor_config.buf, &partial_clone_filter))
+ strbuf_addf(&remote_info_buf, " [%s]", partial_clone_filter);
+
+ strbuf_release(&promisor_config);
string_list_append(list, remote->name)->util =
- strbuf_detach(&url_buf, NULL);
+ strbuf_detach(&remote_info_buf, NULL);
} else
string_list_append(list, remote->name)->util = NULL;
if (remote->pushurl_nr) {
@@ -1204,9 +1212,9 @@ static int get_one_entry(struct remote *remote, void *priv)
}
for (i = 0; i < url_nr; i++)
{
- strbuf_addf(&url_buf, "%s (push)", url[i]);
+ strbuf_addf(&remote_info_buf, "%s (push)", url[i]);
string_list_append(list, remote->name)->util =
- strbuf_detach(&url_buf, NULL);
+ strbuf_detach(&remote_info_buf, NULL);
}
return 0;
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index c90cf47acdb..fff14e13ed4 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -78,6 +78,40 @@ test_expect_success 'add another remote' '
)
'
+test_expect_success 'setup bare clone for server' '
+ git clone --bare "file://$(pwd)/one" srv.bare &&
+ git -C srv.bare config --local uploadpack.allowfilter 1 &&
+ git -C srv.bare config --local uploadpack.allowanysha1inwant 1
+'
+
+test_expect_success 'filters for promisor remotes are listed by git remote -v' '
+ test_when_finished "rm -rf pc" &&
+ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
+ git -C pc remote -v >out &&
+ grep "srv.bare (fetch) \[blob:none\]" out &&
+
+ git -C pc config remote.origin.partialCloneFilter object:type=commit &&
+ git -C pc remote -v >out &&
+ grep "srv.bare (fetch) \[object:type=commit\]" out
+'
+
+test_expect_success 'filters should not be listed for non promisor remotes (remote -v)' '
+ test_when_finished "rm -rf pc" &&
+ git clone one pc &&
+ git -C pc remote -v >out &&
+ ! grep "(fetch) \[.*\]" out
+'
+
+test_expect_success 'filters are listed by git remote -v only' '
+ test_when_finished "rm -rf pc" &&
+ git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
+ git -C pc remote >out &&
+ ! grep "\[blob:none\]" out &&
+
+ git -C pc remote show >out &&
+ ! grep "\[blob:none\]" out
+'
+
test_expect_success 'check remote-tracking' '
(
cd test &&
base-commit: 0f828332d5ac36fc63b7d8202652efa152809856
--
gitgitgadget
next prev parent reply other threads:[~2022-05-09 11:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-30 13:19 [PATCH] builtin/remote.c: teach `-v` to list filters for promisor remotes Abhradeep Chakraborty via GitGitGadget
2022-04-30 21:17 ` Junio C Hamano
2022-05-01 15:57 ` Abhradeep Chakraborty
2022-05-01 16:14 ` Junio C Hamano
2022-05-01 19:38 ` Abhradeep Chakraborty
2022-05-02 10:33 ` Philip Oakley
2022-05-02 14:56 ` Abhradeep Chakraborty
2022-05-03 15:20 ` [PATCH v2] " Abhradeep Chakraborty via GitGitGadget
2022-05-04 17:10 ` Junio C Hamano
2022-05-05 14:12 ` Abhradeep Chakraborty
2022-05-07 14:20 ` [PATCH v3] " Abhradeep Chakraborty via GitGitGadget
2022-05-08 15:33 ` Philippe Blain
2022-05-09 16:29 ` Junio C Hamano
2022-05-09 16:45 ` Philippe Blain
2022-05-08 15:44 ` Philippe Blain
2022-05-09 9:13 ` Abhradeep Chakraborty
2022-05-09 11:32 ` Abhradeep Chakraborty via GitGitGadget [this message]
2022-05-09 15:34 ` [PATCH v4] " Taylor Blau
2022-05-09 17:01 ` Philippe Blain
2022-05-09 17:52 ` Junio C Hamano
2022-05-13 13:49 ` Abhradeep Chakraborty
2022-05-13 18:37 ` Junio C Hamano
2022-05-16 15:38 ` Abhradeep Chakraborty
2022-05-09 17:21 ` Abhradeep Chakraborty
2022-05-09 22:22 ` Taylor Blau
2022-05-09 17:44 ` Abhradeep Chakraborty
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=pull.1227.v4.git.1652095969026.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=chakrabortyabhradeep79@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=levraiphilippeblain@gmail.com \
--cc=philipoakley@iee.email \
/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).