Skip to content

Commit 2785b71

Browse files
committed
Merge branch 'ac/remote-v-with-object-list-filters'
"git remote -v" now shows the list-objects-filter used during fetching from the remote, if available. * ac/remote-v-with-object-list-filters: builtin/remote.c: teach `-v` to list filters for promisor remotes
2 parents 2088a0c + ef6d15c commit 2785b71

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

Documentation/git-remote.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ OPTIONS
3535
-v::
3636
--verbose::
3737
Be a little more verbose and show remote url after name.
38+
For promisor remotes, also show which filter (`blob:none` etc.)
39+
are configured.
3840
NOTE: This must be placed between `remote` and subcommand.
3941

4042

builtin/remote.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,14 +1185,22 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data)
11851185
static int get_one_entry(struct remote *remote, void *priv)
11861186
{
11871187
struct string_list *list = priv;
1188-
struct strbuf url_buf = STRBUF_INIT;
1188+
struct strbuf remote_info_buf = STRBUF_INIT;
11891189
const char **url;
11901190
int i, url_nr;
11911191

11921192
if (remote->url_nr > 0) {
1193-
strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
1193+
struct strbuf promisor_config = STRBUF_INIT;
1194+
const char *partial_clone_filter = NULL;
1195+
1196+
strbuf_addf(&promisor_config, "remote.%s.partialclonefilter", remote->name);
1197+
strbuf_addf(&remote_info_buf, "%s (fetch)", remote->url[0]);
1198+
if (!git_config_get_string_tmp(promisor_config.buf, &partial_clone_filter))
1199+
strbuf_addf(&remote_info_buf, " [%s]", partial_clone_filter);
1200+
1201+
strbuf_release(&promisor_config);
11941202
string_list_append(list, remote->name)->util =
1195-
strbuf_detach(&url_buf, NULL);
1203+
strbuf_detach(&remote_info_buf, NULL);
11961204
} else
11971205
string_list_append(list, remote->name)->util = NULL;
11981206
if (remote->pushurl_nr) {
@@ -1204,9 +1212,9 @@ static int get_one_entry(struct remote *remote, void *priv)
12041212
}
12051213
for (i = 0; i < url_nr; i++)
12061214
{
1207-
strbuf_addf(&url_buf, "%s (push)", url[i]);
1215+
strbuf_addf(&remote_info_buf, "%s (push)", url[i]);
12081216
string_list_append(list, remote->name)->util =
1209-
strbuf_detach(&url_buf, NULL);
1217+
strbuf_detach(&remote_info_buf, NULL);
12101218
}
12111219

12121220
return 0;

t/t5505-remote.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ test_expect_success 'add another remote' '
7878
)
7979
'
8080

81+
test_expect_success 'setup bare clone for server' '
82+
git clone --bare "file://$(pwd)/one" srv.bare &&
83+
git -C srv.bare config --local uploadpack.allowfilter 1 &&
84+
git -C srv.bare config --local uploadpack.allowanysha1inwant 1
85+
'
86+
87+
test_expect_success 'filters for promisor remotes are listed by git remote -v' '
88+
test_when_finished "rm -rf pc" &&
89+
git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
90+
git -C pc remote -v >out &&
91+
grep "srv.bare (fetch) \[blob:none\]" out &&
92+
93+
git -C pc config remote.origin.partialCloneFilter object:type=commit &&
94+
git -C pc remote -v >out &&
95+
grep "srv.bare (fetch) \[object:type=commit\]" out
96+
'
97+
98+
test_expect_success 'filters should not be listed for non promisor remotes (remote -v)' '
99+
test_when_finished "rm -rf pc" &&
100+
git clone one pc &&
101+
git -C pc remote -v >out &&
102+
! grep "(fetch) \[.*\]" out
103+
'
104+
105+
test_expect_success 'filters are listed by git remote -v only' '
106+
test_when_finished "rm -rf pc" &&
107+
git clone --filter=blob:none "file://$(pwd)/srv.bare" pc &&
108+
git -C pc remote >out &&
109+
! grep "\[blob:none\]" out &&
110+
111+
git -C pc remote show >out &&
112+
! grep "\[blob:none\]" out
113+
'
114+
81115
test_expect_success 'check remote-tracking' '
82116
(
83117
cd test &&

0 commit comments

Comments
 (0)