Commit d2a4a54bf9bdb5b8dd9e8c668dd3af14114855ab

Vicent Martí 2013-03-25T21:46:51

Merge pull request #1438 from ethomson/checkout_stat don't stat until the file is written

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/checkout.c b/src/checkout.c
index 5a2698e..2a29b18 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -666,11 +666,11 @@ static int buffer_to_file(
 		giterr_set(GITERR_OS, "Could not write to '%s'", path);
 		(void)p_close(fd);
 	} else {
-		if ((error = p_fstat(fd, st)) < 0)
-			giterr_set(GITERR_OS, "Error while statting '%s'", path);
-
 		if ((error = p_close(fd)) < 0)
 			giterr_set(GITERR_OS, "Error while closing '%s'", path);
+
+		if ((error = p_stat(path, st)) < 0)
+			giterr_set(GITERR_OS, "Error while statting '%s'", path);
 	}
 
 	if (!error &&