mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Add a submoduleEncoding extension which fixes filesystem collisions by encoding gitdir paths. At a high level, this implements a mechanism to encode -> validate -> retry until a working gitdir path is found. Credit goes to Junio for coming up with this design: encoding is only applied when necessary, e.g. uppercase characters are encoded only on case-folding filesystems and only if a real conflict is detected. To make this work, we rely on the submodule.<name>.gitdir config as the single source of truth for gitidir paths: the config is always set when the extension is enabled. Users who care about gitdir paths are expected to get/set the config and not the underlying encoding implementation. This commit adds the basic encoding logic which addresses nested gitdirs. The next commit fixes case-folding, the next commit fixes names longer than NAME_MAX. The idea is the encoding can be improved over time in a way which is transparent to users. Suggested-by: Junio C Hamano <gitster@pobox.com> Suggested-by: Phillip Wood <phillip.wood123@gmail.com> Suggested-by: Patrick Steinhardt <ps@pks.im> Based-on-patch-by: Brandon Williams <bwilliams.eng@gmail.com> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
25 lines
879 B
Bash
25 lines
879 B
Bash
# Helper to verify if repo $1 contains a submodule named $2 with gitdir path $3
|
|
|
|
# This does not check filesystem existence. That is done in submodule.c via the
|
|
# submodule_name_to_gitdir() API which this helper ends up calling. The gitdirs
|
|
# might or might not exist (e.g. when adding a new submodule), so this only
|
|
# checks the expected configuration path, which might be overridden by the user.
|
|
|
|
verify_submodule_gitdir_path() {
|
|
repo="$1" &&
|
|
name="$2" &&
|
|
path="$3" &&
|
|
(
|
|
cd "$repo" &&
|
|
# Compute expected absolute path
|
|
expected="$(git rev-parse --git-common-dir)/$path" &&
|
|
expected="$(test-tool path-utils real_path "$expected")" &&
|
|
# Compute actual absolute path
|
|
actual="$(git submodule--helper gitdir "$name")" &&
|
|
actual="$(test-tool path-utils real_path "$actual")" &&
|
|
echo "$expected" >expect &&
|
|
echo "$actual" >actual &&
|
|
test_cmp expect actual
|
|
)
|
|
}
|