@matheusbsbs / matheus-bagliano / commits / d9042a0ac4
Fork 0

Fix race condition in t9119-git-svn-info.sh

Changed the ptouch bash function to use the "Text Last Updated" date reported by 'svn info' when changing the modified time (mtime) of the file/symlink/directory in the git working directory. Previously it used the mtime of the item in the svn working directory, which caused the race condition. [ew: swapped argument order of ptouch() to minimize diff] From: David D. Kilzer <ddkilzer@kilzer.net> Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David D. Kilzer committed Aug 5, 2008 at 00:35 UTC d9042a0ac41ebd23e4dac00371a682d964eafee7
1 file changed +11 -4
t/t9119-git-svn-info.sh
+11 -4
@@ -11,11 +11,18 @@ test_done
11 ptouch() {
12 perl -w -e '
13 use strict;
14 + use POSIX qw(mktime);
15 die "ptouch requires exactly 2 arguments" if @ARGV != 2;
15 - die "$ARGV[0] does not exist" if ! -e $ARGV[0];
16 - my @s = stat $ARGV[0];
17 - utime $s[8], $s[9], $ARGV[1];
18 - ' "$1" "$2"
16 + my $text_last_updated = shift @ARGV;
17 + my $git_file = shift @ARGV;
18 + die "\"$git_file\" does not exist" if ! -e $git_file;
19 + if ($text_last_updated
20 + =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
21 + my $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);
22 + my $atime = $mtime;
23 + utime $atime, $mtime, $git_file;
24 + }
25 + ' "`svn info $2 | grep '^Text Last Updated:'`" "$1"
26 }
27
28 test_expect_success 'setup repository and import' "