From 2ae4fd7695abcf2ab36f3fe984cc4ca44559635f Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Sep 2007 00:51:41 +0200 Subject: git-merge: fix faulty SQUASH_MSG Only the first 'remote' head is currently specified as an argument to 'git log' when generating a SQUSH_MSG, which makes the generated message fail to mention every commit involved in the merge. This fixes the problem. Noticed-by: Junio C Hamano Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index cde09d4d60..919e6be4b0 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -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 () { -- cgit v1.2.3 From d38eb710d92864b0b1f7cd36f17e273e3d8c735c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Sep 2007 00:51:42 +0200 Subject: git-merge: refactor option parsing Move the option parsing into a separate function as preparation for reuse by the next commit. Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- git-merge.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 919e6be4b0..49185eb5d2 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -119,11 +119,7 @@ merge_name () { 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) @@ -166,9 +162,21 @@ do have_message=t ;; -*) usage ;; - *) break ;; + *) return 1 ;; esac shift + args_left=$# +} + +test $# != 0 || usage + +have_message= +while parse_option "$@" +do + while test $args_left -lt $# + do + shift + done done if test -z "$show_diffstat"; then -- cgit v1.2.3 From aec7b362ad07e1a2c58051c8db653dabffee8960 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Sep 2007 00:51:43 +0200 Subject: git-merge: add support for branch..mergeoptions This enables per branch configuration of merge options. Currently, the most useful options to specify per branch are --squash, --summary/--no-summary and possibly --strategy, but all options are supported. Note: Options containing whitespace will _not_ be handled correctly. Luckily, the only option which can include whitespace is --message and it doesn't make much sense to give that option a default value. Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- git-merge.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 49185eb5d2..a35b15157b 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -168,9 +168,30 @@ parse_option () { 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 $# -- cgit v1.2.3 From d08af0ad745869a4fe36bc8df4f9804edfb74eb9 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Sep 2007 00:51:44 +0200 Subject: git-merge: add support for --commit and --no-squash These options can be used to override --no-commit and --squash, which is needed since --no-commit and --squash now can be specified as default merge options in $GIT_DIR/config. The change also introduces slightly different behavior for --no-commit: when specified, it explicitly overrides --squash. Earlier, 'git merge --squash --no-commit' would result in a squashed merge (i.e. no $GIT_DIR/MERGE_HEAD was created) but with this patch the command will behave as if --squash hadn't been specified. Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- git-merge.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index a35b15157b..a0fc60602a 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -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] [-s ] [-m=] +' SUBDIRECTORY_OK=Yes . git-sh-setup @@ -128,8 +128,12 @@ parse_option () { show_diffstat=t ;; --sq|--squ|--squa|--squas|--squash) squash=t no_commit=t ;; + --no-sq|--no-squ|--no-squa|--no-squas|--no-squash) + squash= no_commit= ;; + --c|--co|--com|--comm|--commi|--commit) + squash= no_commit= ;; --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) - no_commit=t ;; + squash= no_commit=t ;; -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ --strateg=*|--strategy=*|\ -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) -- cgit v1.2.3 From d66424c4ac661c69640765260235452499d80378 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Sep 2007 00:51:45 +0200 Subject: git-merge: add --ff and --no-ff options These new options can be used to control the policy for fast-forward merges: --ff allows it (this is the default) while --no-ff will create a merge commit. Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- git-merge.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index a0fc60602a..ce66524340 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [-s ] [-m=] +' +USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s ] [-m=] +' SUBDIRECTORY_OK=Yes . git-sh-setup @@ -127,13 +127,17 @@ parse_option () { --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) - squash= no_commit= ;; + allow_fast_forward=t squash= no_commit= ;; --c|--co|--com|--comm|--commi|--commit) - squash= no_commit= ;; + allow_fast_forward=t squash= no_commit= ;; --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) - squash= 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) @@ -477,7 +481,13 @@ done # 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 -- cgit v1.2.3