Skip to content

Commit 9a4d8fd

Browse files
author
Junio C Hamano
committed
unpack-trees: get rid of *indpos parameter.
This variable keeps track of which entry in the original index the traversal is looking at, and belongs to the unpack_trees_options structure along with other traversal status information. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f7932a commit 9a4d8fd

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

unpack-trees.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ static int entcmp(const char *name1, int dir1, const char *name2, int dir2)
7070

7171
static int unpack_trees_rec(struct tree_entry_list **posns, int len,
7272
const char *base, struct unpack_trees_options *o,
73-
int *indpos,
7473
struct tree_entry_list *df_conflict_list)
7574
{
7675
int baselen = strlen(base);
@@ -100,7 +99,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
10099
cache_name = NULL;
101100

102101
/* Check the cache */
103-
if (o->merge && *indpos < active_nr) {
102+
if (o->merge && o->pos < active_nr) {
104103
/* This is a bit tricky: */
105104
/* If the index has a subdirectory (with
106105
* contents) as the first name, it'll get a
@@ -118,7 +117,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
118117
* file case.
119118
*/
120119

121-
cache_name = active_cache[*indpos]->name;
120+
cache_name = active_cache[o->pos]->name;
122121
if (strlen(cache_name) > baselen &&
123122
!memcmp(cache_name, base, baselen)) {
124123
cache_name += baselen;
@@ -158,8 +157,8 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
158157

159158
if (cache_name && !strcmp(cache_name, first)) {
160159
any_files = 1;
161-
src[0] = active_cache[*indpos];
162-
remove_cache_entry_at(*indpos);
160+
src[0] = active_cache[o->pos];
161+
remove_cache_entry_at(o->pos);
163162
}
164163

165164
for (i = 0; i < len; i++) {
@@ -228,7 +227,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
228227
#if DBRT_DEBUG > 1
229228
printf("Added %d entries\n", ret);
230229
#endif
231-
*indpos += ret;
230+
o->pos += ret;
232231
} else {
233232
for (i = 0; i < src_size; i++) {
234233
if (src[i]) {
@@ -244,7 +243,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
244243
newbase[baselen + pathlen] = '/';
245244
newbase[baselen + pathlen + 1] = '\0';
246245
if (unpack_trees_rec(subposns, len, newbase, o,
247-
indpos, df_conflict_list)) {
246+
df_conflict_list)) {
248247
retval = -1;
249248
goto leave_directory;
250249
}
@@ -375,7 +374,6 @@ static void check_updates(struct cache_entry **src, int nr,
375374

376375
int unpack_trees(struct object_list *trees, struct unpack_trees_options *o)
377376
{
378-
int indpos = 0;
379377
unsigned len = object_list_length(trees);
380378
struct tree_entry_list **posns;
381379
int i;
@@ -404,7 +402,7 @@ int unpack_trees(struct object_list *trees, struct unpack_trees_options *o)
404402
posn = posn->next;
405403
}
406404
if (unpack_trees_rec(posns, len, o->prefix ? o->prefix : "",
407-
o, &indpos, &df_conflict_list))
405+
o, &df_conflict_list))
408406
return -1;
409407
}
410408

unpack-trees.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct unpack_trees_options {
1616
int verbose_update;
1717
int aggressive;
1818
const char *prefix;
19+
int pos;
1920
struct dir_struct *dir;
2021
merge_fn_t fn;
2122

0 commit comments

Comments
 (0)