From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 3/8] unpack_trees(): keep track of unmerged entries
Date: Sun, 30 Nov 2008 17:54:33 +0700 [thread overview]
Message-ID: <1228042478-1886-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1228042478-1886-3-git-send-email-pclouds@gmail.com>
"git read-tree --reset" will currently remove all unmerged entries in
index before feeding the index to unpack_trees(). Because the lack of
unmerged entries, these entries, when read from tree, will be seen as
"new entries" by {one,two,three}way_merge().
This is fine for now. But for sparse checkout, it needs to know
whether an entry is new entry, because it will handle it different way
than already-in entry.
So the patch moves "unmerged entries removal" part into
unpack_trees(), actually unpack_callback(). The function then can turn
on o->has_unmerged flag, which can be utilized by sparse checkout.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-read-tree.c | 3 ++-
unpack-trees.c | 7 +++++++
unpack-trees.h | 2 ++
3 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 38fef34..528134c 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -136,9 +136,10 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
if (stage || opts.merge || opts.prefix)
usage(read_tree_usage);
opts.reset = 1;
+ opts.prune_unmerged = 1;
opts.merge = 1;
stage = 1;
- read_cache_unmerged();
+ read_cache();
continue;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index 83888ae..7d99051 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -301,6 +301,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
/* Are we supposed to look at the index too? */
if (o->merge) {
+ o->has_unmerged = 0;
while (o->pos < o->src_index->cache_nr) {
struct cache_entry *ce = o->src_index->cache[o->pos];
int cmp = compare_entry(ce, info, p);
@@ -320,6 +321,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
add_entry(o, ce, 0, 0);
return mask;
}
+
+ if (o->prune_unmerged) {
+ o->has_unmerged = 1;
+ /* leave src[0] as NULL and go over all other staged entries */
+ continue;
+ }
}
src[0] = ce;
}
diff --git a/unpack-trees.h b/unpack-trees.h
index 93ec3c6..86f0989 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -43,6 +43,8 @@ struct unpack_trees_options {
verbose_update:1,
aggressive:1,
skip_unmerged:1,
+ prune_unmerged:1,
+ has_unmerged:1,
initial_checkout:1,
gently:1;
const char *prefix;
--
1.6.0.3.890.g95457
next prev parent reply other threads:[~2008-11-30 10:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-30 10:54 [PATCH 0/8] Sparse checkout, the last half of the series Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 1/8] generate-cmdlist.sh: avoid selecting synopsis at wrong place Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 2/8] Introduce "sparse patterns" Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` Nguyễn Thái Ngọc Duy [this message]
2008-11-30 10:54 ` [PATCH 4/8] unpack_trees(): add support for sparse checkout Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 5/8] clone: support sparse checkout with --sparse-checkout option Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 6/8] checkout: add new options to support sparse checkout Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 7/8] Introduce default sparse patterns (core.defaultsparse) Nguyễn Thái Ngọc Duy
2008-11-30 10:54 ` [PATCH 8/8] wt-status: show sparse checkout info Nguyễn Thái Ngọc Duy
2008-12-01 14:10 ` [PATCH 1/8] generate-cmdlist.sh: avoid selecting synopsis at wrong place Johannes Schindelin
2008-12-01 14:11 ` Nguyen Thai Ngoc Duy
2008-12-01 14:11 ` Junio C Hamano
2008-12-01 15:39 ` Johannes Schindelin
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=1228042478-1886-4-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).