summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-08-03 18:01:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-03 18:01:17 (GMT)
commitbe9cb560e31c76c00760dadb151b5e3059970586 (patch)
tree434003cf022bccf7f1a1dfecfb77305214defe32 /builtin/clone.c
parent5f02274e4c4506b923b510a24da7991656f4db14 (diff)
parent1c03c4d34771db20b78231359caa6fda28e2d9fe (diff)
downloadgit-be9cb560e31c76c00760dadb151b5e3059970586.zip
git-be9cb560e31c76c00760dadb151b5e3059970586.tar.gz
git-be9cb560e31c76c00760dadb151b5e3059970586.tar.bz2
Merge branch 'mh/init-delete-refs-api'
Clean up refs API and make "git clone" less intimate with the implementation detail. * mh/init-delete-refs-api: delete_ref(): use the usual convention for old_sha1 cmd_update_ref(): make logic more straightforward update_ref(): don't read old reference value before delete check_branch_commit(): make first parameter const refs.h: add some parameter names to function declarations refs: move the remaining ref module declarations to refs.h initial_ref_transaction_commit(): check for ref D/F conflicts initial_ref_transaction_commit(): check for duplicate refs refs: remove some functions from the module's public interface initial_ref_transaction_commit(): function for initial ref creation repack_without_refs(): make function private prune_refs(): use delete_refs() prune_remote(): use delete_refs() delete_refs(): bail early if the packed-refs file cannot be rewritten delete_refs(): make error message more generic delete_refs(): new function for the refs API delete_ref(): handle special case more explicitly remove_branches(): remove temporary delete_ref(): move declaration to refs.h
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index a72ff7e..303a3a7 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -484,16 +484,26 @@ static void write_remote_refs(const struct ref *local_refs)
{
const struct ref *r;
- lock_packed_refs(LOCK_DIE_ON_ERROR);
+ struct ref_transaction *t;
+ struct strbuf err = STRBUF_INIT;
+
+ t = ref_transaction_begin(&err);
+ if (!t)
+ die("%s", err.buf);
for (r = local_refs; r; r = r->next) {
if (!r->peer_ref)
continue;
- add_packed_ref(r->peer_ref->name, r->old_sha1);
+ if (ref_transaction_create(t, r->peer_ref->name, r->old_sha1,
+ 0, NULL, &err))
+ die("%s", err.buf);
}
- if (commit_packed_refs())
- die_errno("unable to overwrite old ref-pack file");
+ if (initial_ref_transaction_commit(t, &err))
+ die("%s", err.buf);
+
+ strbuf_release(&err);
+ ref_transaction_free(t);
}
static void write_followtags(const struct ref *refs, const char *msg)