[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>
This commit is contained in:
David Meybohm 2005-05-26 22:59:10 -04:00 коммит произвёл Linus Torvalds
Родитель 84c1afd7e7
Коммит 8310c2c0b5
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -200,11 +200,13 @@ static int check_file_directory_conflict(const struct cache_entry *ce,
cp = pathbuf; cp = pathbuf;
while (1) { while (1) {
char *ep = strchr(cp, '/'); char *ep = strchr(cp, '/');
int len;
if (!ep) if (!ep)
break; break;
*ep = 0; /* first cut it at slash */ *ep = 0; /* first cut it at slash */
len = ep - pathbuf;
pos = cache_name_pos(pathbuf, pos = cache_name_pos(pathbuf,
htons(create_ce_flags(ep-cp, stage))); htons(create_ce_flags(len, stage)));
if (0 <= pos) { if (0 <= pos) {
/* Our leading path component is registered as a file, /* Our leading path component is registered as a file,
* and we are trying to make it a directory. This is * and we are trying to make it a directory. This is