X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=refs.c;h=98327d798375d2bc966f877af227a03070ce5d1b;hb=ddaf73141c03aeaab5e8cf5fadaf8b7ebad7955b;hp=aab14fc107353099756403c1bf08a0786e184d98;hpb=b17fda5c07744190e2f9caa24321596830064083;p=git.git diff --git a/refs.c b/refs.c index aab14fc10..98327d798 100644 --- a/refs.c +++ b/refs.c @@ -42,6 +42,12 @@ const char *resolve_ref(const char *path, unsigned char *sha1, int reading) } } + /* 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 @@ -313,8 +319,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *path, } lock->lk = xcalloc(1, sizeof(struct lock_file)); - lock->ref_file = strdup(path); - lock->log_file = strdup(git_path("logs/%s", lock->ref_file + plen)); + lock->ref_file = xstrdup(path); + lock->log_file = xstrdup(git_path("logs/%s", lock->ref_file + plen)); lock->force_write = lstat(lock->ref_file, &st) && errno == ENOENT; if (safe_create_leading_directories(lock->ref_file))