summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorDavid Meybohm <dmeybohmlkml@bellsouth.net>2005-05-27 02:59:10 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-27 17:34:24 (GMT)
commit8310c2c0b585d3ac35a275f795e15fd9887e8b7d (patch)
treef6db9be9d431080d9e7f61edb616b8bac8c9618f /read-cache.c
parent84c1afd7e7c69c6c3c0677d5ee01925d4c70d318 (diff)
downloadgit-8310c2c0b585d3ac35a275f795e15fd9887e8b7d.zip
git-8310c2c0b585d3ac35a275f795e15fd9887e8b7d.tar.gz
git-8310c2c0b585d3ac35a275f795e15fd9887e8b7d.tar.bz2
[PATCH] check_file_directory_conflict path fix
check_file_directory_conflict can give the wrong answers. This is because the wrong length is passed to cache_name_pos. The length passed should be the length of the whole path from the root, not the length of each path subcomponent. $ git-init-db defaulting to local storage area $ mkdir path && touch path/file $ git-update-cache --add path/file $ rm path/file $ mkdir path/file && touch path/file/f $ git-update-cache --add path/file/f <-- Conflict ignored $ Signed-off-by: David Meybohm <dmeybohmlkml@bellsouth.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index 34c040a..bfdaee0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -200,11 +200,13 @@ static int check_file_directory_conflict(const struct cache_entry *ce,
cp = pathbuf;
while (1) {
char *ep = strchr(cp, '/');
+ int len;
if (!ep)
break;
*ep = 0; /* first cut it at slash */
+ len = ep - pathbuf;
pos = cache_name_pos(pathbuf,
- htons(create_ce_flags(ep-cp, stage)));
+ htons(create_ce_flags(len, stage)));
if (0 <= pos) {
/* Our leading path component is registered as a file,
* and we are trying to make it a directory. This is