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 <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lars Hjemli committed
Sep 24, 2007 at 00:51 UTC
d08af0ad745869a4fe36bc8df4f9804edfb74eb9
3 files changed
+36
-2
Documentation/merge-options.txt
+8
@@ -10,6 +10,10 @@
10
not autocommit, to give the user a chance to inspect and
11
further tweak the merge result before committing.
12
13
+--commit::
14
+ Perform the merge and commit the result. This option can
15
+ be used to override --no-commit.
16
+
17
--squash::
18
Produce the working tree and index state as if a real
19
merge happened, but do not actually make a commit or
@@ -19,6 +23,10 @@
23
top of the current branch whose effect is the same as
24
merging another branch (or more in case of an octopus).
25
26
+--no-squash::
27
+ Perform the merge and commit the result. This option can
28
+ be used to override --squash.
29
+
30
-s <strategy>, \--strategy=<strategy>::
31
Use the given merge strategy; can be supplied more than
32
once to specify them in the order they should be tried.
git-merge.sh
+6
-2
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005 Junio C Hamano
4
#
5
6
-USAGE='[-n] [--summary] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
6
+USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
7
8
SUBDIRECTORY_OK=Yes
9
. git-sh-setup
@@ -128,8 +128,12 @@ parse_option () {
128
show_diffstat=t ;;
129
--sq|--squ|--squa|--squas|--squash)
130
squash=t no_commit=t ;;
131
+ --no-sq|--no-squ|--no-squa|--no-squas|--no-squash)
132
+ squash= no_commit= ;;
133
+ --c|--co|--com|--comm|--commi|--commit)
134
+ squash= no_commit= ;;
135
--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
132
- no_commit=t ;;
136
+ squash= no_commit=t ;;
137
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
138
--strateg=*|--strategy=*|\
139
-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
t/t7600-merge.sh
+22
@@ -395,4 +395,26 @@ test_expect_success 'override config option --summary' '
395
396
test_debug 'gitk --all'
397
398
+test_expect_success 'merge c1 with c2 (override --no-commit)' '
399
+ git reset --hard c1 &&
400
+ git config branch.master.mergeoptions "--no-commit" &&
401
+ test_tick &&
402
+ git merge --commit c2 &&
403
+ verify_merge file result.1-5 msg.1-5 &&
404
+ verify_parents $c1 $c2
405
+'
406
+
407
+test_debug 'gitk --all'
408
+
409
+test_expect_success 'merge c1 with c2 (override --squash)' '
410
+ git reset --hard c1 &&
411
+ git config branch.master.mergeoptions "--squash" &&
412
+ test_tick &&
413
+ git merge --no-squash c2 &&
414
+ verify_merge file result.1-5 msg.1-5 &&
415
+ verify_parents $c1 $c2
416
+'
417
+
418
+test_debug 'gitk --all'
419
+
420
test_done