Patrick Steinhardt [off-list ref] writes:
Similar as in the preceding commit, move the setup of alternates for
local clones with "--no-shared" into `collect_alternates()`. With this
step, the complete setup of alternates is now handled by that function.
Note that besides moving stuff around, it also fixes a bug: previously,
we did not know to resolve the referenced repository's common directory.
Consequently, when referencing a worktree we failed to resolve
alternates. But as `collect_alternates()` already knows to resolve the
commondir for "--local" we can simply reuse this resolved path for our
purpose.
Add two tests, the first one of which exercises this bug to avoid future
regressions. The second test ensures that we properly handle relative
alternates for a referenced worktree.
[snip]
quoted hunk ↗ jump to hunk
static void collect_alternates(struct strvec *alternates,
@@ -242,6 +254,8 @@ static void collect_alternates(struct strvec *alternates,
get_common_dir(&commondir, src_repo);
if (option_shared)
strvec_pushf(alternates, "%s/objects", commondir.buf);
+ else
+ read_alternates(alternates, commondir.buf);
Okay so this is why we did what we did in the prev patch. Makes sense.
strbuf_release(&commondir);
}
[snip]