Thread (134 messages) 134 messages, 4 authors, 2016-06-15

Re: [PATCH v8 13/44] tag.c: use ref transactions when doing updates

flat view

From: Jonathan Nieder <hidden>
Date: 2016-06-15 23:01:11

Ronnie Sahlberg wrote:
quoted hunk ↗ jump to hunk
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -701,11 +702,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 	if (annotate)
 		create_tag(object, tag, &buf, &opt, prev, object);
 
-	lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
-	if (!lock)
-		die(_("%s: cannot lock the ref"), ref.buf);
-	if (write_ref_sha1(lock, object, NULL) < 0)
-		die(_("%s: cannot update the ref"), ref.buf);
+	transaction = ref_transaction_begin();
+	if (!transaction ||
+	    ref_transaction_update(transaction, ref.buf, object, prev,
+				   0, !is_null_sha1(prev)) ||
+	    ref_transaction_commit(transaction, NULL, &err))
+		die(_("%s: cannot update the ref: %s"), ref.buf, err.buf);
The error string says what ref it was trying to update, so

		die("%s", err.buf);

should be enough.  (E.g.,

	fatal: refs/tags/v1.0: cannot lock the ref

would become

	fatal: Cannot lock the ref 'refs/tags/v1.0'.

instead of

	fatal: refs/tags/v1.0: cannot update the ref: Cannot lock the ref 'refs/tags/v1.0'.

.)

Thanks,
Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help