Skip to content

Commit d9da26a

Browse files
uecasmdscho
authored andcommitted
squash! git-svn: do not reuse caches memoized for a different architecture
This commit overrides the original one, carried by Git for Windows for over a year, with the version by Eric, which appears as if it should be obviously good, and which already has been merged to upstream's `master`. 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 #233. [ew: import "retrieve" explictly, check unlink result] Signed-off-by: Gavin Lambert <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent 805b7b1 commit d9da26a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

perl/Git/SVN.pm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,10 +1660,15 @@ sub tie_for_persistent_memoization {
16601660
} else {
16611661
# first verify that any existing file can actually be loaded
16621662
# (it may have been saved by an incompatible version)
1663-
if (-e "$path.db") {
1664-
unlink "$path.db" unless eval { retrieve("$path.db"); 1 };
1663+
my $db = "$path.db";
1664+
if (-e $db) {
1665+
use Storable qw(retrieve);
1666+
1667+
if (!eval { retrieve($db); 1 }) {
1668+
unlink $db or die "unlink $db failed: $!";
1669+
}
16651670
}
1666-
tie %$hash => 'Memoize::Storable', "$path.db", 'nstore';
1671+
tie %$hash => 'Memoize::Storable', $db, 'nstore';
16671672
}
16681673
}
16691674

0 commit comments

Comments
 (0)