aboutsummaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-08-23 19:36:51 +0700
committerJunio C Hamano <gitster@pobox.com>2017-08-24 14:42:45 -0700
commit6c3d818154eb74a4d5b35e786eefd297745bae1a (patch)
tree18a6589e5e2fcaa51867567970b5e0048af082ab /revision.c
parentee394bd376e833d8e9e38f81c57f6b4a370e8a92 (diff)
downloadgit-6c3d818154eb74a4d5b35e786eefd297745bae1a.tar.gz
git-6c3d818154eb74a4d5b35e786eefd297745bae1a.tar.xz
revision.c: refactor add_index_objects_to_pending()
The core code is factored out and take 'struct index_state *' instead so that we can reuse it to add objects from index files other than .git/index in the next patch. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/revision.c b/revision.c
index aa3b946a8..6c46ad6c8 100644
--- a/revision.c
+++ b/revision.c
@@ -1262,13 +1262,13 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
}
-void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
+static void do_add_index_objects_to_pending(struct rev_info *revs,
+ struct index_state *istate)
{
int i;
- read_cache();
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
+ for (i = 0; i < istate->cache_nr; i++) {
+ struct cache_entry *ce = istate->cache[i];
struct blob *blob;
if (S_ISGITLINK(ce->ce_mode))
@@ -1281,13 +1281,19 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
ce->ce_mode, ce->name);
}
- if (active_cache_tree) {
+ if (istate->cache_tree) {
struct strbuf path = STRBUF_INIT;
- add_cache_tree(active_cache_tree, revs, &path);
+ add_cache_tree(istate->cache_tree, revs, &path);
strbuf_release(&path);
}
}
+void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
+{
+ read_cache();
+ do_add_index_objects_to_pending(revs, &the_index);
+}
+
static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
int exclude_parent)
{