Skip to content

Commit 2ebb49c

Browse files
rsahlberggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Reviewed-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 971c41c commit 2ebb49c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

builtin/remote.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,16 @@ static int mv(int argc, const char **argv)
749749

750750
static int remove_branches(struct string_list *branches)
751751
{
752+
struct strbuf err = STRBUF_INIT;
752753
const char **branch_names;
753754
int i, result = 0;
754755

755756
branch_names = xmalloc(branches->nr * sizeof(*branch_names));
756757
for (i = 0; i < branches->nr; i++)
757758
branch_names[i] = branches->items[i].string;
758-
result |= repack_without_refs(branch_names, branches->nr, NULL);
759+
if (repack_without_refs(branch_names, branches->nr, &err))
760+
result |= error("%s", err.buf);
761+
strbuf_release(&err);
759762
free(branch_names);
760763

761764
for (i = 0; i < branches->nr; i++) {
@@ -1332,9 +1335,13 @@ static int prune_remote(const char *remote, int dry_run)
13321335
delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs));
13331336
for (i = 0; i < states.stale.nr; i++)
13341337
delete_refs[i] = states.stale.items[i].util;
1335-
if (!dry_run)
1336-
result |= repack_without_refs(delete_refs,
1337-
states.stale.nr, NULL);
1338+
if (!dry_run) {
1339+
struct strbuf err = STRBUF_INIT;
1340+
if (repack_without_refs(delete_refs, states.stale.nr,
1341+
&err))
1342+
result |= error("%s", err.buf);
1343+
strbuf_release(&err);
1344+
}
13381345
free(delete_refs);
13391346
}
13401347

0 commit comments

Comments
 (0)