diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2007-04-11 14:49:44 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-11 19:09:55 -0700 |
commit | 095952585c2a955f45deac69df17a702d7584c80 (patch) | |
tree | b82f2b3aa70b28539a67252961d521999c786aa3 /read-cache.c | |
parent | 1833a925484675b328d5df04ffca62efa7a0a012 (diff) | |
download | git-095952585c2a955f45deac69df17a702d7584c80.tar.gz |
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 <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |