summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 203a2fe)
raw | patch | inline | side by side (parent: 203a2fe)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Thu, 7 Feb 2008 16:39:52 +0000 (11:39 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 10 Feb 2008 07:16:51 +0000 (23:16 -0800) |
(This applies only to errors where a plausible operation is impossible due
to the particular data, not to errors resulting from misuse of the merge
functions.)
This will allow builtin-checkout to suppress merge errors if it's
going to try more merging methods.
Additionally, if unpack_trees() returns with an error, but without
printing anything, it will roll back any changes to the index (by
rereading the index, currently). This obviously could be done by the
caller, but chances are that the caller would forget and debugging
this is difficult. Also, future implementations may give unpack_trees() a
more efficient way of undoing its changes than the caller could.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
to the particular data, not to errors resulting from misuse of the merge
functions.)
This will allow builtin-checkout to suppress merge errors if it's
going to try more merging methods.
Additionally, if unpack_trees() returns with an error, but without
printing anything, it will roll back any changes to the index (by
rereading the index, currently). This obviously could be done by the
caller, but chances are that the caller would forget and debugging
this is difficult. Also, future implementations may give unpack_trees() a
more efficient way of undoing its changes than the caller could.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
unpack-trees.c | patch | blob | history | |
unpack-trees.h | patch | blob | history |
diff --git a/unpack-trees.c b/unpack-trees.c
index 9e6587f66186ef93c3403b15a016c00526cbc1e7..45f40c27755cbe20d1b1c07171b38a9b741bc157 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -356,12 +356,23 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
posns[i] = create_tree_entry_list(t+i);
if (unpack_trees_rec(posns, len, o->prefix ? o->prefix : "",
- o, &df_conflict_list))
+ o, &df_conflict_list)) {
+ if (o->gently) {
+ discard_cache();
+ read_cache();
+ }
return -1;
+ }
}
- if (o->trivial_merges_only && o->nontrivial_merge)
- return error("Merge requires file-level merging");
+ if (o->trivial_merges_only && o->nontrivial_merge) {
+ if (o->gently) {
+ discard_cache();
+ read_cache();
+ }
+ return o->gently ? -1 :
+ error("Merge requires file-level merging");
+ }
check_updates(active_cache, active_nr, o);
return 0;
}
if (errno == ENOENT)
return 0;
- return error("Entry '%s' not uptodate. Cannot merge.", ce->name);
+ return o->gently ? -1 :
+ error("Entry '%s' not uptodate. Cannot merge.", ce->name);
}
static void invalidate_ce_path(struct cache_entry *ce)
@@ -501,8 +513,9 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
d.exclude_per_dir = o->dir->exclude_per_dir;
i = read_directory(&d, ce->name, pathbuf, namelen+1, NULL);
if (i)
- return error("Updating '%s' would lose untracked files in it",
- ce->name);
+ return o->gently ? -1 :
+ error("Updating '%s' would lose untracked files in it",
+ ce->name);
free(pathbuf);
return cnt;
}
return 0;
}
- return error("Untracked working tree file '%s' "
- "would be %s by merge.", ce->name, action);
+ return o->gently ? -1 :
+ error("Untracked working tree file '%s' "
+ "would be %s by merge.", ce->name, action);
}
return 0;
}
/* #14, #14ALT, #2ALT */
if (remote && !df_conflict_head && head_match && !remote_match) {
if (index && !same(index, remote) && !same(index, head))
- return reject_merge(index);
+ return o->gently ? -1 : reject_merge(index);
return merged_entry(remote, index, o);
}
/*
* make sure that it matches head.
*/
if (index && !same(index, head)) {
- return reject_merge(index);
+ return o->gently ? -1 : reject_merge(index);
}
if (head) {
/* all other failures */
remove_entry(remove);
if (oldtree)
- return reject_merge(oldtree);
+ return o->gently ? -1 : reject_merge(oldtree);
if (current)
- return reject_merge(current);
+ return o->gently ? -1 : reject_merge(current);
if (newtree)
- return reject_merge(newtree);
+ return o->gently ? -1 : reject_merge(newtree);
return -1;
}
}
return error("Cannot do a bind merge of %d trees\n",
o->merge_size);
if (a && old)
- return error("Entry '%s' overlaps. Cannot bind.", a->name);
+ return o->gently ? -1 :
+ error("Entry '%s' overlaps. Cannot bind.", a->name);
if (!a)
return keep_entry(old, o);
else
diff --git a/unpack-trees.h b/unpack-trees.h
index 197a0044aa71fc9ca310b36b279b8382487a40a7..83d12295325ba234458d140c5cc718ce5176ede9 100644 (file)
--- a/unpack-trees.h
+++ b/unpack-trees.h
int trivial_merges_only;
int verbose_update;
int aggressive;
+ int gently;
const char *prefix;
int pos;
struct dir_struct *dir;