]> asedeno.scripts.mit.edu Git - git.git/blobdiff - dir.c
Merge branch 'pb/prepare-commit-msg'
[git.git] / dir.c
diff --git a/dir.c b/dir.c
index d448902909a7da216fbd49cecc505e68c0ba5e5f..6543105b9622212430a9e5ed131a81074e019d9a 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -169,7 +169,10 @@ static int add_excludes_from_file_1(const char *fname,
        }
        buf = xmalloc(size+1);
        if (read_in_full(fd, buf, size) != size)
+       {
+               free(buf);
                goto err;
+       }
        close(fd);
 
        if (buf_p)
@@ -343,7 +346,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
 
 struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
-       if (cache_name_pos(pathname, len) >= 0)
+       if (cache_name_exists(pathname, len))
                return NULL;
 
        ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -388,7 +391,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
                        break;
                if (endchar == '/')
                        return index_directory;
-               if (!endchar && S_ISGITLINK(ntohl(ce->ce_mode)))
+               if (!endchar && S_ISGITLINK(ce->ce_mode))
                        return index_gitdir;
        }
        return index_nonexistent;
@@ -692,7 +695,7 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
 int file_exists(const char *f)
 {
        struct stat sb;
-       return stat(f, &sb) == 0;
+       return lstat(f, &sb) == 0;
 }
 
 /*