Merge branch 'jc/finalize-temp-file'
Long overdue micro clean-up. * jc/finalize-temp-file: sha1_file.c: rename move_temp_to_file() to finalize_object_file()maint
commit
51a22ce147
|
@ -1421,7 +1421,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
|
||||||
get_object_directory(), sha1_to_hex(sha1));
|
get_object_directory(), sha1_to_hex(sha1));
|
||||||
final_pack_name = name;
|
final_pack_name = name;
|
||||||
}
|
}
|
||||||
if (move_temp_to_file(curr_pack_name, final_pack_name))
|
if (finalize_object_file(curr_pack_name, final_pack_name))
|
||||||
die(_("cannot store pack file"));
|
die(_("cannot store pack file"));
|
||||||
} else if (from_stdin)
|
} else if (from_stdin)
|
||||||
chmod(final_pack_name, 0444);
|
chmod(final_pack_name, 0444);
|
||||||
|
@ -1432,7 +1432,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
|
||||||
get_object_directory(), sha1_to_hex(sha1));
|
get_object_directory(), sha1_to_hex(sha1));
|
||||||
final_index_name = name;
|
final_index_name = name;
|
||||||
}
|
}
|
||||||
if (move_temp_to_file(curr_index_name, final_index_name))
|
if (finalize_object_file(curr_index_name, final_index_name))
|
||||||
die(_("cannot store index file"));
|
die(_("cannot store index file"));
|
||||||
} else
|
} else
|
||||||
chmod(final_index_name, 0444);
|
chmod(final_index_name, 0444);
|
||||||
|
|
2
cache.h
2
cache.h
|
@ -945,7 +945,7 @@ extern int do_check_packed_object_crc;
|
||||||
|
|
||||||
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
|
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
|
||||||
|
|
||||||
extern int move_temp_to_file(const char *tmpfile, const char *filename);
|
extern int finalize_object_file(const char *tmpfile, const char *filename);
|
||||||
|
|
||||||
extern int has_sha1_pack(const unsigned char *sha1);
|
extern int has_sha1_pack(const unsigned char *sha1);
|
||||||
|
|
||||||
|
|
|
@ -923,12 +923,12 @@ static char *keep_pack(const char *curr_index_name)
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
|
snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
|
||||||
get_object_directory(), sha1_to_hex(pack_data->sha1));
|
get_object_directory(), sha1_to_hex(pack_data->sha1));
|
||||||
if (move_temp_to_file(pack_data->pack_name, name))
|
if (finalize_object_file(pack_data->pack_name, name))
|
||||||
die("cannot store pack file");
|
die("cannot store pack file");
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
|
snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
|
||||||
get_object_directory(), sha1_to_hex(pack_data->sha1));
|
get_object_directory(), sha1_to_hex(pack_data->sha1));
|
||||||
if (move_temp_to_file(curr_index_name, name))
|
if (finalize_object_file(curr_index_name, name))
|
||||||
die("cannot store index file");
|
die("cannot store index file");
|
||||||
free((void *)curr_index_name);
|
free((void *)curr_index_name);
|
||||||
return name;
|
return name;
|
||||||
|
|
10
http.c
10
http.c
|
@ -1318,7 +1318,7 @@ static int http_get_file(const char *url, const char *filename,
|
||||||
ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
|
ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
|
||||||
fclose(result);
|
fclose(result);
|
||||||
|
|
||||||
if (ret == HTTP_OK && move_temp_to_file(tmpfile.buf, filename))
|
if (ret == HTTP_OK && finalize_object_file(tmpfile.buf, filename))
|
||||||
ret = HTTP_ERROR;
|
ret = HTTP_ERROR;
|
||||||
cleanup:
|
cleanup:
|
||||||
strbuf_release(&tmpfile);
|
strbuf_release(&tmpfile);
|
||||||
|
@ -1405,7 +1405,7 @@ static int fetch_and_setup_pack_index(struct packed_git **packs_head,
|
||||||
ret = verify_pack_index(new_pack);
|
ret = verify_pack_index(new_pack);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
close_pack_index(new_pack);
|
close_pack_index(new_pack);
|
||||||
ret = move_temp_to_file(tmp_idx, sha1_pack_index_name(sha1));
|
ret = finalize_object_file(tmp_idx, sha1_pack_index_name(sha1));
|
||||||
}
|
}
|
||||||
free(tmp_idx);
|
free(tmp_idx);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1517,8 +1517,8 @@ int finish_http_pack_request(struct http_pack_request *preq)
|
||||||
|
|
||||||
unlink(sha1_pack_index_name(p->sha1));
|
unlink(sha1_pack_index_name(p->sha1));
|
||||||
|
|
||||||
if (move_temp_to_file(preq->tmpfile, sha1_pack_name(p->sha1))
|
if (finalize_object_file(preq->tmpfile, sha1_pack_name(p->sha1))
|
||||||
|| move_temp_to_file(tmp_idx, sha1_pack_index_name(p->sha1))) {
|
|| finalize_object_file(tmp_idx, sha1_pack_index_name(p->sha1))) {
|
||||||
free(tmp_idx);
|
free(tmp_idx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1782,7 +1782,7 @@ int finish_http_object_request(struct http_object_request *freq)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
freq->rename =
|
freq->rename =
|
||||||
move_temp_to_file(freq->tmpfile, sha1_file_name(freq->sha1));
|
finalize_object_file(freq->tmpfile, sha1_file_name(freq->sha1));
|
||||||
|
|
||||||
return freq->rename;
|
return freq->rename;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2908,11 +2908,8 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the just written object into its final resting place.
|
* Move the just written object into its final resting place.
|
||||||
* NEEDSWORK: this should be renamed to finalize_temp_file() as
|
|
||||||
* "moving" is only a part of what it does, when no patch between
|
|
||||||
* master to pu changes the call sites of this function.
|
|
||||||
*/
|
*/
|
||||||
int move_temp_to_file(const char *tmpfile, const char *filename)
|
int finalize_object_file(const char *tmpfile, const char *filename)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -3085,7 +3082,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
|
||||||
tmp_file, strerror(errno));
|
tmp_file, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return move_temp_to_file(tmp_file, filename);
|
return finalize_object_file(tmp_file, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int freshen_loose_object(const unsigned char *sha1)
|
static int freshen_loose_object(const unsigned char *sha1)
|
||||||
|
|
Loading…
Reference in New Issue