{"thread":{"id":"97","subject":"[PATCH] Fix confusing behaviour of update-cache --refresh on unmerged paths.","startedAt":"2005-04-18T06:09:34Z","lastAt":"2005-04-18T06:09:34Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"630","messageId":"7v3btovco1.fsf@assigned-by-dhcp.cox.net","threadId":"97","inReplyTo":null,"subject":"[PATCH] Fix confusing behaviour of update-cache --refresh on unmerged paths.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-18T06:09:34Z","receivedAt":"2005-04-18T06:09:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"update-cache --refresh\" command attempts refresh_entry() \non unmerged path, which results in as many \"needs update\" messages\nas there are unmerged stages for that path.  This does not do\nany harm to the working directory, but it is confusing.\n\n    $ ls -al\n    total 16\n    drwxrwsr-x   3 junio src 4096 Apr 17 23:00 ./\n    drwxrwsr-x  10 junio src 4096 Apr 17 22:58 ../\n    drwxr-sr-x   3 junio src 4096 Apr 17 22:59 .git/\n    -rw-rw-r--   1 junio src  363 Apr 17 23:00 TT\n    $ show-files --stage\n    100644 e14bafaadce6c34768ba2ff8b3c6419e8839e7d2 1 TT\n    100644 99ef1b30fc6d6ea186d6eac62619e1afd65ad64e 2 TT\n    100644 033b9385f7a29882a6b4b34f67b20e2304d3489d 3 TT\n    $ ../++linus/update-cache --refresh\n    TT: needs update\n    TT: needs update\n    TT: needs update\n    $ ../update-cache --refresh\n    TT: needs merge\n\nHere is a fix.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n update-cache.c |   13 +++++++++++--\n 1 files changed, 11 insertions(+), 2 deletions(-)\n\nupdate-cache.c: 5742c6ca084a7761ad728651d85509736e2ebc7c\n--- update-cache.c\n+++ update-cache.c\t2005-04-17 22:58:06.000000000 -0700\n@@ -196,9 +196,18 @@ static void refresh_cache(void)\n \tint i;\n \n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n-\t\tstruct cache_entry *new = refresh_entry(ce);\n+\t\tstruct cache_entry *ce, *new;\n+\t\tce = active_cache[i];\n+\t\tif (ce_stage(ce)) {\n+\t\t\tprintf(\"%s: needs merge\\n\", ce->name);\n+\t\t\twhile ((i < active_nr) &&\n+\t\t\t       ! strcmp(active_cache[i]->name, ce->name))\n+\t\t\t\ti++;\n+\t\t\ti--;\n+\t\t\tcontinue;\n+\t\t}\n \n+\t\tnew = refresh_entry(ce);\n \t\tif (!new) {\n \t\t\tprintf(\"%s: needs update\\n\", ce->name);\n \t\t\tcontinue;\n\n"}]}