From 7b917606f04daf62e75b1dd435e4edebde0eeca0 Mon Sep 17 00:00:00 2001 From: Gavin Lambert Date: Fri, 17 Jul 2015 13:36:00 +1200 Subject: [PATCH] git-svn: do not reuse caches memoized for a different architecture Reusing cached data speeds up git-svn by quite a fair bit. However, if the YAML module is unavailable, the caches are written to disk in an architecture-dependent manner. That leads to problems when upgrading, say, from 32-bit to 64-bit Git for Windows. Let's just try to read those caches back if we detect the absence of the YAML module and the presence of the file, and delete the file if it could not be read back correctly. Note that the only way to catch the error when the memoized cache could not be read back is to put the call inside an `eval { ... }` block because it would die otherwise; the `eval` block should also return `1` in case of success explicitly since the function reading back the cached data does not return an appropriate value to test for success. This fixes https://github.com/git-for-windows/git/issues/233. [jes: fixed the commit message, made the sign-off explicit] Signed-off-by: Gavin Lambert Signed-off-by: Johannes Schindelin --- perl/Git/SVN.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm index d94d01cfdc..d25034eab4 100644 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@ -1654,6 +1654,11 @@ sub tie_for_persistent_memoization { if ($memo_backend > 0) { tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml"; } else { + # first verify that any existing file can actually be loaded + # (it may have been saved by an incompatible version) + if (-e "$path.db") { + unlink "$path.db" unless eval { retrieve("$path.db"); 1 }; + } tie %$hash => 'Memoize::Storable', "$path.db", 'nstore'; } }