Skip to content

Commit 39add7a

Browse files
committed
Merge branch 'jc/fix-tree-walk' (early part)
* 'jc/fix-tree-walk' (early part): unpack_callback(): use unpack_failed() consistently unpack-trees: typofix diff-lib.c: fix misleading comments on oneway_diff()
2 parents 885d492 + 353c5ee commit 39add7a

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

diff-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_op
383383
* For diffing, the index is more important, and we only have a
384384
* single tree.
385385
*
386-
* We're supposed to return how many index entries we want to skip.
386+
* We're supposed to advance o->pos to skip what we have already processed.
387387
*
388388
* This wrapper makes it all more readable, and takes care of all
389389
* the fairly complex unpack_trees() semantic requirements, including

unpack-trees.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
277277
return 0;
278278
}
279279

280+
static int unpack_failed(struct unpack_trees_options *o, const char *message)
281+
{
282+
discard_index(&o->result);
283+
if (!o->gently) {
284+
if (message)
285+
return error("%s", message);
286+
return -1;
287+
}
288+
return -1;
289+
}
290+
280291
static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
281292
{
282293
struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -294,7 +305,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
294305
int cmp = compare_entry(ce, info, p);
295306
if (cmp < 0) {
296307
if (unpack_index_entry(ce, o) < 0)
297-
return -1;
308+
return unpack_failed(o, NULL);
298309
continue;
299310
}
300311
if (!cmp) {
@@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
352363
return mask;
353364
}
354365

355-
static int unpack_failed(struct unpack_trees_options *o, const char *message)
356-
{
357-
discard_index(&o->result);
358-
if (!o->gently) {
359-
if (message)
360-
return error("%s", message);
361-
return -1;
362-
}
363-
return -1;
364-
}
365-
366366
/*
367367
* N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
368368
* resulting index, -2 on failure to reflect the changes to the work tree.
@@ -617,7 +617,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
617617
* found "foo/." in the working tree.
618618
* This is tricky -- if we have modified
619619
* files that are in "foo/" we would lose
620-
* it.
620+
* them.
621621
*/
622622
ret = verify_clean_subdirectory(ce, action, o);
623623
if (ret < 0)

0 commit comments

Comments
 (0)