summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d11f21)
raw | patch | inline | side by side (parent: 2d11f21)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 31 May 2011 17:06:44 +0000 (10:06 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 31 May 2011 18:24:12 +0000 (11:24 -0700) |
A negative return from the unpack callback function usually means unpack
failed for the entry and signals the unpack_trees() machinery to fail the
entire merge operation, immediately and there is no other way for the
callback to tell the machinery to exit early without reporting an error.
This is what we usually want to make a merge all-or-nothing operation, but
the machinery is also used for diff-index codepath by using a custom
unpack callback function. And we do sometimes want to exit early without
failing, namely when we are under --quiet and can short-cut the diff upon
finding the first difference.
Add "exiting_early" field to unpack_trees_options structure, to signal the
unpack_trees() machinery that the negative return value is not signaling
an error but an early return from the unpack_trees() machinery. As this by
definition hasn't unpacked everything, discard the resulting index just
like the failure codepath.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
failed for the entry and signals the unpack_trees() machinery to fail the
entire merge operation, immediately and there is no other way for the
callback to tell the machinery to exit early without reporting an error.
This is what we usually want to make a merge all-or-nothing operation, but
the machinery is also used for diff-index codepath by using a custom
unpack callback function. And we do sometimes want to exit early without
failing, namely when we are under --quiet and can short-cut the diff upon
finding the first difference.
Add "exiting_early" field to unpack_trees_options structure, to signal the
unpack_trees() machinery that the negative return value is not signaling
an error but an early return from the unpack_trees() machinery. As this by
definition hasn't unpacked everything, discard the resulting index just
like the failure codepath.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c | patch | blob | history | |
unpack-trees.c | patch | blob | history | |
unpack-trees.h | patch | blob | history |
diff --git a/diff-lib.c b/diff-lib.c
index 9c29293bbc05d175ba13338813e8532c7ad677cf..2e09500c8210e22d6c81484aa198f1d811a9933d 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -433,8 +433,13 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
if (tree == o->df_conflict_entry)
tree = NULL;
- if (ce_path_match(idx ? idx : tree, &revs->prune_data))
+ if (ce_path_match(idx ? idx : tree, &revs->prune_data)) {
do_oneway_diff(o, idx, tree);
+ if (diff_can_quit_early(&revs->diffopt)) {
+ o->exiting_early = 1;
+ return -1;
+ }
+ }
return 0;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index 500ebcfd545772fb17e5fb14bba42bf4be468b75..b2b6a901b20c513e4fd9333412802a758006dd88 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
static int unpack_failed(struct unpack_trees_options *o, const char *message)
{
discard_index(&o->result);
- if (!o->gently) {
+ if (!o->gently && !o->exiting_early) {
if (message)
return error("%s", message);
return -1;
display_error_msgs(o);
mark_all_ce_unused(o->src_index);
ret = unpack_failed(o, NULL);
+ if (o->exiting_early)
+ ret = 0;
goto done;
}
diff --git a/unpack-trees.h b/unpack-trees.h
index cd11a08365ab3e27b1321b3df87bcab6b9278f90..4c6c54033e2d319a305e9a82d06e48e570f4f871 100644 (file)
--- a/unpack-trees.h
+++ b/unpack-trees.h
debug_unpack,
skip_sparse_checkout,
gently,
+ exiting_early,
show_all_errors;
const char *prefix;
int cache_bottom;