Skip to content

Commit e2b77f0

Browse files
sigprofJunio C Hamano
authored andcommitted
[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>
1 parent 1a95181 commit e2b77f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

local-fetch.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ static int copy_file(const char *source, const char *dest, const char *hex)
6565
return -1;
6666
}
6767
}
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+
}
7179
}
7280
if (use_filecopy) {
7381
int ifd, ofd, status;

0 commit comments

Comments
 (0)