From 095952585c2a955f45deac69df17a702d7584c80 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 11 Apr 2007 14:49:44 -0700 Subject: Teach directory traversal about subprojects This is the promised cleaned-up version of teaching directory traversal (ie the "read_directory()" logic) about subprojects. That makes "git add" understand to add/update subprojects. It now knows to look at the index file to see if a directory is marked as a subproject, and use that as information as whether it should be recursed into or not. It also generally cleans up the handling of directory entries when traversing the working tree, by splitting up the decision-making process into small functions of their own, and adding a fair number of comments. Finally, it teaches "add_file_to_cache()" that directory names can have slashes at the end, since the directory traversal adds them to make the difference between a file and a directory clear (it always did that, but my previous too-ugly-to-apply subproject patch had a totally different path for subproject directories and avoided the slash for that case). Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- read-cache.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index b8b6d11dba..e4c628f927 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); -- cgit v1.2.3