summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-05-15 10:29:19 -0700
committerJunio C Hamano <gitster@pobox.com>2014-05-15 14:01:36 -0700
commit8ab96a0b3f53c4fa7253708aa4b267e1b02dc96a (patch)
tree892dca6c2a54c33a75da7becba049f4bd90cfe58
parent6d774c6bf0adccc69673b29951ad8724955a3509 (diff)
downloadgit-8ab96a0b3f53c4fa7253708aa4b267e1b02dc96a.tar.gz
refs.c: add an err argument to repack_without_refs
Update repack_without_refs to take an err argument and update it if there is a failure. Pass the err variable from ref_transaction_commit to this function so that callers can print a meaningful error message if _commit fails due to a problem in repack_without_refs. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/refs.c b/refs.c
index 1a7f9d9763..c2b720e96d 100644
--- a/refs.c
+++ b/refs.c
@@ -2427,12 +2427,12 @@ static int curate_packed_ref_fn(struct ref_entry *entry, void *cb_data)
return 0;
}
-static int repack_without_refs(const char **refnames, int n)
+static int repack_without_refs(const char **refnames, int n, struct strbuf *err)
{
struct ref_dir *packed;
struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
struct string_list_item *ref_to_delete;
- int i, removed = 0;
+ int i, ret, removed = 0;
/* Look for a packed ref */
for (i = 0; i < n; i++)
@@ -2445,6 +2445,9 @@ static int repack_without_refs(const char **refnames, int n)
if (lock_packed_refs(0)) {
unable_to_lock_error(git_path("packed-refs"), errno);
+ if (err)
+ strbuf_addf(err, "cannot delete '%s' from packed refs",
+ refnames[i]);
return error("cannot delete '%s' from packed refs", refnames[i]);
}
packed = get_packed_refs(&ref_cache);
@@ -2470,12 +2473,15 @@ static int repack_without_refs(const char **refnames, int n)
}
/* Write what remains */
- return commit_packed_refs();
+ ret = commit_packed_refs();
+ if (ret && err)
+ strbuf_addf(err, "unable to overwrite old ref-pack file");
+ return ret;
}
static int repack_without_ref(const char *refname)
{
- return repack_without_refs(&refname, 1);
+ return repack_without_refs(&refname, 1, NULL);
}
static int delete_ref_loose(struct ref_lock *lock, int flag)
@@ -3486,7 +3492,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
}
}
- ret |= repack_without_refs(delnames, delnum);
+ ret |= repack_without_refs(delnames, delnum, err);
for (i = 0; i < delnum; i++)
unlink_or_warn(git_path("logs/%s", delnames[i]));
clear_loose_ref_cache(&ref_cache);