summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ded2d47)
raw | patch | inline | side by side (parent: ded2d47)
author | SZEDER Gábor <szeder@ira.uka.de> | |
Mon, 12 Jul 2010 23:42:04 +0000 (01:42 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 14 Jul 2010 16:26:57 +0000 (09:26 -0700) |
'rerere gc' prunes resolutions of conflicted merges that occurred long
time ago, and when doing so it takes the creation time of the
conflicted automerge results into account. This can cause the loss of
frequently used conflict resolutions (e.g. long-living topic branches
are merged into a regularly rebuilt integration branch (think of git's
pu)) when they become old enough to exceed 'rerere gc's threshold.
To prevent the loss of valuable merge resolutions 'rerere' will (1)
update the timestamp of the recorded conflict resolution (i.e.
'postimage') each time when encountering and resolving the same merge
conflict, and (2) take this timestamp, i.e. the time of the last usage
into account when gc'ing.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
time ago, and when doing so it takes the creation time of the
conflicted automerge results into account. This can cause the loss of
frequently used conflict resolutions (e.g. long-living topic branches
are merged into a regularly rebuilt integration branch (think of git's
pu)) when they become old enough to exceed 'rerere gc's threshold.
To prevent the loss of valuable merge resolutions 'rerere' will (1)
update the timestamp of the recorded conflict resolution (i.e.
'postimage') each time when encountering and resolving the same merge
conflict, and (2) take this timestamp, i.e. the time of the last usage
into account when gc'ing.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rerere.c | patch | blob | history | |
rerere.c | patch | blob | history | |
t/t4200-rerere.sh | patch | blob | history |
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 0048f9ef7fee24e5e058ef226f3b0fc93703fcf1..6d1b5802add040b7189630077c1bc10b82f76756 100644 (file)
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
}
+static time_t rerere_last_used_at(const char *name)
+{
+ struct stat st;
+ return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
+}
+
static void unlink_rr_item(const char *name)
{
unlink(rerere_path(name, "thisimage"));
while ((e = readdir(dir))) {
if (is_dot_or_dotdot(e->d_name))
continue;
- then = rerere_created_at(e->d_name);
- if (!then)
- continue;
- cutoff = (has_rerere_resolution(e->d_name)
- ? cutoff_resolve : cutoff_noresolve);
+
+ then = rerere_last_used_at(e->d_name);
+ if (then) {
+ cutoff = cutoff_resolve;
+ } else {
+ then = rerere_created_at(e->d_name);
+ if (!then)
+ continue;
+ cutoff = cutoff_noresolve;
+ }
if (then < now - cutoff * 86400)
string_list_append(e->d_name, &to_remove);
}
diff --git a/rerere.c b/rerere.c
index f221bed1e97a0f1b41d1845edac270a109e3a4dd..a6f6681e112af2fc209fe2b5297ec319ebfd24b5 100644 (file)
--- a/rerere.c
+++ b/rerere.c
}
ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
if (!ret) {
- FILE *f = fopen(path, "w");
+ FILE *f;
+
+ if (utime(rerere_path(name, "postimage"), NULL) < 0)
+ warning("failed utime() on %s: %s",
+ rerere_path(name, "postimage"),
+ strerror(errno));
+ f = fopen(path, "w");
if (!f)
return error("Could not open %s: %s", path,
strerror(errno));
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 70856d07ed113b731d149bde73fe7b4eb25a72f2..093b1389116250ada236b5949fab269fd567b643 100755 (executable)
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
test_expect_success 'recorded postimage' "test -f $rr/postimage"
+oldmtimepost=$(test-chmtime -v -60 $rr/postimage |cut -f 1)
+
test_expect_success 'another conflicting merge' '
git checkout -b third master &&
git show second^:a1 | sed "s/To die: t/To die! T/" > a1 &&
test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
+test_expect_success 'rerere updates postimage timestamp' '
+ newmtimepost=$(test-chmtime -v +0 $rr/postimage |cut -f 1) &&
+ test $oldmtimepost -lt $newmtimepost
+'
+
rm $rr/postimage
echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
almost_60_days_ago=$((60-60*86400))
just_over_60_days_ago=$((-1-60*86400))
-test-chmtime =$almost_60_days_ago $rr/preimage
+test-chmtime =$just_over_60_days_ago $rr/preimage
+test-chmtime =$almost_60_days_ago $rr/postimage
test-chmtime =$almost_15_days_ago $rr2/preimage
test_expect_success 'garbage collection (part1)' 'git rerere gc'
-test_expect_success 'young records still live' \
+test_expect_success 'young or recently used records still live' \
"test -f $rr/preimage && test -f $rr2/preimage"
-test-chmtime =$just_over_60_days_ago $rr/preimage
+test-chmtime =$just_over_60_days_ago $rr/postimage
test-chmtime =$just_over_15_days_ago $rr2/preimage
test_expect_success 'garbage collection (part2)' 'git rerere gc'