1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 21:56:07 +02:00

Merge branch 'jk/remote-helper-object-format-option-fix' into next

The implementation and documentation of "object-format" option
exchange between the Git itself and its remote helpers did not
quite match.

* 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-03-27 10:13:02 -07:00
commit 5c9d5be660
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 transaction. If successful, all refs will be updated, or none will. If the
remote side does not support this capability, the push will fail. remote side does not support this capability, the push will fail.
'option object-format' {'true'|algorithm}:: 'option object-format true'::
If 'true', indicate that the caller wants hash algorithm information Indicate that the caller wants hash algorithm information
to be passed back from the remote. This mode is used when fetching to be passed back from the remote. This mode is used when fetching
refs. refs.
+
If set to an algorithm, indicate that the caller wants to interact with
the remote side using that algorithm.
SEE ALSO SEE ALSO
-------- --------

View File

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

View File

@ -30,6 +30,7 @@ GIT_DIR="$url/.git"
export GIT_DIR export GIT_DIR
force= force=
object_format=
mkdir -p "$dir" mkdir -p "$dir"
@ -61,7 +62,8 @@ do
echo echo
;; ;;
list) 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/' git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
head=$(git symbolic-ref HEAD) head=$(git symbolic-ref HEAD)
echo "@$head 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; data->get_refs_list_called = 1;
helper = get_helper(transport); helper = get_helper(transport);
if (data->object_format) { if (data->object_format)
write_str_in_full(helper->in, "option object-format\n"); set_helper_option(transport, "object-format", "true");
if (recvline(data, &buf) || strcmp(buf.buf, "ok"))
exit(128);
}
if (data->push && for_push) if (data->push && for_push)
write_str_in_full(helper->in, "list for-push\n"); write_constant(helper->in, "list for-push\n");
else else
write_str_in_full(helper->in, "list\n"); write_constant(helper->in, "list\n");
while (1) { while (1) {
char *eov, *eon; char *eov, *eon;