Re: [PATCH v8 14/44] replace.c: use the ref transaction functions for updates
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- May 15, 2014, 21:18 UTC
- Message-ID
- <20140515211835.GL26471@google.com>
- In-Reply-To
- <1400174999-26786-15-git-send-email-sahlberg@google.com>
Ronnie Sahlberg wrote:
> --- a/builtin/replace.c > +++ b/builtin/replace.c
[...]
Show 15 quoted lines
> @@ -156,11 +157,12 @@ static int replace_object_sha1(const char *object_ref,
> else if (!force)
> die("replace ref '%s' already exists", ref);
>
> - lock = lock_any_ref_for_update(ref, prev, 0, NULL);
> - if (!lock)
> - die("%s: cannot lock the ref", ref);
> - if (write_ref_sha1(lock, repl, NULL) < 0)
> - die("%s: cannot update the ref", ref);
> + transaction = ref_transaction_begin();
> + if (!transaction ||
> + ref_transaction_update(transaction, ref, repl, prev,
> + 0, !is_null_sha1(prev)) ||
> + ref_transaction_commit(transaction, NULL, &err))
> + die("%s: failed to replace ref: %s", ref, err.buf);This would write
fatal: refs/replace/09c779943364d893c190066c385e6112af421db3: failed to replace ref: Cannot lock the ref 'refs/replace/09c779943364d893c190066c385e6112af421db3'.
Perhaps something like
$ git replace foo bar fatal: replace foo: Cannot lock the ref 'refs/replace/09c779943364d893c190066c385e6112af421db3'.
would make sense (die("replace %s: %s", object_ref, err.buf)). Plain$ git replace foo bar fatal: Cannot lock the ref 'refs/replace/09c779943364d893c190066c385e6112af421db3'.
also seems fine (die("%s", err.buf)).Thanks, Jonathan