From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] unpack-trees.c: simplify check_updates() code path when o->update is false
Date: Sun, 16 Aug 2009 12:05:30 +0700 [thread overview]
Message-ID: <1250399130-31793-1-git-send-email-pclouds@gmail.com> (raw)
check_updates() is heavily branched by o->update, which makes it quite
difficult to follow. This patch rips "o->update == 0" code path out and
put it on top.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
unpack-trees.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 720f7a1..3ee9919 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -75,7 +75,15 @@ static int check_updates(struct unpack_trees_options *o)
int i;
int errs = 0;
- if (o->update && o->verbose_update) {
+ if (!o->update) {
+ remove_marked_cache_entries(&o->result);
+ remove_scheduled_dirs();
+ for (i = 0; i < index->cache_nr; i++)
+ index->cache[i]->ce_flags &= ~CE_UPDATE;
+ return 0;
+ }
+
+ if (o->verbose_update) {
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
struct cache_entry *ce = index->cache[cnt];
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
@@ -87,15 +95,13 @@ static int check_updates(struct unpack_trees_options *o)
cnt = 0;
}
- if (o->update)
- git_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result);
+ git_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result);
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
if (ce->ce_flags & CE_REMOVE) {
display_progress(progress, ++cnt);
- if (o->update)
- unlink_entry(ce);
+ unlink_entry(ce);
}
}
remove_marked_cache_entries(&o->result);
@@ -107,14 +113,11 @@ static int check_updates(struct unpack_trees_options *o)
if (ce->ce_flags & CE_UPDATE) {
display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
- if (o->update) {
- errs |= checkout_entry(ce, &state, NULL);
- }
+ errs |= checkout_entry(ce, &state, NULL);
}
}
stop_progress(&progress);
- if (o->update)
- git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
+ git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
return errs != 0;
}
--
1.6.3.GIT
reply other threads:[~2009-08-16 5:05 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=1250399130-31793-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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