Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: torvalds@osdl.org
Cc: git@vger.kernel.org
Subject: [PATCH] Fix confusing behaviour of update-cache --refresh on unmerged paths.
Date: Sun, 17 Apr 2005 23:09:34 -0700	[thread overview]
Message-ID: <7v3btovco1.fsf@assigned-by-dhcp.cox.net> (raw)

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;


                 reply	other threads:[~2005-04-18  6:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v3btovco1.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox