Re: [PATCH 07/11] commit: avoid race when creating orphan commits

2015-02-11 Thread Michael Haggerty
On 02/09/2015 07:35 PM, Stefan Beller wrote:
 On Sun, Feb 8, 2015 at 8:14 AM, Michael Haggerty mhag...@alum.mit.edu wrote:
 If, during the initial check, HEAD doesn't point at anything, then we
 
 Maybe
 If HEAD doesn't point at anything during the initial check, then... ?
 (Being a non native speaker is hard. These commas look so confusing,
 so the version without commas makes it way easier to read for me.)

Will change. Thanks!

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/11] commit: avoid race when creating orphan commits

2015-02-09 Thread Stefan Beller
On Sun, Feb 8, 2015 at 8:14 AM, Michael Haggerty mhag...@alum.mit.edu wrote:
 If, during the initial check, HEAD doesn't point at anything, then we

Maybe
If HEAD doesn't point at anything during the initial check, then... ?
(Being a non native speaker is hard. These commas look so confusing,
so the version without commas makes it way easier to read for me.)

Otherwise
Reviewed-by: Stefan Beller sbel...@google.com
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] commit: avoid race when creating orphan commits

2015-02-08 Thread Michael Haggerty
If, during the initial check, HEAD doesn't point at anything, 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 mhag...@alum.mit.edu
---
 builtin/commit.c| 2 +-
 t/t7516-commit-races.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 5654abd..c566e32 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1772,7 +1772,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();
diff --git a/t/t7516-commit-races.sh b/t/t7516-commit-races.sh
index 5efa351..17a139e 100755
--- a/t/t7516-commit-races.sh
+++ b/t/t7516-commit-races.sh
@@ -17,7 +17,7 @@ test_expect_success 'set up editor' '
chmod +x editor
 '
 
-test_expect_failure 'race to create orphan commit' '
+test_expect_success 'race to create orphan commit' '
test_must_fail env EDITOR=./editor git commit --allow-empty 
git show -s --pretty=format:%s subject 
grep -q hare subject 
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html