Skip to content

Commit 0af0ac7

Browse files
dschogitster
authored andcommitted
Move MERGE_RR from .git/rr-cache/ into .git/
If you want to reuse the rerere cache in another repository, and set a symbolic link to it, you do not want to have the two repositories interfer with each other by accessing the _same_ MERGE_RR. For example, if you use contrib/git-new-workdir to set up a second working directory, and you have a conflict in one working directory, but commit in the other working directory first, the wrong "resolution" will be recorded. The easy solution is to move MERGE_RR out of the rr-cache/ directory, which also corresponds with the notion that rr-cache/ contains cached resolutions, not some intermediate temporary states. Noticed by Kalle Olavi Niemitalo. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 99d698f commit 0af0ac7

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void create_branch(const char *head,
166166
void remove_branch_state(void)
167167
{
168168
unlink(git_path("MERGE_HEAD"));
169-
unlink(git_path("rr-cache/MERGE_RR"));
169+
unlink(git_path("MERGE_RR"));
170170
unlink(git_path("MERGE_MSG"));
171171
unlink(git_path("SQUASH_MSG"));
172172
}

builtin-rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static int setup_rerere(struct path_list *merge_rr)
429429
if (!is_rerere_enabled())
430430
return -1;
431431

432-
merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
432+
merge_rr_path = xstrdup(git_path("MERGE_RR"));
433433
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
434434
read_rr(merge_rr);
435435
return fd;

t/t4200-rerere.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test_expect_success 'conflicting merge' '
5757
! git merge first
5858
'
5959

60-
sha1=$(sed -e 's/ .*//' .git/rr-cache/MERGE_RR)
60+
sha1=$(sed -e 's/ .*//' .git/MERGE_RR)
6161
rr=.git/rr-cache/$sha1
6262
test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
6363

@@ -143,7 +143,7 @@ test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
143143
test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
144144

145145
rm $rr/postimage
146-
echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/rr-cache/MERGE_RR
146+
echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
147147

148148
test_expect_success 'rerere clear' 'git rerere clear'
149149

@@ -190,7 +190,7 @@ test_expect_success 'file2 added differently in two branches' '
190190
git add file2 &&
191191
git commit -m version2 &&
192192
! git merge fourth &&
193-
sha1=$(sed -e "s/ .*//" .git/rr-cache/MERGE_RR) &&
193+
sha1=$(sed -e "s/ .*//" .git/MERGE_RR) &&
194194
rr=.git/rr-cache/$sha1 &&
195195
echo Cello > file2 &&
196196
git add file2 &&

0 commit comments

Comments
 (0)