From: Junio C Hamano Date: Sun, 22 Jul 2012 20:04:25 +0000 (-0700) Subject: Merge branch 'jk/push-delete-ref-error-message' into maint X-Git-Tag: v1.7.11.3~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b120079113c62cf52a23e0d84760b5405bcf6b2e?hp=-c Merge branch 'jk/push-delete-ref-error-message' into maint The error message from "git push $there :bogo" (and its equivalent "git push $there --delete bogo") mentioned that we tried and failed to guess what ref is being deleted based on the LHS of the refspec, which we don't. * jk/push-delete-ref-error-message: push: don't guess at qualifying remote refs on deletion --- b120079113c62cf52a23e0d84760b5405bcf6b2e diff --combined remote.c index 6833538829,6b07e580ae..04fd9ea4bd --- a/remote.c +++ b/remote.c @@@ -7,7 -7,6 +7,7 @@@ #include "dir.h" #include "tag.h" #include "string-list.h" +#include "mergesort.h" enum map_direction { FROM_SRC, FROM_DST }; @@@ -919,27 -918,6 +919,27 @@@ void free_refs(struct ref *ref } } +int ref_compare_name(const void *va, const void *vb) +{ + const struct ref *a = va, *b = vb; + return strcmp(a->name, b->name); +} + +static void *ref_list_get_next(const void *a) +{ + return ((const struct ref *)a)->next; +} + +static void ref_list_set_next(void *a, void *next) +{ + ((struct ref *)a)->next = next; +} + +void sort_ref_list(struct ref **l, int (*cmp)(const void *, const void *)) +{ + *l = llist_mergesort(*l, ref_list_get_next, ref_list_set_next, cmp); +} + static int count_refspec_match(const char *pattern, struct ref *refs, struct ref **matched_ref) @@@ -1100,6 -1078,9 +1100,9 @@@ static int match_explicit(struct ref *s case 0: if (!memcmp(dst_value, "refs/", 5)) matched_dst = make_linked_ref(dst_value, dst_tail); + else if (is_null_sha1(matched_src->new_sha1)) + error("unable to delete '%s': remote ref does not exist", + dst_value); else if ((dst_guess = guess_ref(dst_value, matched_src))) matched_dst = make_linked_ref(dst_guess, dst_tail); else