Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-06-22 17:03:08 +0300
committerJunio C Hamano <gitster@pobox.com>2015-06-22 23:17:13 +0300
commita1c9eb918b9af809d75ee3206e684f3a8f29ee63 (patch)
tree471a0acc3474c24730cf7478b5ef3a36171b3a91 /fast-import.c
parent4eaa4bd800152f20a51e25176a0803d1b7757c7b (diff)
update_ref(): don't read old reference value before delete
If we are deleting the reference, then we don't need to read the reference's old value. It doesn't provide any race safety, because the value read just before the delete is no "better" than the value that would be read under lock during the delete. And even if the reference previously didn't exist, we can call delete_ref() on it if we don't provide an old_sha1 value. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fast-import.c b/fast-import.c
index 6378726993..d7ed065381 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1692,13 +1692,13 @@ static int update_branch(struct branch *b)
unsigned char old_sha1[20];
struct strbuf err = STRBUF_INIT;
- if (read_ref(b->name, old_sha1))
- hashclr(old_sha1);
if (is_null_sha1(b->sha1)) {
if (b->delete)
- delete_ref(b->name, old_sha1, 0);
+ delete_ref(b->name, NULL, 0);
return 0;
}
+ if (read_ref(b->name, old_sha1))
+ hashclr(old_sha1);
if (!force_update && !is_null_sha1(old_sha1)) {
struct commit *old_cmit, *new_cmit;