diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-11-07 11:39:03 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-07 15:46:23 -0800 |
commit | aca06247504c31cff7e6fa09242218b5a369e516 (patch) | |
tree | a29323d6ba81ae1a8e82df596b04062c3f18b743 | |
parent | f4eab01bd887338d498bc401158e218947dfb988 (diff) | |
download | git-aca06247504c31cff7e6fa09242218b5a369e516.tar.gz |
refs.c: make add_packed_ref return an error instead of calling die
Change add_packed_ref to return an error instead of calling die().
Update all callers to check the return value of add_packed_ref.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | refs.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1229,15 +1229,16 @@ static struct ref_dir *get_packed_refs(struct ref_cache *refs) return get_packed_ref_dir(get_packed_ref_cache(refs)); } -static void add_packed_ref(const char *refname, const unsigned char *sha1) +static int add_packed_ref(const char *refname, const unsigned char *sha1) { struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(&ref_cache); if (!packed_ref_cache->lock) - die("internal error: packed refs not locked"); + return -1; add_ref(get_packed_ref_dir(packed_ref_cache), create_ref_entry(refname, sha1, REF_ISPACKED, 1)); + return 0; } /* @@ -3827,7 +3828,13 @@ int transaction_commit(struct transaction *transaction, sha1, NULL)) continue; - add_packed_ref(update->refname, sha1); + if (add_packed_ref(update->refname, sha1)) { + if (err) + strbuf_addf(err, "Failed to add %s to packed " + "refs", update->refname); + ret = -1; + goto cleanup; + } need_repack = 1; } if (need_repack) { @@ -3941,7 +3948,13 @@ int transaction_commit(struct transaction *transaction, packed = get_packed_refs(&ref_cache); remove_entry(packed, update->refname); - add_packed_ref(update->refname, update->new_sha1); + if (add_packed_ref(update->refname, update->new_sha1)) { + if (err) + strbuf_addf(err, "Failed to add %s to packed " + "refs", update->refname); + ret = -1; + goto cleanup; + } need_repack = 1; try_remove_empty_parents((char *)update->refname); |