Last active
November 17, 2022 04:04
-
-
Save NonLogicalDev/29b55d855c8aaae0a641cd0dda2ec443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
rm -rf repo* | |
ROOT_DIR="$(pwd)" | |
mkdir repo-origin | |
export GIT_PAGER=cat | |
( | |
cd repo-origin | |
mkdir 1 | |
touch 1/a | |
touch 1/b | |
touch 1/c | |
mkdir 2 | |
touch 2/a | |
touch 2/b | |
touch 2/c | |
git init | |
git add -A | |
git commit -m "INIT" | |
git config core.repositoryformatversion 1 | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
) | |
( | |
git clone ${ROOT_DIR}/repo-origin --filter=blob:none --single-branch --no-tags repo-parent | |
cd repo-parent | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
git worktree add --no-checkout -b sparse-main ${ROOT_DIR}/repo-worktree HEAD | |
) | |
( | |
cd repo-worktree | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
git branch --set-upstream-to=origin main | |
echo "## Test: Worktree Extension is not setup" | |
test $( git config -l | grep -q worktree ; echo $? ) == 1 | |
git sparse-checkout init --cone | |
echo "## Test: Worktree Config is available" | |
test -n $(git config -l --worktree | grep "cone") | |
echo "## Test: Worktree Extension is setup" | |
test $( git config -l | grep -q worktree ; echo $? ) == 0 | |
git sparse-checkout add 1 | |
git sparse-checkout reapply | |
git reset --hard | |
git status | |
find . -type f | |
stg init || ( echo "FAIL" && false ) | |
echo "OK" | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
rm -rf repo* | |
ROOT_DIR="$(pwd)" | |
mkdir repo-origin | |
export GIT_PAGER=cat | |
( | |
cd repo-origin | |
mkdir 1 | |
touch 1/a | |
touch 1/b | |
touch 1/c | |
mkdir 2 | |
touch 2/a | |
touch 2/b | |
touch 2/c | |
# This one is the killer. | |
# | |
# if object format is not set to sha256 then repositoryformatversion gets set to 0 | |
# otherwise if we do set it to SHA256 the repositoryformatversion gets set to 1 | |
# and all of the clones of this repo inherit this setting. | |
# | |
# https://github.com/git/git/blob/63bba4fdd86d80ef061c449daa97a981a9be0792/builtin/init-db.c#L173-L181 | |
# ``` | |
# int repo_version = GIT_REPO_VERSION; | |
# | |
# if (hash_algo != GIT_HASH_SHA1) | |
# repo_version = GIT_REPO_VERSION_READ; | |
# /* This forces creation of new config file */ | |
# xsnprintf(repo_version_string, sizeof(repo_version_string), | |
# "%d", repo_version); | |
# git_config_set("core.repositoryformatversion", repo_version_string); | |
# ``` | |
# | |
# https://github.com/git/git/blob/6c8e4ee870332d11e4bba84901654b355a9ff016/cache.h#L1135-L1141 | |
# ``` | |
# define GIT_REPO_VERSION 0 | |
# define GIT_REPO_VERSION_READ 1 | |
# ``` | |
git init --object-format sha256 | |
git add -A | |
git commit -m "INIT" | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
) | |
( | |
git clone ${ROOT_DIR}/repo-origin --single-branch --no-tags repo-parent | |
cd repo-parent | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
git worktree add --no-checkout -b sparse-main ${ROOT_DIR}/repo-worktree HEAD | |
) | |
( | |
cd repo-worktree | |
echo "## Repo Version:" | |
git config core.repositoryformatversion | |
git branch --set-upstream-to=origin main | |
echo "## Test: Worktree Extension is not setup" | |
test $( git config -l | grep -q worktree ; echo $? ) == 1 | |
git sparse-checkout init --cone | |
echo "## Test: Worktree Config is available" | |
test -n $(git config -l --worktree | grep "cone") | |
echo "## Test: Worktree Extension is setup" | |
test $( git config -l | grep -q worktree ; echo $? ) == 0 | |
git sparse-checkout add 1 | |
git sparse-checkout reapply | |
git reset --hard | |
git status | |
find . -type f | |
stg init || ( echo "FAIL" && false ) | |
echo "OK" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment