summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-04-28 22:23:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-09-03 17:04:14 (GMT)
commit3f09ba754367fcc0ddad94e22385d80b5f317584 (patch)
tree76e06fbd23c56aac4a4b4b30a95c068fe08fa3bd /fast-import.c
parent6629ea2d4a5faa0a84367f6d4aedba53cb0f26b4 (diff)
downloadgit-3f09ba754367fcc0ddad94e22385d80b5f317584.zip
git-3f09ba754367fcc0ddad94e22385d80b5f317584.tar.gz
git-3f09ba754367fcc0ddad94e22385d80b5f317584.tar.bz2
fast-import.c: use a ref transaction when dumping tags
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/fast-import.c b/fast-import.c
index 79160d5..e7f6e37 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1735,15 +1735,32 @@ static void dump_tags(void)
{
static const char *msg = "fast-import";
struct tag *t;
- struct ref_lock *lock;
- char ref_name[PATH_MAX];
+ struct strbuf ref_name = STRBUF_INIT;
+ struct strbuf err = STRBUF_INIT;
+ struct ref_transaction *transaction;
+ transaction = ref_transaction_begin(&err);
+ if (!transaction) {
+ failure |= error("%s", err.buf);
+ goto cleanup;
+ }
for (t = first_tag; t; t = t->next_tag) {
- sprintf(ref_name, "tags/%s", t->name);
- lock = lock_ref_sha1(ref_name, NULL);
- if (!lock || write_ref_sha1(lock, t->sha1, msg) < 0)
- failure |= error("Unable to update %s", ref_name);
+ strbuf_reset(&ref_name);
+ strbuf_addf(&ref_name, "refs/tags/%s", t->name);
+
+ if (ref_transaction_update(transaction, ref_name.buf, t->sha1,
+ NULL, 0, 0, &err)) {
+ failure |= error("%s", err.buf);
+ goto cleanup;
+ }
}
+ if (ref_transaction_commit(transaction, msg, &err))
+ failure |= error("%s", err.buf);
+
+ cleanup:
+ ref_transaction_free(transaction);
+ strbuf_release(&ref_name);
+ strbuf_release(&err);
}
static void dump_marks_helper(FILE *f,