From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>
Subject: [PATCH 1/2] t5801: fix object-format handling in git-remote-testgit
Date: Thu, 7 Mar 2024 03:51:58 -0500 [thread overview]
Message-ID: <20240307085158.GA2072294@coredump.intra.peff.net> (raw)
In-Reply-To: <20240307084735.GA2072130@coredump.intra.peff.net>
Our fake remote helper tries to handle the object-format capability,
courtesy of 3716d50dd5 (remote-testgit: adapt for object-format,
2020-06-19). But its parsing isn't quite right; it expects to receive
"option object-format true", but the transport-helper code just sends
"option object-format" with no value.
As a result, we never set the $object_format variable to "true". And
worse, because $val is used unquoted, this confuses the shell's "test"
command, which prints something like:
.../git/t/t5801/git-remote-testgit: 150: test: =: unexpected operator
It all turns out to be harmless, though, because we never look at
$object_format after that!
The Git-side behavior comes from 8b85ee4f47 (transport-helper: implement
object-format extensions, 2020-05-25). It is a bit unlike other "option"
variables, which always say "true" or "false". But in this case, there's
not really any need to do so. As I understand it from that commit, the
sequence is something like:
1. the remote helper in its capabilities list says "object-format" to
tell Git that it understands the object-format option.
2. Git then tells the helper "option object-format" to tell it that it
too understands object-formats.
3. when the remote helper lists refs, it sends a special
":object-format" line that tells Git which object format it is
using. But it presumably should only do this if we found out that
the other side supports object-formats in step (2).
So let's improve our remote-testgit helper a bit:
- when we see an object-format line, just set object_format=true;
that's the only useful thing to take away from it
- make sure that object_format is set before sending the special
":object-format" line. Since we're always testing against a version
of Git recent enough to have sent us the object-format option, this
is mostly a noop. But it confirms that the transport-helper code is
correctly sending us the option (if we fail to send the line, then
the test will fail when run with GIT_TEST_DEFAULT_HASH=sha256).
Signed-off-by: Jeff King <peff@peff.net>
---
The only other helper we ship that knows about object-format is
remote-curl. And there it _does_ expect "true" or an algorithm.
Curiously the "true" thing works because the remote-curl code silently
rewrites "option foo" to be the same as "option foo true". And even
though it understands receiving a specific algorithm, I'm not sure it
would do anything useful (whatever the caller says is generally
overwritten by the info/refs response).
So I dunno.
t/t5801/git-remote-testgit | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t5801/git-remote-testgit b/t/t5801/git-remote-testgit
index 1544d6dc6b..b348608847 100755
--- a/t/t5801/git-remote-testgit
+++ b/t/t5801/git-remote-testgit
@@ -25,6 +25,7 @@ GIT_DIR="$url/.git"
export GIT_DIR
force=
+object_format=
mkdir -p "$dir"
@@ -56,7 +57,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"
@@ -142,7 +144,7 @@ do
echo "ok"
;;
object-format)
- test $val = "true" && object_format="true" || object_format=
+ object_format=true
echo "ok"
;;
*)
--
2.44.0.463.g71abcb3a9f
next prev parent reply other threads:[~2024-03-07 8:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 8:47 [RFC/PATCH 0/2] some transport-helper "option object-format" confusion Jeff King
2024-03-07 8:51 ` Jeff King [this message]
2024-03-07 8:56 ` [PATCH 2/2] doc/gitremote-helpers: match object-format option docs to code Jeff King
2024-03-07 22:20 ` brian m. carlson
2024-03-12 7:45 ` Jeff King
2024-03-13 21:11 ` brian m. carlson
2024-03-14 12:47 ` Eric W. Biederman
2024-03-14 21:21 ` brian m. carlson
2024-03-15 15:41 ` Eric W. Biederman
2024-03-16 6:04 ` Jeff King
2024-03-17 20:47 ` Eric W. Biederman
2024-03-18 8:49 ` Jeff King
2024-03-14 15:33 ` Junio C Hamano
2024-03-14 21:54 ` brian m. carlson
2024-03-20 9:32 ` [PATCH 0/3] some transport-helper "option object-format" confusion Jeff King
2024-03-20 9:34 ` [PATCH 1/3] transport-helper: use write helpers more consistently Jeff King
2024-03-20 9:37 ` [PATCH 2/3] transport-helper: drop "object-format <algo>" option Jeff King
2024-03-20 9:41 ` [PATCH 3/3] transport-helper: send "true" value for object-format option Jeff King
2024-03-20 17:23 ` Junio C Hamano
2024-03-20 17:05 ` [PATCH 0/3] some transport-helper "option object-format" confusion Eric W. Biederman
2024-03-27 9:48 ` Jeff King
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=20240307085158.GA2072294@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=sandals@crustytoothpaste.net \
/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).