Skip to content

Commit e139bb1

Browse files
committed
Merge branch 'jk/remote-helper-object-format-option-fix'
The implementation and documentation of "object-format" option exchange between the Git itself and its remote helpers did not quite match, which has been corrected. * jk/remote-helper-object-format-option-fix: transport-helper: send "true" value for object-format option transport-helper: drop "object-format <algo>" option transport-helper: use write helpers more consistently
2 parents c2cbfbd + b5b7b17 commit e139bb1

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

Documentation/gitremote-helpers.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,10 @@ set by Git if the remote helper has the 'option' capability.
542542
transaction. If successful, all refs will be updated, or none will. If the
543543
remote side does not support this capability, the push will fail.
544544

545-
'option object-format' {'true'|algorithm}::
546-
If 'true', indicate that the caller wants hash algorithm information
545+
'option object-format true'::
546+
Indicate that the caller wants hash algorithm information
547547
to be passed back from the remote. This mode is used when fetching
548548
refs.
549-
+
550-
If set to an algorithm, indicate that the caller wants to interact with
551-
the remote side using that algorithm.
552549

553550
SEE ALSO
554551
--------

remote-curl.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,9 @@ static int set_option(const char *name, const char *value)
211211
options.filter = xstrdup(value);
212212
return 0;
213213
} else if (!strcmp(name, "object-format")) {
214-
int algo;
215214
options.object_format = 1;
216-
if (strcmp(value, "true")) {
217-
algo = hash_algo_by_name(value);
218-
if (algo == GIT_HASH_UNKNOWN)
219-
die("unknown object format '%s'", value);
220-
options.hash_algo = &hash_algos[algo];
221-
}
215+
if (strcmp(value, "true"))
216+
die(_("unknown value for object-format: %s"), value);
222217
return 0;
223218
} else {
224219
return 1 /* unsupported */;

t/t5801/git-remote-testgit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ GIT_DIR="$url/.git"
3030
export GIT_DIR
3131

3232
force=
33+
object_format=
3334

3435
mkdir -p "$dir"
3536

@@ -61,7 +62,8 @@ do
6162
echo
6263
;;
6364
list)
64-
echo ":object-format $(git rev-parse --show-object-format=storage)"
65+
test -n "$object_format" &&
66+
echo ":object-format $(git rev-parse --show-object-format=storage)"
6567
git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
6668
head=$(git symbolic-ref HEAD)
6769
echo "@$head HEAD"

transport-helper.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,16 +1210,13 @@ static struct ref *get_refs_list_using_list(struct transport *transport,
12101210
data->get_refs_list_called = 1;
12111211
helper = get_helper(transport);
12121212

1213-
if (data->object_format) {
1214-
write_str_in_full(helper->in, "option object-format\n");
1215-
if (recvline(data, &buf) || strcmp(buf.buf, "ok"))
1216-
exit(128);
1217-
}
1213+
if (data->object_format)
1214+
set_helper_option(transport, "object-format", "true");
12181215

12191216
if (data->push && for_push)
1220-
write_str_in_full(helper->in, "list for-push\n");
1217+
write_constant(helper->in, "list for-push\n");
12211218
else
1222-
write_str_in_full(helper->in, "list\n");
1219+
write_constant(helper->in, "list\n");
12231220

12241221
while (1) {
12251222
char *eov, *eon;

0 commit comments

Comments
 (0)