-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rerere: make sure it works even in a workdir attached to a young repo…
…sitory The git-new-workdir script in contrib/ makes a new work tree by sharing many subdirectories of the .git directory with the original repository. When rerere.enabled is set in the original repository, but the user has not encountered any conflicts yet, the original repository may not yet have .git/rr-cache directory. When rerere wants to run in a new work tree created from such a young original repository, it fails to mkdir(2) .git/rr-cache that is a symlink to a yet-to-be-created directory. There are three possible approaches to this: - A naive solution is not to create a symlink in the git-new-workdir script to a directory the original does not have (yet). This is not a solution, as we tend to lazily create subdirectories of .git/, and having rerere.enabled configuration set is a strong indication that the user _wants_ to have this lazy creation to happen; - We could always create .git/rr-cache upon repository creation. This is tempting but will not help people with existing repositories. - Detect this case by seeing that mkdir(2) failed with EEXIST, checking that the path is a symlink, and try running mkdir(2) on the link target. This patch solves the issue by doing the third one. Strictly speaking, this is incomplete. It does not attempt to handle relative symbolic link that points into the original repository, but this is good enough to help people who use contrib/workdir/git-new-workdir script. Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Junio C Hamano
committed
Mar 23, 2011
1 parent
547e8b9
commit 90a6464
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/sh | ||
|
||
test_description='rerere run in a workdir' | ||
. ./test-lib.sh | ||
|
||
test_expect_success SYMLINKS setup ' | ||
git config rerere.enabled true && | ||
>world && | ||
git add world && | ||
test_tick && | ||
git commit -m initial && | ||
echo hello >world && | ||
test_tick && | ||
git commit -a -m hello && | ||
git checkout -b side HEAD^ && | ||
echo goodbye >world && | ||
test_tick && | ||
git commit -a -m goodbye && | ||
git checkout master | ||
' | ||
|
||
test_expect_success SYMLINKS 'rerere in workdir' ' | ||
rm -rf .git/rr-cache && | ||
"$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . work && | ||
( | ||
cd work && | ||
test_must_fail git merge side && | ||
git rerere status >actual && | ||
echo world >expect && | ||
test_cmp expect actual | ||
) | ||
' | ||
|
||
# This fails because we don't resolve relative symlink in mkdir_in_gitdir() | ||
# For the purpose of helping contrib/workdir/git-new-workdir users, we do not | ||
# have to support relative symlinks, but it might be nicer to make this work | ||
# with a relative symbolic link someday. | ||
test_expect_failure SYMLINKS 'rerere in workdir (relative)' ' | ||
rm -rf .git/rr-cache && | ||
"$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . krow && | ||
( | ||
cd krow && | ||
rm -f .git/rr-cache && | ||
ln -s ../.git/rr-cache .git/rr-cache && | ||
test_must_fail git merge side && | ||
git rerere status >actual && | ||
echo world >expect && | ||
test_cmp expect actual | ||
) | ||
' | ||
|
||
test_done |