"Shawn O. Pearce" <spearce@xxxxxxxxxxx> writes: >> Among these, I think lines 2..3 are somewhat confusing but I am >> used to seeing them and do not mind them too much. > > In my experience these lines scare new users. And then they start > to ignore other "fatal:" messages from Git because they can safely > ignore this particular one. I tend to agree; we could do something like the attached. >> Lines 10..16 are useful, but I think we probably should show >> them only for outermost merges. > > Actually I think that only 13 is useful. 10-12,14-17 are > pretty useless messages in my mind. I am not sure. It is nice to view which paths have content-level merges as it is more significant than path-level merges. I think the output from merge-recursive can be categorized into 5 verbosity levels: 1. "CONFLICT", "Rename", "Adding here instead due to D/F conflict" (outermost) 2. "Auto-merged successfully" (outermost) 3. The first "Merging X with Y". 4. outermost "Merging:\ntitle1\ntitle2". 5. outermost "found N common ancestors\nancestor1\nancestor2\n..." and anything from inner merge. I would prefer the default verbosity level to be 2 (that is, show both 1 and 2); your "quieter" option would show only level 1, and somebody who is debugging reursive would ask for all levels. -- >8 -- [PATCH] Make 'trivial merge' attempt less verbose. This replaces die() calls in unpack-trees with simple and quiet exit(1) when we are trying trivial merges only and die() is about the case that cannot trivially be merged (i.e. not a serious corruption error but expected). Also it makes the nontrivial merges exit early. And then this updates git-merge so that we do not have to say "trying..." followed by "wonderful" or "nope". Signed-off-by: Junio C Hamano <junkio@xxxxxxx> --- git-merge.sh | 36 ++++++++++++++++++++++-------------- unpack-trees.c | 29 ++++++++++++++++++----------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/git-merge.sh b/git-merge.sh index 3eef048..6240a73 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -302,21 +302,29 @@ f,*) # one common. See if it is really trivial. git var GIT_COMMITTER_IDENT >/dev/null || exit - echo "Trying really trivial in-index merge..." git-update-index --refresh 2>/dev/null - if git-read-tree --trivial -m -u -v $common $head "$1" && - result_tree=$(git-write-tree) - then - echo "Wonderful." - result_commit=$( - echo "$merge_msg" | - git-commit-tree $result_tree -p HEAD -p "$1" - ) || exit - finish "$result_commit" "In-index merge" - dropsave - exit 0 - fi - echo "Nope." + git-read-tree --trivial -m -u -v $common $head "$1" + case "$?" in + 1) : expected failure from non-trivial merge + ;; + 0) + if result_tree=$(git-write-tree) + then + echo "Trivially merged in index." + result_commit=$( + echo "$merge_msg" | + git-commit-tree $result_tree -p HEAD -p "$1" + ) || exit + finish "$result_commit" "In-index merge" + dropsave + exit 0 + fi + ;; + *) + : This could be serious failure. + echo >&2 "Tried trivial merge but did not work; don't worry..." + ;; + esac ;; *) # An octopus. If we can reach all the remote we are up to date. diff --git a/unpack-trees.c b/unpack-trees.c index 2e2232c..0fca83b 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -409,17 +409,17 @@ int unpack_trees(struct object_list *trees, struct unpack_trees_options *o) return -1; } - if (o->trivial_merges_only && o->nontrivial_merge) - die("Merge requires file-level merging"); - check_updates(active_cache, active_nr, o); return 0; } /* Here come the merge functions */ -static void reject_merge(struct cache_entry *ce) +static void reject_merge(struct cache_entry *ce, + struct unpack_trees_options *o) { + if (o->trivial_merges_only) + exit(1); die("Entry '%s' would be overwritten by merge. Cannot merge.", ce->name); } @@ -459,6 +459,8 @@ static void verify_uptodate(struct cache_entry *ce, } if (errno == ENOENT) return; + if (o->trivial_merges_only) + exit(1); die("Entry '%s' not uptodate. Cannot merge.", ce->name); } @@ -473,15 +475,18 @@ static void invalidate_ce_path(struct cache_entry *ce) * is not tracked, unless it is ignored. */ static void verify_absent(const char *path, const char *action, - struct unpack_trees_options *o) + struct unpack_trees_options *o) { struct stat st; if (o->index_only || o->reset || !o->update) return; - if (!lstat(path, &st) && !(o->dir && excluded(o->dir, path))) + if (!lstat(path, &st) && !(o->dir && excluded(o->dir, path))) { + if (o->trivial_merges_only) + exit(1); die("Untracked working tree file '%s' " "would be %s by merge.", path, action); + } } static int merged_entry(struct cache_entry *merge, struct cache_entry *old, @@ -617,7 +622,7 @@ int threeway_merge(struct cache_entry **stages, /* #14, #14ALT, #2ALT */ if (remote && !df_conflict_head && head_match && !remote_match) { if (index && !same(index, remote) && !same(index, head)) - reject_merge(index); + reject_merge(index, o); return merged_entry(remote, index, o); } /* @@ -625,7 +630,7 @@ int threeway_merge(struct cache_entry **stages, * make sure that it matches head. */ if (index && !same(index, head)) { - reject_merge(index); + reject_merge(index, o); } if (head) { @@ -677,6 +682,8 @@ int threeway_merge(struct cache_entry **stages, } o->nontrivial_merge = 1; + if (o->trivial_merges_only) + exit(1); /* #2, #3, #4, #6, #7, #9, #11. */ count = 0; @@ -743,11 +750,11 @@ int twoway_merge(struct cache_entry **src, else { /* all other failures */ if (oldtree) - reject_merge(oldtree); + reject_merge(oldtree, o); if (current) - reject_merge(current); + reject_merge(current, o); if (newtree) - reject_merge(newtree); + reject_merge(newtree, o); return -1; } } -- 1.5.0.rc1.g120b - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html