X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=sha1_file.c;h=642f00d3d47c3d782c3dfe522d21819c1a67de30;hb=87ce294c9129879f717f8749cae1c659e18a3823;hp=f0590049098b5371bc72855acc5736f9d5f61e2b;hpb=d06b689a933f6d2130f8afdf1ac0ddb83eeb59ab;p=git.git diff --git a/sha1_file.c b/sha1_file.c index f05900490..642f00d3d 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -416,7 +416,7 @@ int use_packed_git(struct packed_git *p) return 0; } -struct packed_git *add_packed_git(char *path, int path_len) +struct packed_git *add_packed_git(char *path, int path_len, int local) { struct stat st; struct packed_git *p; @@ -444,6 +444,7 @@ struct packed_git *add_packed_git(char *path, int path_len) p->pack_base = NULL; p->pack_last_used = 0; p->pack_use_cnt = 0; + p->pack_local = local; return p; } @@ -484,7 +485,7 @@ void install_packed_git(struct packed_git *pack) packed_git = pack; } -static void prepare_packed_git_one(char *objdir) +static void prepare_packed_git_one(char *objdir, int local) { char path[PATH_MAX]; int len; @@ -506,7 +507,7 @@ static void prepare_packed_git_one(char *objdir) /* we have .idx. Is it a file we can map? */ strcpy(path + len, de->d_name); - p = add_packed_git(path, len + namelen); + p = add_packed_git(path, len + namelen, local); if (!p) continue; p->next = packed_git; @@ -522,11 +523,11 @@ void prepare_packed_git(void) if (run_once) return; - prepare_packed_git_one(get_object_directory()); + prepare_packed_git_one(get_object_directory(), 1); prepare_alt_odb(); for (alt = alt_odb_list; alt; alt = alt->next) { alt->name[0] = 0; - prepare_packed_git_one(alt->base); + prepare_packed_git_one(alt->base, 0); } run_once = 1; } @@ -1231,18 +1232,22 @@ static int link_temp_to_file(const char *tmpfile, char *filename) int move_temp_to_file(const char *tmpfile, char *filename) { int ret = link_temp_to_file(tmpfile, filename); - if (ret) { - /* - * Coda hack - coda doesn't like cross-directory links, - * so we fall back to a rename, which will mean that it - * won't be able to check collisions, but that's not a - * big deal. - * - * When this succeeds, we just return 0. We have nothing - * left to unlink. - */ - if (ret == EXDEV && !rename(tmpfile, filename)) + + /* + * Coda hack - coda doesn't like cross-directory links, + * so we fall back to a rename, which will mean that it + * won't be able to check collisions, but that's not a + * big deal. + * + * The same holds for FAT formatted media. + * + * When this succeeds, we just return 0. We have nothing + * left to unlink. + */ + if (ret && ret != EEXIST) { + if (!rename(tmpfile, filename)) return 0; + ret = errno; } unlink(tmpfile); if (ret) {