Skip to content

Commit 6c3d818

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent ee394bd commit 6c3d818

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

revision.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,13 +1262,13 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
12621262

12631263
}
12641264

1265-
void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
1265+
static void do_add_index_objects_to_pending(struct rev_info *revs,
1266+
struct index_state *istate)
12661267
{
12671268
int i;
12681269

1269-
read_cache();
1270-
for (i = 0; i < active_nr; i++) {
1271-
struct cache_entry *ce = active_cache[i];
1270+
for (i = 0; i < istate->cache_nr; i++) {
1271+
struct cache_entry *ce = istate->cache[i];
12721272
struct blob *blob;
12731273

12741274
if (S_ISGITLINK(ce->ce_mode))
@@ -1281,13 +1281,19 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
12811281
ce->ce_mode, ce->name);
12821282
}
12831283

1284-
if (active_cache_tree) {
1284+
if (istate->cache_tree) {
12851285
struct strbuf path = STRBUF_INIT;
1286-
add_cache_tree(active_cache_tree, revs, &path);
1286+
add_cache_tree(istate->cache_tree, revs, &path);
12871287
strbuf_release(&path);
12881288
}
12891289
}
12901290

1291+
void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
1292+
{
1293+
read_cache();
1294+
do_add_index_objects_to_pending(revs, &the_index);
1295+
}
1296+
12911297
static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
12921298
int exclude_parent)
12931299
{

0 commit comments

Comments
 (0)