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

[PATCH] Fix confusing behaviour of update-cache --refresh on unmerged paths.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 18, 2005, 06:09 UTC
Message-ID
<7v3btovco1.fsf@assigned-by-dhcp.cox.net>

The "update-cache --refresh" command attempts refresh_entry() on unmerged path, which results in as many "needs update" messages as there are unmerged stages for that path. This does not do any harm to the working directory, but it is confusing.

    $ ls -al
    total 16
    drwxrwsr-x   3 junio src 4096 Apr 17 23:00 ./
    drwxrwsr-x  10 junio src 4096 Apr 17 22:58 ../
    drwxr-sr-x   3 junio src 4096 Apr 17 22:59 .git/
    -rw-rw-r--   1 junio src  363 Apr 17 23:00 TT
    $ show-files --stage
    100644 e14bafaadce6c34768ba2ff8b3c6419e8839e7d2 1 TT
    100644 99ef1b30fc6d6ea186d6eac62619e1afd65ad64e 2 TT
    100644 033b9385f7a29882a6b4b34f67b20e2304d3489d 3 TT
    $ ../++linus/update-cache --refresh
    TT: needs update
    TT: needs update
    TT: needs update
    $ ../update-cache --refresh
    TT: needs merge
Here is a fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 update-cache.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

update-cache.c: 5742c6ca084a7761ad728651d85509736e2ebc7c --- update-cache.c +++ update-cache.c 2005-04-17 22:58:06.000000000 -0700

@@ -196,9 +196,18 @@ static void refresh_cache(void)
 	int i;
 
 	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
-		struct cache_entry *new = refresh_entry(ce);
+		struct cache_entry *ce, *new;
+		ce = active_cache[i];
+		if (ce_stage(ce)) {
+			printf("%s: needs merge\n", ce->name);
+			while ((i < active_nr) &&
+			       ! strcmp(active_cache[i]->name, ce->name))
+				i++;
+			i--;
+			continue;
+		}
 
+		new = refresh_entry(ce);
 		if (!new) {
 			printf("%s: needs update\n", ce->name);
 			continue;
Message 1 of 1 in “Fix confusing behaviour of update-cache --refresh on unmerged paths.”
  1. Fix confusing behaviour of update-cache --refresh on unmerged paths.Junio C Hamano, Apr 18, 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.