Merge branch 'jh/update-ref-d-through-symref' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 Nov 2012 21:28:45 +0000 (13:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Nov 2012 21:28:45 +0000 (13:28 -0800)
* jh/update-ref-d-through-symref:
Fix failure to delete a packed ref through a symref
t1400-update-ref: Add test verifying bug with symrefs in delete_ref()

1  2 
refs.c
diff --combined refs.c
index 9d1685bcba4ca0381dd9d0990a97046b56324aed,b4c57af998122f11a45823a92ffbe001975abaea..520e50f3bc9c52beb45d2df19a7ae928c174c9ed
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -1753,24 -1753,32 +1753,24 @@@ int delete_ref(const char *refname, con
        struct ref_lock *lock;
        int err, i = 0, ret = 0, flag = 0;
  
 -      lock = lock_ref_sha1_basic(refname, sha1, 0, &flag);
 +      lock = lock_ref_sha1_basic(refname, sha1, delopt, &flag);
        if (!lock)
                return 1;
        if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
                /* loose */
 -              const char *path;
 -
 -              if (!(delopt & REF_NODEREF)) {
 -                      i = strlen(lock->lk->filename) - 5; /* .lock */
 -                      lock->lk->filename[i] = 0;
 -                      path = lock->lk->filename;
 -              } else {
 -                      path = git_path("%s", refname);
 -              }
 -              err = unlink_or_warn(path);
 +              i = strlen(lock->lk->filename) - 5; /* .lock */
 +              lock->lk->filename[i] = 0;
 +              err = unlink_or_warn(lock->lk->filename);
                if (err && errno != ENOENT)
                        ret = 1;
  
 -              if (!(delopt & REF_NODEREF))
 -                      lock->lk->filename[i] = '.';
 +              lock->lk->filename[i] = '.';
        }
        /* removing the loose one could have resurrected an earlier
         * packed one.  Also, if it was not loose we need to repack
         * without it.
         */
-       ret |= repack_without_ref(refname);
+       ret |= repack_without_ref(lock->ref_name);
  
        unlink_or_warn(git_path("logs/%s", lock->ref_name));
        invalidate_ref_cache(NULL);