[PATCH 21/24] merge script: --ff-only to disallow true merge

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Nieder
Date: Tuesday, August 17, 2010 - 12:10 am

Port v1.6.6-rc0~62^2 (Teach 'git merge' and 'git pull' the option
--ff-only, 2009-10-29) to the old merge script.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 contrib/examples/git-merge.sh |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh
index 410fa3c..dfd6e17 100755
--- a/contrib/examples/git-merge.sh
+++ b/contrib/examples/git-merge.sh
@@ -15,6 +15,7 @@ log                  add list of one-line log to merge commit message
 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
 s,strategy=          merge strategy to use
 X=                   option for selected merge strategy
 m,message=           message to be used for the merge commit (if any)
@@ -45,6 +46,7 @@ use_strategies=
 xopt=
 
 allow_fast_forward=t
+fast_forward_only=
 allow_trivial_merge=t
 squash= no_commit= log_arg=
 
@@ -189,7 +191,13 @@ parse_config () {
 		--no-ff)
 			test "$squash" != t ||
 				die "You cannot combine --squash with --no-ff."
+			test "$fast_forward_only" != t ||
+				die "You cannot combine --ff-only with --no-ff."
 			allow_fast_forward=f ;;
+		--ff-only)
+			test "$allow_fast_forward" != f ||
+				die "You cannot combine --ff-only with --no-ff."
+			fast_forward_only=t ;;
 		-s|--strategy)
 			shift
 			case " $all_strategies " in
@@ -412,8 +420,8 @@ t,1,"$head",*)
 	# We are not doing octopus, not fast-forward, and have only
 	# one common.
 	git update-index --refresh 2>/dev/null
-	case "$allow_trivial_merge" in
-	t)
+	case "$allow_trivial_merge,$fast_forward_only" in
+	t,)
 		# See if it is really trivial.
 		git var GIT_COMMITTER_IDENT >/dev/null || exit
 		echo "Trying really trivial in-index merge..."
@@ -452,6 +460,11 @@ t,1,"$head",*)
 	;;
 esac
 
+if test "$fast_forward_only" = t
+then
+	die "Not possible to fast-forward, aborting."
+fi
+
 # We are going to make a new commit.
 git var GIT_COMMITTER_IDENT >/dev/null || exit
 
-- 
1.7.2.1.544.ga752d.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 01/24] merge: do not mistake (ancestor of) tag for ..., Jonathan Nieder, (Mon Aug 16, 11:52 pm)
[PATCH 02/24] t7600 (merge): modernize style, Jonathan Nieder, (Mon Aug 16, 11:53 pm)
[PATCH 03/24] t7600 (merge): do not launch gitk for --debug, Jonathan Nieder, (Mon Aug 16, 11:54 pm)
[PATCH 04/24] t7600 (merge): check reflog entry, Jonathan Nieder, (Mon Aug 16, 11:56 pm)
[PATCH 06/24] t6010 (merge-base): modernize style, Jonathan Nieder, (Mon Aug 16, 11:57 pm)
[PATCH 07/24] t6200 (fmt-merge-msg): style nitpicks, Jonathan Nieder, (Mon Aug 16, 11:57 pm)
[PATCH 11/24] fmt-merge-msg -m to override subject line, Jonathan Nieder, (Tue Aug 17, 12:02 am)
[PATCH 14/24] merge script: refuse to merge during merge, Jonathan Nieder, (Tue Aug 17, 12:03 am)
[PATCH 15/24] merge script: improve log message subject, Jonathan Nieder, (Tue Aug 17, 12:04 am)
[PATCH 16/24] merge script: merge -X&lt;option&gt;, Jonathan Nieder, (Tue Aug 17, 12:05 am)
[PATCH 17/24] merge script: allow custom strategies, Jonathan Nieder, (Tue Aug 17, 12:05 am)
[PATCH 18/24] merge script: forbid merge -s index, Jonathan Nieder, (Tue Aug 17, 12:06 am)
[PATCH 19/24] merge script: handle -m --log correctly, Jonathan Nieder, (Tue Aug 17, 12:06 am)
[PATCH 20/24] merge script: handle many-way octopus, Jonathan Nieder, (Tue Aug 17, 12:09 am)
[PATCH 21/24] merge script: --ff-only to disallow true merge, Jonathan Nieder, (Tue Aug 17, 12:10 am)
[PATCH 23/24] merge script: notice @{-1} shorthand, Jonathan Nieder, (Tue Aug 17, 12:11 am)
[PATCH 24/24] merge script: learn --[no-]rerere-autoupdate, Jonathan Nieder, (Tue Aug 17, 12:13 am)
Re: [PATCH 03/24] t7600 (merge): do not launch gitk for -- ..., Ævar Arnfjörð Bjarmason, (Tue Aug 17, 12:31 am)
Re: [PATCH 13/24] merge script: tweak unmerged files messa ..., Ævar Arnfjörð Bjarmason, (Tue Aug 17, 12:36 am)
Re: [PATCH/RFC] updating examples/git-merge (plus a builti ..., Ævar Arnfjörð Bjarmason, (Tue Aug 17, 12:46 am)
Re: [PATCH 19/24] merge script: handle -m --log correctly, Tay Ray Chuan, (Tue Aug 17, 2:55 am)
Re: [PATCH 03/24] t7600 (merge): do not launch gitk for -- ..., Sverre Rabbelier, (Tue Aug 17, 10:50 am)
Re: [PATCH 19/24] merge script: handle -m --log correctly, Jonathan Nieder, (Tue Aug 17, 2:54 pm)
[PATCH 11/24 v2] fmt-merge-msg -m to override merge title, Jonathan Nieder, (Tue Aug 17, 4:00 pm)
Re: [PATCH 03/24] t7600 (merge): do not launch gitk for -- ..., Ævar Arnfjörð Bjarmason, (Wed Aug 18, 1:55 am)