read_raw_ref(): don't get confused by an empty directory

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>

Michael Haggerty committed May 5, 2016 at 14:09 UTC e167a5673e25b960dce118fb967d54da30b69def
2 files changed +11 -2
refs/files-backend.c
+10 -1
@@ -1477,7 +1477,16 @@ stat_ref:
1477
1478 /* Is it a directory? */
1479 if (S_ISDIR(st.st_mode)) {
1480 - errno = EISDIR;
1480 + /*
1481 + * Even though there is a directory where the loose
1482 + * ref is supposed to be, there could still be a
1483 + * packed ref:
1484 + */
1485 + if (resolve_missing_loose_ref(refname, sha1, flags)) {
1486 + errno = EISDIR;
1487 + goto out;
1488 + }
1489 + ret = 0;
1490 goto out;
1491 }
1492
t/t1404-update-ref-df-conflicts.sh
+1 -1
@@ -106,7 +106,7 @@ test_expect_success 'one new ref is a simple prefix of another' '
106
107 '
108
109 -test_expect_failure 'empty directory should not fool rev-parse' '
109 +test_expect_success 'empty directory should not fool rev-parse' '
110 prefix=refs/e-rev-parse &&
111 git update-ref $prefix/foo $C &&
112 git pack-refs --all &&