Skip to content

Commit 01d6be9

Browse files
committed
Let nonstandard worktree fixtures work even if Git < 2.37.2
This reorders the operations in the nonstandard worktree fixtures to work even when Git is at a lower version than 2.37.2. This makes root_enters_directory_with_dot_git_in_reconfigured_worktree_tracked pass on more systems, including common development systems. When fixture scripts are run on a system whose Git version is lower than 2.37.2, including currently maintained downstream versions with backported security (but not most other) fixes on some popular OSes (e.g. Ubuntu 22.04.4 LTS with 2.34.1-1ubuntu1.10), the gix-dir nonstandard worktree fixtures had silently failed to stage one of two intended files. They appeared to succeed, but created a repo with only the "seemingly-outside" file, and not the "inside" file. This is due to the bug git/git@27128996b8 fixed in Git. The nonstandard worktree fixtures had needed Git to support the first condition noted there, where core.worktree is the parent of the default worktree, in order to stage both files. The change made here overcomes the problem by staging before rather than after moving .git and setting core.worktree. The `git add` command used to stage is adjusted to remain equivalent in its effect. (Committing can be, and is, still done last.) CI hadn't suffered/shown the problem, since while GHA ubuntu-latest runners are currently Ubuntu 22.04, they have many newer software versions installed on them, currently including Git 2.43.2.
1 parent 4bb8ef5 commit 01d6be9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

gix-dir/tests/fixtures/many.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,22 @@ git clone dir-with-tracked-file with-submodule
110110
git init nonstandard-worktree
111111
(cd nonstandard-worktree
112112
mkdir dir-with-dot-git
113-
mv .git dir-with-dot-git
114-
115-
git -C dir-with-dot-git config core.worktree "$PWD"
116113
touch dir-with-dot-git/inside
117114
touch seemingly-outside
118-
git -C dir-with-dot-git add inside ../seemingly-outside
115+
git add dir-with-dot-git/inside seemingly-outside
116+
mv .git dir-with-dot-git
117+
git -C dir-with-dot-git config core.worktree "$PWD"
119118
git -C dir-with-dot-git commit -m "init"
120119
)
121120

122121
git init nonstandard-worktree-untracked
123122
(cd nonstandard-worktree-untracked
124123
mkdir dir-with-dot-git
125-
mv .git dir-with-dot-git
126-
127-
git -C dir-with-dot-git config core.worktree "$PWD"
128124
touch dir-with-dot-git/inside
129125
touch seemingly-outside
130-
git -C dir-with-dot-git add inside ../seemingly-outside
126+
git add dir-with-dot-git/inside seemingly-outside
127+
mv .git dir-with-dot-git
128+
git -C dir-with-dot-git config core.worktree "$PWD"
131129
git -C dir-with-dot-git commit -m "init"
132130

133131
rm dir-with-dot-git/.git/index

0 commit comments

Comments
 (0)