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 4/5] unpack_trees(): keep track of unmerged entries
Date: Wed, 29 Jul 2009 16:49:13 +1000 [thread overview]
Message-ID: <1248850154-5469-5-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1248850154-5469-4-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 | 6 +++++-
unpack-trees.c | 7 +++++++
unpack-trees.h | 2 ++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 9c2d634..17ca265 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -113,7 +113,11 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
argc = parse_options(argc, argv, unused_prefix, read_tree_options,
read_tree_usage, 0);
- if (read_cache_unmerged() && (opts.prefix || opts.merge))
+ if (opts.reset) {
+ opts.prune_unmerged = 1;
+ read_cache();
+ }
+ else if (read_cache_unmerged() && (opts.prefix || opts.merge))
die("You need to resolve your current index first");
prefix_set = opts.prefix ? 1 : 0;
diff --git a/unpack-trees.c b/unpack-trees.c
index 720f7a1..c67eed8 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -289,6 +289,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);
@@ -308,6 +309,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 d19df44..aa3ac17 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -26,6 +26,8 @@ struct unpack_trees_options {
verbose_update,
aggressive,
skip_unmerged,
+ prune_unmerged,
+ has_unmerged,
initial_checkout,
diff_index_cached,
gently;
--
1.6.3.2.448.gdf8b6
next prev parent reply other threads:[~2009-07-29 6:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 6:49 [RFC PATCH 0/5] Sparse checkout resurrection Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 1/5] Prevent diff machinery from examining worktree outside sparse checkout Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 2/5] grep: skip files outside sparse checkout area Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 3/5] gitignore: read from index if .gitignore is not in worktree Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` Nguyễn Thái Ngọc Duy [this message]
2009-07-29 6:49 ` [PATCH 5/5] unpack_trees(): add support for sparse checkout Nguyễn Thái Ngọc Duy
2009-07-29 11:48 ` Jakub Narebski
2009-07-29 23:32 ` Nguyen Thai Ngoc Duy
2009-07-30 0:42 ` Jakub Narebski
2009-07-31 16:55 ` [PATCH 3/5] gitignore: read from index if .gitignore is not in worktree Junio C Hamano
2009-07-31 16:42 ` [PATCH 2/5] grep: skip files outside sparse checkout area Junio C Hamano
2009-08-04 13:14 ` Nguyen Thai Ngoc Duy
2009-07-31 16:34 ` [PATCH 1/5] Prevent diff machinery from examining worktree outside sparse checkout Junio C Hamano
2009-07-31 21:18 ` [RFC PATCH 0/5] Sparse checkout resurrection skillzero
2009-08-04 13:20 ` Nguyen Thai Ngoc Duy
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=1248850154-5469-5-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).