From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: "Junio C Hamano" <gitster@pobox.com>,
git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: [PATCH 2/2] rerere: fix overeager gc
Date: Thu, 1 Jul 2010 13:07:46 +0200 [thread overview]
Message-ID: <1277982466-29601-2-git-send-email-szeder@ira.uka.de> (raw)
In-Reply-To: <4C2C69AF.4010303@viscovery.net>
'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 merge 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.
Prevent the loss of valuable merge resolutions by updating the
timestamp of the conflicted automerge result each time when
encountering the same merge conflict.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
On Thu, Jul 01, 2010 at 12:10:55PM +0200, Johannes Sixt wrote:
> rerere_last_used_at?
> I think this should be outside of 'if (!ret)' condition because even if
> the merge fails, the resolution was *used*.
Right on both points.
builtin/rerere.c | 4 ++--
rerere.c | 4 ++++
t/t4200-rerere.sh | 8 ++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 980d542..03434a7 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -13,7 +13,7 @@ static const char git_rerere_usage[] =
static int cutoff_noresolve = 15;
static int cutoff_resolve = 60;
-static time_t rerere_created_at(const char *name)
+static time_t rerere_last_used_at(const char *name)
{
struct stat st;
return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
@@ -53,7 +53,7 @@ static void garbage_collect(struct string_list *rr)
while ((e = readdir(dir))) {
if (is_dot_or_dotdot(e->d_name))
continue;
- then = rerere_created_at(e->d_name);
+ then = rerere_last_used_at(e->d_name);
if (!then)
continue;
cutoff = (has_rerere_resolution(e->d_name)
diff --git a/rerere.c b/rerere.c
index d03a696..0d8a167 100644
--- a/rerere.c
+++ b/rerere.c
@@ -389,6 +389,10 @@ static int merge(const char *name, const char *path)
strerror(errno));
}
+ if (utime(rerere_path(name, "preimage"), NULL) < 0)
+ warning("failed utime() on %s: %s",
+ rerere_path(name, "preimage"), strerror(errno));
+
out:
free(cur.ptr);
free(base.ptr);
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 70856d0..c01d930 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -144,6 +144,14 @@ test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
+test_expect_success 'rerere updates preimage timestamp' '
+ git reset --hard &&
+ oldmtime=$(test-chmtime -v -42 $rr/preimage |cut -f 1) &&
+ test_must_fail git pull . first &&
+ newmtime=$(test-chmtime -v +0 $rr/preimage |cut -f 1) &&
+ test $oldmtime -lt $newmtime
+'
+
rm $rr/postimage
echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
--
1.7.2.rc0.54.g4d821
next prev parent reply other threads:[~2010-07-01 11:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-29 11:38 [RFC PATCH] rerere: fix overeager gc SZEDER Gábor
2010-06-29 17:59 ` Junio C Hamano
2010-06-30 6:12 ` Johannes Sixt
2010-06-30 8:01 ` SZEDER Gábor
2010-06-30 15:22 ` Junio C Hamano
2010-06-30 15:40 ` Johannes Sixt
2010-07-01 9:36 ` [PATCH v2] " SZEDER Gábor
2010-07-01 10:10 ` Johannes Sixt
2010-07-01 11:07 ` [PATCH 1/2] mingw: utime() handles NULL times parameter SZEDER Gábor
2010-07-01 12:16 ` [PATCH 1/2 fixed] mingw_utime(): handle " Johannes Sixt
2010-07-01 11:07 ` SZEDER Gábor [this message]
2010-07-01 16:27 ` [RFC PATCH] rerere: fix overeager gc Junio C Hamano
2010-07-02 5:49 ` Johannes Sixt
2010-07-02 17:25 ` Junio C Hamano
2010-07-05 6:02 ` Johannes Sixt
2010-07-08 14:35 ` [PATCH v4] " SZEDER Gábor
2010-07-09 0:06 ` [RFC PATCH] " Junio C Hamano
2010-07-12 23:42 ` [PATCH 1/2] mingw_utime(): handle NULL times parameter SZEDER Gábor
2010-07-12 23:42 ` [PATCH 2/2] rerere: fix overeager gc SZEDER Gábor
2010-07-13 0:40 ` Junio C Hamano
2010-07-14 12:19 ` SZEDER Gábor
2010-07-14 16:23 ` Junio C Hamano
2010-07-14 18:33 ` SZEDER Gábor
2010-07-08 6:27 ` [RFC PATCH] " Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277982466-29601-2-git-send-email-szeder@ira.uka.de \
--to=szeder@ira.uka.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).