summaryrefslogtreecommitdiff
path: root/rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-11 00:02:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-03-23 23:05:44 (GMT)
commit90a6464b4ad5887e4d12e660f51dabdbd5c00812 (patch)
tree1ccc1deb96f7dd9edb8b5929e61fa08d619c666d /rerere.c
parent547e8b9205349b47003ed25a82673e413e71c255 (diff)
downloadgit-90a6464b4ad5887e4d12e660f51dabdbd5c00812.zip
git-90a6464b4ad5887e4d12e660f51dabdbd5c00812.tar.gz
git-90a6464b4ad5887e4d12e660f51dabdbd5c00812.tar.bz2
rerere: make sure it works even in a workdir attached to a young repository
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>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/rerere.c b/rerere.c
index a59f74f..2d8de61 100644
--- a/rerere.c
+++ b/rerere.c
@@ -522,8 +522,7 @@ static int is_rerere_enabled(void)
if (rerere_enabled < 0)
return rr_cache_exists;
- if (!rr_cache_exists &&
- (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache)))
+ if (!rr_cache_exists && mkdir_in_gitdir(rr_cache))
die("Could not create directory %s", rr_cache);
return 1;
}