@matheusbsbs / matheus-bagliano / commits / 9a4d8fdc25
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Apr 2, 2007 at 15:06 UTC 9a4d8fdc25d6ba08564766c6ded165212f423b61
2 files changed +8 -9
unpack-trees.c
+7 -9
@@ -70,7 +70,6 @@ static int entcmp(const char *name1, int dir1, const char *name2, int dir2)
70
71 static int unpack_trees_rec(struct tree_entry_list **posns, int len,
72 const char *base, struct unpack_trees_options *o,
73 - int *indpos,
73 struct tree_entry_list *df_conflict_list)
74 {
75 int baselen = strlen(base);
@@ -100,7 +99,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
99 cache_name = NULL;
100
101 /* Check the cache */
103 - if (o->merge && *indpos < active_nr) {
102 + if (o->merge && o->pos < active_nr) {
103 /* This is a bit tricky: */
104 /* If the index has a subdirectory (with
105 * 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,
117 * file case.
118 */
119
121 - cache_name = active_cache[*indpos]->name;
120 + cache_name = active_cache[o->pos]->name;
121 if (strlen(cache_name) > baselen &&
122 !memcmp(cache_name, base, baselen)) {
123 cache_name += baselen;
@@ -158,8 +157,8 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
157
158 if (cache_name && !strcmp(cache_name, first)) {
159 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);
162 }
163
164 for (i = 0; i < len; i++) {
@@ -228,7 +227,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
227 #if DBRT_DEBUG > 1
228 printf("Added %d entries\n", ret);
229 #endif
231 - *indpos += ret;
230 + o->pos += ret;
231 } else {
232 for (i = 0; i < src_size; i++) {
233 if (src[i]) {
@@ -244,7 +243,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
243 newbase[baselen + pathlen] = '/';
244 newbase[baselen + pathlen + 1] = '\0';
245 if (unpack_trees_rec(subposns, len, newbase, o,
247 - indpos, df_conflict_list)) {
246 + df_conflict_list)) {
247 retval = -1;
248 goto leave_directory;
249 }
@@ -375,7 +374,6 @@ static void check_updates(struct cache_entry **src, int nr,
374
375 int unpack_trees(struct object_list *trees, struct unpack_trees_options *o)
376 {
378 - int indpos = 0;
377 unsigned len = object_list_length(trees);
378 struct tree_entry_list **posns;
379 int i;
@@ -404,7 +402,7 @@ int unpack_trees(struct object_list *trees, struct unpack_trees_options *o)
402 posn = posn->next;
403 }
404 if (unpack_trees_rec(posns, len, o->prefix ? o->prefix : "",
407 - o, &indpos, &df_conflict_list))
405 + o, &df_conflict_list))
406 return -1;
407 }
408
unpack-trees.h
+1
@@ -16,6 +16,7 @@ struct unpack_trees_options {
16 int verbose_update;
17 int aggressive;
18 const char *prefix;
19 + int pos;
20 struct dir_struct *dir;
21 merge_fn_t fn;
22