Skip to content

Commit ad141d4

Browse files
committed
t2400, t5516: strip directory prefix from --git-dir path arguments
This commit replaces a couple of `-C <dir>` invocations where `<dir>` is a bare repository with `--git-dir=<dir>` as part of the `safe.bareRepository` preparation. Since `--git-dir` does not change the working directory, paths that duplicated the directory name as a prefix are now redundant. This commit can be validated in a mechanical way via this command-line: git diff HEAD^! | awk ' /^diff/,/^\+\+\+/ { next } /^-/ { old[m++] = substr($0, 2) } /^\+/ { line = substr($0,2) # apply: -C X -> --git-dir=X and strip ../ if (match(line, /--git-dir=([^ ]*)(.* )([^ ]*)\//, a) && a[1] == a[3]) { gsub(/--git-dir=.*\//, "-C " a[1] a[2], line) } if (old[n++] != line) print old[n-1] " != " line }' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent daeed0d commit ad141d4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

t/t2400-worktree-add.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ test_expect_success '"add --orphan" with empty repository' '
397397
test_when_finished "rm -rf empty_repo" &&
398398
echo refs/heads/newbranch >expected &&
399399
GIT_DIR="empty_repo" git init --bare &&
400-
git -C empty_repo worktree add --orphan -b newbranch worktreedir &&
400+
git --git-dir=empty_repo worktree add --orphan -b newbranch empty_repo/worktreedir &&
401401
git -C empty_repo/worktreedir symbolic-ref HEAD >actual &&
402402
test_cmp expected actual
403403
'

t/t5516-fetch-push.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ test_expect_success 'denyCurrentBranch and worktrees' '
18061806
test_expect_success 'denyCurrentBranch and bare repository worktrees' '
18071807
test_when_finished "rm -fr bare.git" &&
18081808
git clone --bare . bare.git &&
1809-
git -C bare.git worktree add wt &&
1809+
git --git-dir=bare.git worktree add bare.git/wt &&
18101810
test_commit grape &&
18111811
git -C bare.git config receive.denyCurrentBranch refuse &&
18121812
test_must_fail git push bare.git HEAD:wt &&
@@ -1827,7 +1827,7 @@ test_expect_success 'refuse fetch to current branch of worktree' '
18271827
test_expect_success 'refuse fetch to current branch of bare repository worktree' '
18281828
test_when_finished "rm -fr bare.git" &&
18291829
git clone --bare . bare.git &&
1830-
git -C bare.git worktree add wt &&
1830+
git --git-dir=bare.git worktree add bare.git/wt &&
18311831
test_commit banana &&
18321832
test_must_fail git -C bare.git fetch .. HEAD:wt &&
18331833
git -C bare.git fetch -u .. HEAD:wt

0 commit comments

Comments
 (0)