From: Junio C Hamano Date: Tue, 03 Nov 2026 01:12:24 GMT Subject: Re: [PATCH v2] odb: do not list our own refs as alternate refs in the quarantine Message-ID: In-Reply-To: Junio C Hamano writes: > "Kristofer Karlsson via GitGitGadget" > writes: > >> Changes since v1: >> ... >> quarantine outside of the commondir. > > All of the above changes make sense to me. > > This unfortunately crashes with Patrick's odb-reload-alternates > series, but let me see if I can get a reasonable conflict resolution > or if it is more reasonable to ask you to rebase this on the other > topic. I decided to queue it as-is instead of asking you to depend on the other topic. Here is what I got after making a trial merge to 'seen'. I usually use "git show" to trigger the dense-combined diff format (i.e., "git show --cc seen"), but "git show --remerge-diff seen" output is shown below, just to see how easy it is to read. commit b7f4d1e66b034c2a64b7f3323f9cd156a028f080 Merge: 1707829739 3f91b4bc4b Author: Junio C Hamano Date: Mon Nov 2 16:37:57 2026 -0800 Merge branch 'kk/quarantine-alternate-refs' into seen The connectivity check in 'git-receive-pack(1)' has been optimized to not list the repository's own refs as alternate refs when running inside the object quarantine, avoiding redundant traversal of hidden refs. * kk/quarantine-alternate-refs: odb: do not list our own refs as alternate refs in the quarantine diff --git a/Documentation/rev-list-options.adoc b/Documentation/rev-list-options.adoc remerge CONFLICT (content): Merge conflict in Documentation/rev-list-options.adoc index 4e92cf6456..d20c5f6372 100644 --- a/Documentation/rev-list-options.adoc +++ b/Documentation/rev-list-options.adoc @@ -223,23 +223,13 @@ explicitly. Pretend as if all objects mentioned as ref tips of alternate repositories were listed on the command line. An alternate repository is any repository whose object directory is specified -<<<<<<< 1707829739 (Merge branch 'kk/connectivity-check-ignore-replace' into seen) in `objects/info/alternates`. The refs of shallow and grafted alternate repositories are ignored, as the history behind them - may be missing. The set of included objects may be modified by + may be missing. The repository's own object directory does not + count, even when it is passed in as an alternate, as happens + inside the object quarantine of linkgit:git-receive-pack[1]. + The set of included objects may be modified by `core.alternateRefsCommand`, etc. See linkgit:git-config[1]. -||||||| ebdc087dc9 - in `objects/info/alternates`. The set of included objects may - be modified by `core.alternateRefsCommand`, etc. See - linkgit:git-config[1]. -======= - in `objects/info/alternates`. The repository's own object - directory does not count, even when it is passed in as an - alternate, as happens inside the object quarantine of - linkgit:git-receive-pack[1]. The set of included objects may - be modified by `core.alternateRefsCommand`, etc. See - linkgit:git-config[1]. ->>>>>>> 3f91b4bc4b (odb: do not list our own refs as alternate refs in the quarantine) `--single-worktree`:: By default, all working trees will be examined by the diff --git a/odb/source-files.c b/odb/source-files.c remerge CONFLICT (content): Merge conflict in odb/source-files.c index 4239cb493c..8ce437fdc2 100644 --- a/odb/source-files.c +++ b/odb/source-files.c @@ -75,15 +75,9 @@ static void odb_source_files_free(struct odb_source *source) odb_files_dir_free(files->dirs); files->dirs = next; } -<<<<<<< 1707829739 (Merge branch 'kk/connectivity-check-ignore-replace' into seen) strset_clear(&files->dir_paths); stat_validity_clear(&files->alternates_validity); -||||||| ebdc087dc9 - hashmap_clear(&files->dirs_by_path); -======= - hashmap_clear(&files->dirs_by_path); free(files->quarantine_path); ->>>>>>> 3f91b4bc4b (odb: do not list our own refs as alternate refs in the quarantine) odb_source_release(&files->base); free(files); @@ -362,15 +356,6 @@ static void read_alternates(const char *object_dir, struct strvec *out, free(path); } -<<<<<<< 1707829739 (Merge branch 'kk/connectivity-check-ignore-replace' into seen) -static void add_alternate_recursively(struct odb_source_files *files, - const char *path, - int depth) -||||||| ebdc087dc9 -static void odb_add_alternate_recursively(struct odb_source_files *files, - const char *path, - int depth) -======= /* * Our own object directory is /objects, or the parent of * GIT_QUARANTINE_PATH, as an object quarantine is created directly @@ -410,10 +395,9 @@ static bool is_borrowed_object_dir(struct odb_source_files *files, return ret; } -static void odb_add_alternate_recursively(struct odb_source_files *files, - const char *path, - int depth) ->>>>>>> 3f91b4bc4b (odb: do not list our own refs as alternate refs in the quarantine) +static void add_alternate_recursively(struct odb_source_files *files, + const char *path, + int depth) { struct odb_files_dir *alternate; struct strvec alternates = STRVEC_INIT; diff --git a/odb/source-files.h b/odb/source-files.h remerge CONFLICT (content): Merge conflict in odb/source-files.h index 7afc2f28ad..9117dbea5b 100644 --- a/odb/source-files.h +++ b/odb/source-files.h @@ -70,22 +70,16 @@ struct odb_source_files { * Whether directory paths shall be compared case-insensitively, as * determined by "core.ignoreCase". */ -<<<<<<< 1707829739 (Merge branch 'kk/connectivity-check-ignore-replace' into seen) int dir_paths_icase; /* Stat data of the "info/alternates" file. */ struct stat_validity alternates_validity; -||||||| ebdc087dc9 - int dirs_paths_icase; -======= - int dirs_paths_icase; /* * The value of GIT_QUARANTINE_PATH when this source was set up from * the environment (see ODB_NEW_HONOR_ENV), or NULL. */ char *quarantine_path; ->>>>>>> 3f91b4bc4b (odb: do not list our own refs as alternate refs in the quarantine) }; /* Allocate and initialize a new object source. */ diff --git a/t/t5618-alternate-refs.sh b/t/t5618-alternate-refs.sh remerge CONFLICT (content): Merge conflict in t/t5618-alternate-refs.sh index cefc37797c..048c7c63c1 100755 --- a/t/t5618-alternate-refs.sh +++ b/t/t5618-alternate-refs.sh @@ -58,34 +58,6 @@ test_expect_success 'log --source shows .alternate marker' ' test_cmp expect actual ' -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1707829739 (Merge branch 'kk/connectivity-check-ignore-replace' into seen) -test_expect_success 'connectivity check of a fetch excludes alternate refs' ' - GIT_TRACE2_EVENT="$(pwd)/fetch.trace" git fetch origin && - test_subcommand_flex git rev-list --objects --stdin --not --all \ - --alternate-refs --quiet >.git/objects/info/alternates && - git cat-file -e $shallow_tip && - git rev-list --remotes=origin >expect && - git rev-list --alternate-refs >actual && - test_cmp expect actual -' - -|||||||||||||||||||||||||||||||| ebdc087dc9 -================================ # Our own object directory as an alternate is not a source of alternate # refs, but the alternates it brings in with it still are. test_expect_success 'own object directory as alternate lists only real alternates' ' @@ -120,5 +92,29 @@ test_expect_success 'parent of the quarantine is not listed as an alternate' ' test_must_be_empty actual ' ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3f91b4bc4b (odb: do not list our own refs as alternate refs in the quarantine) +test_expect_success 'connectivity check of a fetch excludes alternate refs' ' + GIT_TRACE2_EVENT="$(pwd)/fetch.trace" git fetch origin && + test_subcommand_flex git rev-list --objects --stdin --not --all \ + --alternate-refs --quiet >.git/objects/info/alternates && + git cat-file -e $shallow_tip && + git rev-list --remotes=origin >expect && + git rev-list --alternate-refs >actual && + test_cmp expect actual +' + test_done