Skip to content

Commit 51a22ce

Browse files
committed
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()
2 parents 4bfab58 + cb5add5 commit 51a22ce

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
14211421
get_object_directory(), sha1_to_hex(sha1));
14221422
final_pack_name = name;
14231423
}
1424-
if (move_temp_to_file(curr_pack_name, final_pack_name))
1424+
if (finalize_object_file(curr_pack_name, final_pack_name))
14251425
die(_("cannot store pack file"));
14261426
} else if (from_stdin)
14271427
chmod(final_pack_name, 0444);
@@ -1432,7 +1432,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
14321432
get_object_directory(), sha1_to_hex(sha1));
14331433
final_index_name = name;
14341434
}
1435-
if (move_temp_to_file(curr_index_name, final_index_name))
1435+
if (finalize_object_file(curr_index_name, final_index_name))
14361436
die(_("cannot store index file"));
14371437
} else
14381438
chmod(final_index_name, 0444);

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ extern int do_check_packed_object_crc;
945945

946946
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
947947

948-
extern int move_temp_to_file(const char *tmpfile, const char *filename);
948+
extern int finalize_object_file(const char *tmpfile, const char *filename);
949949

950950
extern int has_sha1_pack(const unsigned char *sha1);
951951

fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,12 +923,12 @@ static char *keep_pack(const char *curr_index_name)
923923

924924
snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
925925
get_object_directory(), sha1_to_hex(pack_data->sha1));
926-
if (move_temp_to_file(pack_data->pack_name, name))
926+
if (finalize_object_file(pack_data->pack_name, name))
927927
die("cannot store pack file");
928928

929929
snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
930930
get_object_directory(), sha1_to_hex(pack_data->sha1));
931-
if (move_temp_to_file(curr_index_name, name))
931+
if (finalize_object_file(curr_index_name, name))
932932
die("cannot store index file");
933933
free((void *)curr_index_name);
934934
return name;

http.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ static int http_get_file(const char *url, const char *filename,
13181318
ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
13191319
fclose(result);
13201320

1321-
if (ret == HTTP_OK && move_temp_to_file(tmpfile.buf, filename))
1321+
if (ret == HTTP_OK && finalize_object_file(tmpfile.buf, filename))
13221322
ret = HTTP_ERROR;
13231323
cleanup:
13241324
strbuf_release(&tmpfile);
@@ -1405,7 +1405,7 @@ static int fetch_and_setup_pack_index(struct packed_git **packs_head,
14051405
ret = verify_pack_index(new_pack);
14061406
if (!ret) {
14071407
close_pack_index(new_pack);
1408-
ret = move_temp_to_file(tmp_idx, sha1_pack_index_name(sha1));
1408+
ret = finalize_object_file(tmp_idx, sha1_pack_index_name(sha1));
14091409
}
14101410
free(tmp_idx);
14111411
if (ret)
@@ -1517,8 +1517,8 @@ int finish_http_pack_request(struct http_pack_request *preq)
15171517

15181518
unlink(sha1_pack_index_name(p->sha1));
15191519

1520-
if (move_temp_to_file(preq->tmpfile, sha1_pack_name(p->sha1))
1521-
|| move_temp_to_file(tmp_idx, sha1_pack_index_name(p->sha1))) {
1520+
if (finalize_object_file(preq->tmpfile, sha1_pack_name(p->sha1))
1521+
|| finalize_object_file(tmp_idx, sha1_pack_index_name(p->sha1))) {
15221522
free(tmp_idx);
15231523
return -1;
15241524
}
@@ -1782,7 +1782,7 @@ int finish_http_object_request(struct http_object_request *freq)
17821782
return -1;
17831783
}
17841784
freq->rename =
1785-
move_temp_to_file(freq->tmpfile, sha1_file_name(freq->sha1));
1785+
finalize_object_file(freq->tmpfile, sha1_file_name(freq->sha1));
17861786

17871787
return freq->rename;
17881788
}

sha1_file.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,11 +2908,8 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
29082908

29092909
/*
29102910
* Move the just written object into its final resting place.
2911-
* NEEDSWORK: this should be renamed to finalize_temp_file() as
2912-
* "moving" is only a part of what it does, when no patch between
2913-
* master to pu changes the call sites of this function.
29142911
*/
2915-
int move_temp_to_file(const char *tmpfile, const char *filename)
2912+
int finalize_object_file(const char *tmpfile, const char *filename)
29162913
{
29172914
int ret = 0;
29182915

@@ -3085,7 +3082,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
30853082
tmp_file, strerror(errno));
30863083
}
30873084

3088-
return move_temp_to_file(tmp_file, filename);
3085+
return finalize_object_file(tmp_file, filename);
30893086
}
30903087

30913088
static int freshen_loose_object(const unsigned char *sha1)

0 commit comments

Comments
 (0)