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
This commit is contained in:
Junio C Hamano 2024-04-03 10:56:18 -07:00
commit e139bb1006
4 changed files with 11 additions and 20 deletions

View file

@ -542,13 +542,10 @@ set by Git if the remote helper has the 'option' capability.
transaction. If successful, all refs will be updated, or none will. If the
remote side does not support this capability, the push will fail.
'option object-format' {'true'|algorithm}::
If 'true', indicate that the caller wants hash algorithm information
'option object-format true'::
Indicate that the caller wants hash algorithm information
to be passed back from the remote. This mode is used when fetching
refs.
+
If set to an algorithm, indicate that the caller wants to interact with
the remote side using that algorithm.
SEE ALSO
--------

View file

@ -211,14 +211,9 @@ static int set_option(const char *name, const char *value)
options.filter = xstrdup(value);
return 0;
} else if (!strcmp(name, "object-format")) {
int algo;
options.object_format = 1;
if (strcmp(value, "true")) {
algo = hash_algo_by_name(value);
if (algo == GIT_HASH_UNKNOWN)
die("unknown object format '%s'", value);
options.hash_algo = &hash_algos[algo];
}
if (strcmp(value, "true"))
die(_("unknown value for object-format: %s"), value);
return 0;
} else {
return 1 /* unsupported */;

View file

@ -30,6 +30,7 @@ GIT_DIR="$url/.git"
export GIT_DIR
force=
object_format=
mkdir -p "$dir"
@ -61,7 +62,8 @@ do
echo
;;
list)
echo ":object-format $(git rev-parse --show-object-format=storage)"
test -n "$object_format" &&
echo ":object-format $(git rev-parse --show-object-format=storage)"
git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
head=$(git symbolic-ref HEAD)
echo "@$head HEAD"

View file

@ -1210,16 +1210,13 @@ static struct ref *get_refs_list_using_list(struct transport *transport,
data->get_refs_list_called = 1;
helper = get_helper(transport);
if (data->object_format) {
write_str_in_full(helper->in, "option object-format\n");
if (recvline(data, &buf) || strcmp(buf.buf, "ok"))
exit(128);
}
if (data->object_format)
set_helper_option(transport, "object-format", "true");
if (data->push && for_push)
write_str_in_full(helper->in, "list for-push\n");
write_constant(helper->in, "list for-push\n");
else
write_str_in_full(helper->in, "list\n");
write_constant(helper->in, "list\n");
while (1) {
char *eov, *eon;