git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] check_file_directory_conflict path fix

From
DMDavid Meybohm <dmeybohmlkml@bellsouth.net>
Date
May 27, 2005, 02:59 UTC
Message-ID
<20050527025910.GA4836@localhost>

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>
---
Index: read-cache.c
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/read-cache.c  (mode:100644)
+++ uncommitted/read-cache.c  (mode:100644)
@@ -172,11 +172,13 @@
 	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
Message 1 of 1 in “check_file_directory_conflict path fix”
  1. check_file_directory_conflict path fixDavid Meybohm, May 27, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.