Skip to content

Commit

Permalink
fetch: add 'refs/bundle/' to log.excludeDecoration
Browse files Browse the repository at this point in the history
When fetching from a bundle URI, the branches of that bundle are stored
in a different ref namespace: refs/bundles/. This namespace is intended
to assist with later 'git fetch' negotiations with a Git server,
allowing the client to advertise which data it already has from a bundle
URI.

These references can be confusing for a user when they appear as a
decoration in 'git log' output. Add "refs/bundles/" to the multi-valued
log.excludeDecoration config value. This is similar to the way
"refs/prefetch/" is hidden by background prefetch operations in 'git
maintenance' as added by 96eaffe (maintenance: set
log.excludeDecoration durin prefetch, 2021-01-19).

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
  • Loading branch information
derrickstolee committed Jun 24, 2022
1 parent bfbd11b commit a217e9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,5 @@ endif::git-pull[]
--bundle-uri=<uri>::
Instead of fetching from a remote, fetch a bundle from the given
`<uri>` and unbundle the data into the local repository. The refs
in the bundle will be stored under the `refs/bundle/*` namespace.
in the bundle will be stored under the hidden `refs/bundle/*`
namespace.
7 changes: 7 additions & 0 deletions bundle-uri.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "cache.h"
#include "bundle-uri.h"
#include "bundle.h"
#include "config.h"
#include "object-store.h"
#include "refs.h"
#include "run-command.h"
Expand Down Expand Up @@ -153,6 +154,12 @@ int fetch_bundle_uri(struct repository *r, const char *uri)
if ((result = unbundle_from_file(r, filename.buf)))
goto cleanup;

git_config_set_multivar_gently("log.excludedecoration",
"refs/bundle/",
"refs/bundle/",
CONFIG_FLAGS_FIXED_VALUE |
CONFIG_FLAGS_MULTI_REPLACE);

cleanup:
unlink(filename.buf);
strbuf_release(&filename);
Expand Down
12 changes: 9 additions & 3 deletions t/t5558-fetch-bundle-uri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ test_expect_success 'fetch file bundle' '
git -C fetch-to fetch --bundle-uri="$(pwd)/fetch-from/B.bundle" &&
git -C fetch-to rev-parse refs/bundles/topic >actual &&
git -C fetch-from rev-parse topic >expect &&
test_cmp expect actual
test_cmp expect actual &&
test_config -C fetch-to log.excludedecoration refs/bundle/
'

test_expect_success 'fetch file:// bundle' '
git init fetch-file &&
git -C fetch-file fetch --bundle-uri="file://$(pwd)/fetch-from/B.bundle" &&
git -C fetch-file rev-parse refs/bundles/topic >actual &&
git -C fetch-from rev-parse topic >expect &&
test_cmp expect actual
test_cmp expect actual &&
test_config -C fetch-file log.excludedecoration refs/bundle/
'

#########################################################################
Expand All @@ -62,7 +66,9 @@ test_expect_success 'fetch HTTP bundle' '
git -C fetch-http fetch --bundle-uri="$HTTPD_URL/B.bundle" &&
git -C fetch-http rev-parse refs/bundles/topic >actual &&
git -C fetch-from rev-parse topic >expect &&
test_cmp expect actual
test_cmp expect actual &&
test_config log.excludedecoration refs/bundle/
'

# Do not add tests here unless they use the HTTP server, as they will
Expand Down

0 comments on commit a217e9a

Please sign in to comment.