remote rm/prune: print a message when writing packed-refs fails
Until v2.1.0-rc0~22^2~11 (refs.c: add an err argument to repack_without_refs, 2014-06-20), repack_without_refs forgot to provide an error message when commit_packed_refs fails. Even today, it only provides a message for callers that pass a non-NULL err parameter. Internal callers in refs.c pass non-NULL err but "git remote" does not. That means that "git remote rm" and "git remote prune" can fail without printing a message about why. Fix them by passing in a non-NULL err parameter and printing the returned message. This is the last caller to a ref handling function passing err == NULL. A later patch can drop support for err == NULL, avoiding such problems in the future. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
971c41c717
commit
2ebb49ca8a
@ -749,13 +749,16 @@ static int mv(int argc, const char **argv)
|
|||||||
|
|
||||||
static int remove_branches(struct string_list *branches)
|
static int remove_branches(struct string_list *branches)
|
||||||
{
|
{
|
||||||
|
struct strbuf err = STRBUF_INIT;
|
||||||
const char **branch_names;
|
const char **branch_names;
|
||||||
int i, result = 0;
|
int i, result = 0;
|
||||||
|
|
||||||
branch_names = xmalloc(branches->nr * sizeof(*branch_names));
|
branch_names = xmalloc(branches->nr * sizeof(*branch_names));
|
||||||
for (i = 0; i < branches->nr; i++)
|
for (i = 0; i < branches->nr; i++)
|
||||||
branch_names[i] = branches->items[i].string;
|
branch_names[i] = branches->items[i].string;
|
||||||
result |= repack_without_refs(branch_names, branches->nr, NULL);
|
if (repack_without_refs(branch_names, branches->nr, &err))
|
||||||
|
result |= error("%s", err.buf);
|
||||||
|
strbuf_release(&err);
|
||||||
free(branch_names);
|
free(branch_names);
|
||||||
|
|
||||||
for (i = 0; i < branches->nr; i++) {
|
for (i = 0; i < branches->nr; i++) {
|
||||||
@ -1332,9 +1335,13 @@ static int prune_remote(const char *remote, int dry_run)
|
|||||||
delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs));
|
delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs));
|
||||||
for (i = 0; i < states.stale.nr; i++)
|
for (i = 0; i < states.stale.nr; i++)
|
||||||
delete_refs[i] = states.stale.items[i].util;
|
delete_refs[i] = states.stale.items[i].util;
|
||||||
if (!dry_run)
|
if (!dry_run) {
|
||||||
result |= repack_without_refs(delete_refs,
|
struct strbuf err = STRBUF_INIT;
|
||||||
states.stale.nr, NULL);
|
if (repack_without_refs(delete_refs, states.stale.nr,
|
||||||
|
&err))
|
||||||
|
result |= error("%s", err.buf);
|
||||||
|
strbuf_release(&err);
|
||||||
|
}
|
||||||
free(delete_refs);
|
free(delete_refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user