merge script: --ff-only to disallow true merge
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Aug 17, 2010 at 02:10 UTC
f07df52489c78c33c5c5c1bd973038283c401582
1 file changed
+15
-2
contrib/examples/git-merge.sh
+15
-2
@@ -15,6 +15,7 @@ log add list of one-line log to merge commit message
15
squash create a single commit instead of doing a merge
16
commit perform a commit if the merge succeeds (default)
17
ff allow fast-forward (default)
18
+ff-only abort if fast-forward is not possible
19
s,strategy= merge strategy to use
20
X= option for selected merge strategy
21
m,message= message to be used for the merge commit (if any)
@@ -45,6 +46,7 @@ use_strategies=
46
xopt=
47
48
allow_fast_forward=t
49
+fast_forward_only=
50
allow_trivial_merge=t
51
squash= no_commit= log_arg=
52
@@ -189,7 +191,13 @@ parse_config () {
191
--no-ff)
192
test "$squash" != t ||
193
die "You cannot combine --squash with --no-ff."
194
+ test "$fast_forward_only" != t ||
195
+ die "You cannot combine --ff-only with --no-ff."
196
allow_fast_forward=f ;;
197
+ --ff-only)
198
+ test "$allow_fast_forward" != f ||
199
+ die "You cannot combine --ff-only with --no-ff."
200
+ fast_forward_only=t ;;
201
-s|--strategy)
202
shift
203
case " $all_strategies " in
@@ -412,8 +420,8 @@ t,1,"$head",*)
420
# We are not doing octopus, not fast-forward, and have only
421
# one common.
422
git update-index --refresh 2>/dev/null
415
- case "$allow_trivial_merge" in
416
- t)
423
+ case "$allow_trivial_merge,$fast_forward_only" in
424
+ t,)
425
# See if it is really trivial.
426
git var GIT_COMMITTER_IDENT >/dev/null || exit
427
echo "Trying really trivial in-index merge..."
@@ -452,6 +460,11 @@ t,1,"$head",*)
460
;;
461
esac
462
463
+if test "$fast_forward_only" = t
464
+then
465
+ die "Not possible to fast-forward, aborting."
466
+fi
467
+
468
# We are going to make a new commit.
469
git var GIT_COMMITTER_IDENT >/dev/null || exit
470