read_raw_ref(): don't get confused by an empty directory
authorMichael Haggerty <mhagger@alum.mit.edu>
Thu, 5 May 2016 12:09:41 +0000 (14:09 +0200)
committerMichael Haggerty <mhagger@alum.mit.edu>
Thu, 5 May 2016 14:37:04 +0000 (16:37 +0200)
Even if there is an empty directory where we look for the loose version
of a reference, check for a packed reference before giving up. This
fixes the failing test that was introduced two commits ago.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
refs/files-backend.c
t/t1404-update-ref-df-conflicts.sh
index ad9cd86457c4795d52f578687306afec65548d54..0cc116d67c3ad064da1511a0848b8a46baff865e 100644 (file)
@@ -1477,7 +1477,16 @@ int read_raw_ref(const char *refname, unsigned char *sha1,
 
        /* Is it a directory? */
        if (S_ISDIR(st.st_mode)) {
-               errno = EISDIR;
+               /*
+                * Even though there is a directory where the loose
+                * ref is supposed to be, there could still be a
+                * packed ref:
+                */
+               if (resolve_missing_loose_ref(refname, sha1, flags)) {
+                       errno = EISDIR;
+                       goto out;
+               }
+               ret = 0;
                goto out;
        }
 
index 16752a999f89a29ea8110eac66574d210b4b490f..6d869d1285fbb3f687750978db468291c636fd61 100755 (executable)
@@ -106,7 +106,7 @@ test_expect_success 'one new ref is a simple prefix of another' '
 
 '
 
-test_expect_failure 'empty directory should not fool rev-parse' '
+test_expect_success 'empty directory should not fool rev-parse' '
        prefix=refs/e-rev-parse &&
        git update-ref $prefix/foo $C &&
        git pack-refs --all &&