remote rm: handle symbolic refs correctly

In the modern world of reference backends, it is not OK to delete a symref by unlink()ing the file directly. This must be done via the refs API. We do so by adding the symref to the list of references to delete along with the non-symbolic references, then calling delete_refs() with the new flags option set to REF_NODEREF. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jun 18, 2016 at 06:15 UTC 29a7cf96441241a291edca8136ab3cc80201e7ee
1 file changed +1 -5
builtin/remote.c
+1 -5
@@ -539,10 +539,6 @@ static int add_branch_for_removal(const char *refname,
539 return 0;
540 }
541
542 - /* make sure that symrefs are deleted */
543 - if (flags & REF_ISSYMREF)
544 - return unlink(git_path("%s", refname));
545 -
542 string_list_append(branches->branches, refname);
543
544 return 0;
@@ -788,7 +784,7 @@ static int rm(int argc, const char **argv)
784 strbuf_release(&buf);
785
786 if (!result)
791 - result = delete_refs(&branches, 0);
787 + result = delete_refs(&branches, REF_NODEREF);
788 string_list_clear(&branches, 0);
789
790 if (skipped.nr) {