From: Junio C Hamano Date: Wed, 3 Oct 2007 10:05:58 +0000 (-0700) Subject: Merge branch 'lh/merge' X-Git-Tag: v1.5.4-rc0~388 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e66273a6abb8e9cd0967d52113e29c8014a255f8?ds=inline;hp=-c Merge branch 'lh/merge' * lh/merge: git-merge: add --ff and --no-ff options git-merge: add support for --commit and --no-squash git-merge: add support for branch..mergeoptions git-merge: refactor option parsing git-merge: fix faulty SQUASH_MSG Add test-script for git-merge porcelain --- e66273a6abb8e9cd0967d52113e29c8014a255f8 diff --combined Documentation/config.txt index eebb0b6ba2,d3c25f30f5..971fd9f16f --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -337,6 -337,12 +337,12 @@@ branch..merge: branch..merge to the desired branch, and use the special setting `.` (a period) for branch..remote. + branch..mergeoptions:: + Sets default options for merging into branch . The syntax and + supported options are equal to that of gitlink:git-merge[1], but + option values containing whitespace characters are currently not + supported. + clean.requireForce:: A boolean to make git-clean do nothing unless given -f or -n. Defaults to false. @@@ -439,19 -445,6 +445,19 @@@ gc.aggressiveWindow: algorithm used by 'git gc --aggressive'. This defaults to 10. +gc.auto:: + When there are approximately more than this many loose + objects in the repository, `git gc --auto` will pack them. + Some Porcelain commands use this command to perform a + light-weight garbage collection from time to time. Setting + this to 0 disables it. + +gc.autopacklimit:: + When there are more than this many packs that are not + marked with `*.keep` file in the repository, `git gc + --auto` consolidates them into one larger pack. Setting + this to 0 disables this. + gc.packrefs:: `git gc` does not run `git pack-refs` in a bare repository by default so that older dumb-transport clients can still fetch @@@ -592,7 -585,7 +598,7 @@@ merge.summary: merge.tool:: Controls which merge resolution program is used by - gitlink:git-mergetool[l]. Valid values are: "kdiff3", "tkdiff", + gitlink:git-mergetool[1]. Valid values are: "kdiff3", "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff". merge.verbosity:: diff --combined Documentation/git-merge.txt index eae49c4876,b1771a13c8..bca4212e56 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@@ -56,8 -56,12 +56,12 @@@ merge.verbosity: message if conflicts were detected. Level 1 outputs only conflicts, 2 outputs conflicts and file changes. Level 5 and above outputs debugging information. The default is level 2. - Can be overriden by 'GIT_MERGE_VERBOSITY' environment variable. + Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable. + branch..mergeoptions:: + Sets default options for merging into branch . The syntax and + supported options are equal to that of git-merge, but option values + containing whitespace characters are currently not supported. HOW MERGE WORKS --------------- diff --combined git-merge.sh index bf18f582da,ce66524340..c2092a2040 --- a/git-merge.sh +++ b/git-merge.sh @@@ -3,7 -3,7 +3,7 @@@ # Copyright (c) 2005 Junio C Hamano # - USAGE='[-n] [--summary] [--no-commit] [--squash] [-s ] [-m=] +' + USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s ] [-m=] +' SUBDIRECTORY_OK=Yes . git-sh-setup @@@ -59,7 -59,7 +59,7 @@@ finish_up_to_date () squash_message () { echo Squashed commit of the following: echo - git log --no-merges ^"$head" $remote + git log --no-merges ^"$head" $remoteheads } finish () { @@@ -82,7 -82,6 +82,7 @@@ ;; *) git update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1 + git gc --auto ;; esac ;; @@@ -98,19 -97,6 +98,19 @@@ fi ;; esac + + # Run a post-merge hook + if test -x "$GIT_DIR"/hooks/post-merge + then + case "$squash" in + t) + "$GIT_DIR"/hooks/post-merge 1 + ;; + '') + "$GIT_DIR"/hooks/post-merge 0 + ;; + esac + fi } merge_name () { @@@ -133,11 -119,7 +133,7 @@@ fi } - case "$#" in 0) usage ;; esac - - have_message= - while test $# != 0 - do + parse_option () { case "$1" in -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\ --no-summa|--no-summar|--no-summary) @@@ -145,9 -127,17 +141,17 @@@ --summary) show_diffstat=t ;; --sq|--squ|--squa|--squas|--squash) - squash=t no_commit=t ;; + allow_fast_forward=t squash=t no_commit=t ;; + --no-sq|--no-squ|--no-squa|--no-squas|--no-squash) + allow_fast_forward=t squash= no_commit= ;; + --c|--co|--com|--comm|--commi|--commit) + allow_fast_forward=t squash= no_commit= ;; --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) - no_commit=t ;; + allow_fast_forward=t squash= no_commit=t ;; + --ff) + allow_fast_forward=t squash= no_commit= ;; + --no-ff) + allow_fast_forward=false squash= no_commit= ;; -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ --strateg=*|--strategy=*|\ -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) @@@ -180,9 -170,42 +184,42 @@@ have_message=t ;; -*) usage ;; - *) break ;; + *) return 1 ;; esac shift + args_left=$# + } + + parse_config () { + while test $# -gt 0 + do + parse_option "$@" || usage + while test $args_left -lt $# + do + shift + done + done + } + + test $# != 0 || usage + + have_message= + + if branch=$(git-symbolic-ref -q HEAD) + then + mergeopts=$(git config "branch.${branch#refs/heads/}.mergeoptions") + if test -n "$mergeopts" + then + parse_config $mergeopts + fi + fi + + while parse_option "$@" + do + while test $args_left -lt $# + do + shift + done done if test -z "$show_diffstat"; then @@@ -458,7 -481,13 +495,13 @@@ don # auto resolved the merge cleanly. if test '' != "$result_tree" then - parents=$(git show-branch --independent "$head" "$@" | sed -e 's/^/-p /') + if test "$allow_fast_forward" = "t" + then + parents=$(git show-branch --independent "$head" "$@") + else + parents=$(git rev-parse "$head" "$@") + fi + parents=$(echo "$parents" | sed -e 's/^/-p /') result_commit=$(printf '%s\n' "$merge_msg" | git commit-tree $result_tree $parents) || exit finish "$result_commit" "Merge made by $wt_strategy." dropsave