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-02-17 20:00:18 +0300
committerJunio C Hamano <gitster@pobox.com>2015-02-17 22:24:20 +0300
commita933c23e66265eedf822535ac56fcdb4ecb07a8c (patch)
tree2248903b0d95e1bdf362828ebf5dd40507c3532b /builtin/commit.c
parenta908a31c344cdcce2bf1a9fc163f3bccd2349e6a (diff)
commit: avoid race when creating orphan commits
If HEAD doesn't point at anything during the initial check, then we should make sure that it *still* doesn't point at anything when we are ready to update the reference. Otherwise, another process might commit while we are working (e.g., while we are waiting for the user to edit the commit message) and we will silently overwrite it. This fixes a failing test in t7516. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 8afb0ff5e0..682f922c73 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1766,7 +1766,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (!transaction ||
ref_transaction_update(transaction, "HEAD", sha1,
current_head
- ? current_head->object.sha1 : NULL,
+ ? current_head->object.sha1 : null_sha1,
0, sb.buf, &err) ||
ref_transaction_commit(transaction, &err)) {
rollback_index_files();