Skip to content

Commit 3a026d3

Browse files
uecasmdscho
authored andcommitted
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 git-for-windows#233. [jes: fixed the commit message, made the sign-off explicit] Signed-off-by: Gavin Lambert <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b3b8b31 commit 3a026d3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

perl/Git/SVN.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,11 @@ sub tie_for_persistent_memoization {
15851585
if ($memo_backend > 0) {
15861586
tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml";
15871587
} else {
1588+
# first verify that any existing file can actually be loaded
1589+
# (it may have been saved by an incompatible version)
1590+
if (-e "$path.db") {
1591+
unlink "$path.db" unless eval { retrieve("$path.db"); 1 };
1592+
}
15881593
tie %$hash => 'Memoize::Storable', "$path.db", 'nstore';
15891594
}
15901595
}

0 commit comments

Comments
 (0)