aboutsummaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index b8b6d11db..e4c628f92 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -365,6 +365,10 @@ int add_file_to_cache(const char *path, int verbose)
die("%s: can only add regular files, symbolic links or git-directories", path);
namelen = strlen(path);
+ if (S_ISDIR(st.st_mode)) {
+ while (namelen && path[namelen-1] == '/')
+ namelen--;
+ }
size = cache_entry_size(namelen);
ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);