diff --git a/refs.c b/refs.c index aa4c4e0b94..305c1a92cc 100644 --- a/refs.c +++ b/refs.c @@ -234,6 +234,12 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int * } } + /* Is it a directory? */ + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return NULL; + } + /* * Anything else, just open it and try to use it as * a ref