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

[PATCH] Fix "git-local-fetch -s" with packed source repository

"git-local-fetch -s" did not work with a packed repository, because symlink() happily created a link to a non-existing object file, therefore fetch_file() always returned success, and fetch_pack() was not called. Fixed by calling stat() before symlink() to ensure the file really exists. Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: Junio C Hamano <junkio@cox.net>

Sergey Vlasov committed Sep 23, 2005 at 16:28 UTC e2b77f026a251a47ebdf634107e76f7b457087af
1 file changed +11 -3
local-fetch.c
+11 -3
@@ -65,9 +65,17 @@ static int copy_file(const char *source, const char *dest, const char *hex)
65 return -1;
66 }
67 }
68 - if (use_symlink && !symlink(source, dest)) {
69 - pull_say("symlink %s\n", hex);
70 - return 0;
68 + if (use_symlink) {
69 + struct stat st;
70 + if (stat(source, &st)) {
71 + fprintf(stderr, "cannot stat %s: %s\n", source,
72 + strerror(errno));
73 + return -1;
74 + }
75 + if (!symlink(source, dest)) {
76 + pull_say("symlink %s\n", hex);
77 + return 0;
78 + }
79 }
80 if (use_filecopy) {
81 int ifd, ofd, status;