git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sdaoden@googlemail.com
To: git@vger.kernel.org
Cc: Steffen Daode Nurpmeso <sdaoden@gmail.com>
Subject: [PATCH 2/2] unpack-trees: divert check_updates() output via update_progress()
Date: Mon, 29 Aug 2011 22:17:40 +0200	[thread overview]
Message-ID: <a768a89aa9e98435030631d6a19d6524c352acde.1314647163.git.sdaoden@gmail.com> (raw)
In-Reply-To: <bc530ff857b92ad58bfd6f331cf6732ed86c42b0.1314647163.git.sdaoden@gmail.com>
In-Reply-To: <cover.1314647163.git.sdaoden@gmail.com>

From: Steffen Daode Nurpmeso <sdaoden@gmail.com>

The progress shown by check_updates() yet always printed
"Checking out files", even if basically files were only
unlinked.

This commit diverts that into "Updating working tree:" plus the
actual action which currently is performed (i.e. "removing
files" or "checking out files").

Inspired-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Steffen Daode Nurpmeso <sdaoden@gmail.com>
---
 unpack-trees.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index cc616c3..95cd8a6 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -178,26 +178,34 @@ static void unlink_entry(struct cache_entry *ce)
 static struct checkout state;
 static int check_updates(struct unpack_trees_options *o)
 {
-	unsigned cnt = 0, total = 0;
+	unsigned rm_cnt, co_cnt, cnt;
 	struct progress *progress = NULL;
 	struct index_state *index = &o->result;
 	int i;
 	int errs = 0;
 
 	if (o->update && o->verbose_update) {
-		for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
+		rm_cnt = co_cnt = 0;
+		for (cnt = 0; cnt < index->cache_nr; cnt++) {
 			struct cache_entry *ce = index->cache[cnt];
-			if (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE))
-				total++;
+			switch (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE)) {
+			case CE_UPDATE:
+				co_cnt++;
+				break;
+			default:
+				rm_cnt++;
+				break;
+			}
 		}
 
-		progress = start_progress_delay("Checking out files",
-						total, 50, 1);
+		progress = start_progress_delay("Updating work tree: "
+						"removing files",
+						rm_cnt, 64, 1);
 		cnt = 0;
 	}
-
 	if (o->update)
 		git_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result);
+
 	for (i = 0; i < index->cache_nr; i++) {
 		struct cache_entry *ce = index->cache[i];
 
@@ -211,6 +219,13 @@ static int check_updates(struct unpack_trees_options *o)
 	remove_marked_cache_entries(&o->result);
 	remove_scheduled_dirs();
 
+	if (co_cnt > 0) {
+		update_progress(progress,
+				"Updating work tree: checking out files",
+				co_cnt);
+		cnt = 0;
+	}
+
 	for (i = 0; i < index->cache_nr; i++) {
 		struct cache_entry *ce = index->cache[i];
 
@@ -222,6 +237,7 @@ static int check_updates(struct unpack_trees_options *o)
 			}
 		}
 	}
+
 	stop_progress(&progress);
 	if (o->update)
 		git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
-- 
1.7.7.rc0.dirty

      reply	other threads:[~2011-08-29 20:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28 14:40 [PATCH] progress: use \r as EOL only if isatty(stderr) is true Steffen Daode Nurpmeso
     [not found] ` <BANLkTinRe=pA=_obCmPKBjJMXH_pDfwCtw@mail.gmail.com>
2011-06-28 16:51   ` Steffen Daode Nurpmeso
2011-06-28 18:04   ` Steffen Daode Nurpmeso
2011-06-28 18:33 ` Junio C Hamano
2011-06-28 18:48   ` Steffen Daode Nurpmeso
2011-06-28 18:55   ` Steffen Daode Nurpmeso
2011-06-28 22:45   ` Jeff King
2011-06-29 21:36     ` Junio C Hamano
2011-06-30  4:33       ` Miles Bader
2011-06-29 17:42   ` [PATCH/RFC] sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true) Steffen Daode Nurpmeso
2011-06-29 18:15     ` Nicolas Pitre
2011-06-30 21:13       ` Steffen Daode Nurpmeso
2011-07-01  3:46         ` Nicolas Pitre
2011-08-27 19:45   ` [PATCH] checkout: be quiet if not on isatty() Steffen Daode Nurpmeso
2011-08-27 19:45     ` Steffen Daode Nurpmeso
2011-08-28  6:22       ` Junio C Hamano
2011-08-28  6:28         ` martin f krafft
2011-08-28 17:37         ` [PATCH] checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty()) Steffen Daode Nurpmeso
2011-08-29 20:14         ` [PATCH 0/2 RFC] Add update_progress(), divert checkout messages sdaoden
2011-08-29 20:17           ` [PATCH 1/2] progress: add update_progress() sdaoden
2011-08-29 20:17             ` sdaoden [this message]

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=a768a89aa9e98435030631d6a19d6524c352acde.1314647163.git.sdaoden@gmail.com \
    --to=sdaoden@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=sdaoden@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).