Skip to content

Commit

Permalink
Merge branch 'jc/fix-tree-walk' (early part)
Browse files Browse the repository at this point in the history
* 'jc/fix-tree-walk' (early part):
  unpack_callback(): use unpack_failed() consistently
  unpack-trees: typofix
  diff-lib.c: fix misleading comments on oneway_diff()
  • Loading branch information
Junio C Hamano committed Nov 21, 2009
2 parents 885d492 + 353c5ee commit 39add7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion diff-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_op
* For diffing, the index is more important, and we only have a
* single tree.
*
* We're supposed to return how many index entries we want to skip.
* We're supposed to advance o->pos to skip what we have already processed.
*
* This wrapper makes it all more readable, and takes care of all
* the fairly complex unpack_trees() semantic requirements, including
Expand Down
26 changes: 13 additions & 13 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
return 0;
}

static int unpack_failed(struct unpack_trees_options *o, const char *message)
{
discard_index(&o->result);
if (!o->gently) {
if (message)
return error("%s", message);
return -1;
}
return -1;
}

static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
{
struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
Expand All @@ -294,7 +305,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
int cmp = compare_entry(ce, info, p);
if (cmp < 0) {
if (unpack_index_entry(ce, o) < 0)
return -1;
return unpack_failed(o, NULL);
continue;
}
if (!cmp) {
Expand Down Expand Up @@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
return mask;
}

static int unpack_failed(struct unpack_trees_options *o, const char *message)
{
discard_index(&o->result);
if (!o->gently) {
if (message)
return error("%s", message);
return -1;
}
return -1;
}

/*
* N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
* resulting index, -2 on failure to reflect the changes to the work tree.
Expand Down Expand Up @@ -617,7 +617,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
* found "foo/." in the working tree.
* This is tricky -- if we have modified
* files that are in "foo/" we would lose
* it.
* them.
*/
ret = verify_clean_subdirectory(ce, action, o);
if (ret < 0)
Expand Down

0 comments on commit 39add7a

Please sign in to comment.