summaryrefslogtreecommitdiff
path: root/t/lib-bundle-uri-protocol.sh
AgeCommit message (Collapse)AuthorFilesLines
2026-07-19Merge branch 'tc/bundle-uri-empty-fix'Junio C Hamano1-0/+23
The client-side parser of the server-advertised bundle-URI list has been updated to drain the remaining response in order to avoid protocol desynchronization when the server sends a misconfigured list. Also, the server-side has been taught to omit empty configuration values instead of sending invalid key-value lines. * tc/bundle-uri-empty-fix: bundle-uri: stop sending invalid bundle configuration bundle-uri: drain remaining response on invalid bundle-uri lines
2026-07-08bundle-uri: stop sending invalid bundle configurationJustin Tobler1-0/+23
When bundle-URI info is requested by the client, the server responds with all "bundle.*" config lines as key=value packet lines. On the client-side, the received bundle config packet lines are always expected to contain both a key and a value otherwise the client errors out during parsing. The server performs no validation of the read bundle configuration though which results in any misconfiguration on the server-side, such as bundle configuration with an empty value, being blindly sent to the client. To avoid having the server transmit invalid configuration to clients, only send bundle configuration that has non-empty values. This change makes bundle-URI information sent by the server syntactically correct, but semantically it still can be invalid. For example the server may end up sending `bundle.bundle-1.creationToken`, but be lacking a `bundle.bundle-1.uri` for that bundle. The `uri` is mandatory, thus the client cannot process this bundle and will error with the message: error: bundle 'bundle-1' has no uri Fixing this would require a more complex solution, because bundles need to be validated as a whole and not line-by-line. This is considered outside the scope of this change. Co-authored-by: Toon Claes <toon@iotcl.com> Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-06t: convert grep assertions to test_grepMichael Montalbo1-13/+13
Replace bare grep with test_grep in test assertions across the suite, including sourced test helpers (lib-*.sh, *-tests.sh). test_grep prints the contents of the file being searched on failure, making debugging easier than a bare grep which fails silently. Only assertion-style greps are converted: grep used as a filter in pipelines, command substitutions, conditionals, or with redirected I/O is left as-is with a "# lint-ok" annotation. Existing '! test_grep' calls are rewritten to 'test_grep !' so that the diagnostic output is preserved on failure. test_grep requires the file it reads to exist, so '! grep' assertions that inspect a file whose presence is conditional need care. In t5537 the '.git/shallow' file is still present after the repack (the client remains shallow), so the assertion is converted like any other. In t1400 the '.git/packed-refs' file exists only with the files backend, so its check is guarded with a REFFILES prerequisite; the backend-agnostic 'git show-ref' check that follows still runs under every backend. In t7450 'git~2' is the NTFS 8.3 short name of a '..git' file and only exists when 8.3 short-name generation is enabled, so its check is guarded with a 'test -f' on the path and uses test_grep inside the guard, the same shape as t1400 (a plain test_grep would BUG when the short name is absent). The conversion was generated using a grep-assertion linter (greplint.pl, added in the following commit) to identify bare grep calls at command position. To reproduce, from the t/ directory: # Step 1: annotate the two data-filter greps (grep produces # data, not a verdict) so the linter skips them. sed -i '/grep -vf before commits\.raw/s/$/ # lint-ok: data filter/' \ t5326-multi-pack-bitmaps.sh sed -i '/grep -E "^\[0-9a-f\].*|| :/s/$/ # lint-ok: data filter/' \ t5702-protocol-v2.sh # Step 1b: two '! grep' assertions need more than a mechanical # conversion; handle them by hand before the linter-driven steps # below so it leaves them alone. # # t1400: '.git/packed-refs' is absent under reftable, so guard the # check with REFFILES (a plain test_grep would BUG on the missing # file): # # git update-ref -d HEAD $B && # - ! grep "$m" .git/packed-refs && # + if test_have_prereq REFFILES # + then # + test_grep ! "$m" .git/packed-refs # + fi && # test_must_fail git show-ref --verify -q $m # # t7450: git~2 is an NTFS 8.3 short name that exists only when # short-name generation is enabled, so guard the check on its # presence with 'test -f' and note in a comment why the path can # be absent (a plain test_grep would BUG when it is): # # - ! grep gitdir squatting-clone/d/a/git~2 # + if test -f squatting-clone/d/a/git~2 # + then # + test_grep ! gitdir squatting-clone/d/a/git~2 # + fi # Step 2: reorder pre-existing '! test_grep' to 'test_grep !' # (must come before steps 3-4 so greplint does not see them) sed -i 's/! test_grep/test_grep !/' t0031-lockfile-pid.sh sed -i 's/! test_grep/test_grep !/' t5300-pack-object.sh sed -i 's/! test_grep/test_grep !/' t5319-multi-pack-index.sh # Step 3: convert '! grep' -> 'test_grep !' perl greplint.pl *.sh 2>&1 | cut -d: -f1,2 | while IFS=: read f l; do sed -i "${l}s/! *grep/test_grep !/" "$f" done # Step 4: convert remaining 'grep' -> 'test_grep' perl greplint.pl *.sh 2>&1 | cut -d: -f1,2 | while IFS=: read f l; do sed -i "${l}s/grep/test_grep/" "$f" done To verify, run: make -C t test-greplint Signed-off-by: Michael Montalbo <mmontalbo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-26t/lib-bundle-uri: use local fake bundle URLsJeff King1-2/+2
A few of the bundle URI tests point config at a fake bundle; they care only that the client has been configured with _some_ bundle, but it doesn't have to actually contain objects. For the file:// tests, we use "$BUNDLE_URI_REPO_URI/fake.bdl", a non-existent file inside the actual remote repo. But for git:// and http:// tests, we use "https://example.com/fake.bdl". This works OK in practice, but it means we actually make a request to example.com (which returns a placeholder HTML response). That can be annoying when running the test suite on a spotty network (it doesn't produce a wrong result, since we expect it to fail, but it may introduce delays). We can reduce our dependency on the outside world by using a local URL. It would work to just do "file://$PWD/fake.bdl" here, since the bundle code does not care about the actual location. But in the long run I suspect we may have more restrictions on which protocols can be passed around as bundle URIs. So instead, let's stick with the file:// repo's pattern and just point to a bogus name based on the remote repo's URL. For http this makes perfect sense; we'll make a request to the local http server and find that there's nothing there. For git:// it's a little weird, as you wouldn't normally access a bundle file over git:// at all. But it's probably the most reasonable guess we can make for now, and anybody who tightens protocol selection later will know better what's the best path forward. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25clone: unbundle the advertised bundlesDerrick Stolee1-2/+19
A previous change introduced the transport methods to acquire a bundle list from the 'bundle-uri' protocol v2 command, when advertised _and_ when the client has chosen to enable the feature. Teach Git to download and unbundle the data advertised by those bundles during 'git clone'. This takes place between the ref advertisement and the object data download, and stateful connections will linger while the client downloads bundles. In the future, we should consider closing the remote connection during this process. Also, since the --bundle-uri option exists, we do not want to mix the advertised bundles with the user-specified bundles. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25bundle-uri: serve bundle.* keys from configDerrick Stolee1-0/+32
Implement the "bundle-uri" protocol v2 capability by populating the key=value packet lines from the local Git config. The list of bundles is provided from the keys beginning with "bundle.". In the future, we may want to filter this list to be more specific to the exact known keys that the server intends to share, but for flexibility at the moment we will assume that the config values are well-formed. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25bundle-uri client: add helper for testing serverÆvar Arnfjörð Bjarmason1-0/+46
Add a 'test-tool bundle-uri ls-remote' command. This is a thin wrapper for issuing protocol v2 "bundle-uri" commands to a server, and to the parsing routines in bundle-uri.c. In the "git clone" case we'll have already done the handshake(), but not here. Add an extra case to check for this handshake in get_bundle_uri() for ease of use for future callers. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25bundle-uri client: add boolean transfer.bundleURI settingÆvar Arnfjörð Bjarmason1-1/+18
The yet-to-be introduced client support for bundle-uri will always fall back on a full clone, but we'd still like to be able to ignore a server's bundle-uri advertisement entirely. The new transfer.bundleURI config option defaults to 'false', but a user can set it to 'true' to enable checking for bundle URIs from the origin Git server using protocol v2. Co-authored-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25clone: request the 'bundle-uri' command when availableÆvar Arnfjörð Bjarmason1-0/+19
Set up all the needed client parts of the 'bundle-uri' protocol v2 command, without actually doing anything with the bundle URIs. If the server says it supports 'bundle-uri' teach Git to issue the 'bundle-uri' command after the 'ls-refs' during 'git clone'. The returned key=value pairs are passed to the bundle list code which is tested using a different ingest mechanism in t5750-bundle-uri-parse.sh. At this point, Git does nothing with that bundle list. It will not download any of the bundles. That will come in a later change after these protocol bits are finalized. The no-op client is initially used only by 'git clone' to test the basic functionality, and eventually will bootstrap the initial download of Git objects during a fresh clone. The bundle URI client will not be integrated into other fetches until a mechanism is created to select a subset of bundles for download. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-25t: create test harness for 'bundle-uri' commandÆvar Arnfjörð Bjarmason1-0/+85
The previous change allowed for a Git server to advertise the 'bundle-uri' command as a capability based on the uploadPack.advertiseBundleURIs config option. Create a set of tests that check that this capability is advertised using 'git ls-remote'. In order to test this functionality across three protocols (file, git, and http), create lib-bundle-uri-protocol.sh to generalize the tests, allowing the other test scripts to set an environment variable and otherwise inherit the setup and tests from this script. The tests currently only test that the 'bundle-uri' command is advertised or not. Other actions will be tested as the Git client learns to request the 'bundle-uri' command and parse its response. To help with URI escaping, specifically for file paths with a space in them, extract a 'sed' invocation from t9199-git-svn-info.sh into a helper function for use here, too. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>