X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=contrib%2Fexamples%2Fgit-merge.sh;h=7b922c39480c8b78d0687cbabac59672f9ae6ede;hb=6b948a7a480b4ad5e112eb1642e9160e2a3b4f2b;hp=dfd6e17946946825ad7a486e90d35a9f310020e6;hpb=f07df52489c78c33c5c5c1bd973038283c401582;p=git.git diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index dfd6e1794..7b922c394 100755 --- a/contrib/examples/git-merge.sh +++ b/contrib/examples/git-merge.sh @@ -16,6 +16,7 @@ squash create a single commit instead of doing a merge commit perform a commit if the merge succeeds (default) ff allow fast-forward (default) ff-only abort if fast-forward is not possible +rerere-autoupdate update index with any reused conflict resolution s,strategy= merge strategy to use X= option for selected merge strategy m,message= message to be used for the merge commit (if any) @@ -48,11 +49,11 @@ xopt= allow_fast_forward=t fast_forward_only= allow_trivial_merge=t -squash= no_commit= log_arg= +squash= no_commit= log_arg= rr_arg= dropsave() { rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \ - "$GIT_DIR/MERGE_STASH" || exit 1 + "$GIT_DIR/MERGE_STASH" "$GIT_DIR/MERGE_MODE" || exit 1 } savestate() { @@ -148,13 +149,15 @@ merge_name () { if found_ref=$(git rev-parse --symbolic-full-name --verify \ "$remote" 2>/dev/null) then + expanded=$(git check-ref-format --branch "$remote") || + exit if test "${found_ref#refs/heads/}" != "$found_ref" then - echo "$rh branch '$remote' of ." + echo "$rh branch '$expanded' of ." return elif test "${found_ref#refs/remotes/}" != "$found_ref" then - echo "$rh remote branch '$remote' of ." + echo "$rh remote branch '$expanded' of ." return fi fi @@ -198,6 +201,8 @@ parse_config () { test "$allow_fast_forward" != f || die "You cannot combine --ff-only with --no-ff." fast_forward_only=t ;; + --rerere-autoupdate|--no-rerere-autoupdate) + rr_arg=$1 ;; -s|--strategy) shift case " $all_strategies " in @@ -585,7 +590,15 @@ else do echo $remote done >"$GIT_DIR/MERGE_HEAD" - printf '%s\n' "$merge_msg" >"$GIT_DIR/MERGE_MSG" + printf '%s\n' "$merge_msg" >"$GIT_DIR/MERGE_MSG" || + die "Could not write to $GIT_DIR/MERGE_MSG" + if test "$allow_fast_forward" != t + then + printf "%s" no-ff + else + : + fi >"$GIT_DIR/MERGE_MODE" || + die "Could not write to $GIT_DIR/MERGE_MODE" fi if test "$merge_was_ok" = t @@ -602,6 +615,6 @@ Conflicts: sed -e 's/^[^ ]* / /' | uniq } >>"$GIT_DIR/MERGE_MSG" - git rerere + git rerere $rr_arg die "Automatic merge failed; fix conflicts and then commit the result." fi