@matheusbsbs / matheus-bagliano / commits / dd1e5b313a
Fork 0

add configuration variable for --autosquash option of interactive rebase

If you use this feature regularly you can now enable it by default. In case the user wants to override this config on the commandline --no-autosquash can be used to force disabling. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Heiko Voigt committed Jul 14, 2010 at 13:59 UTC dd1e5b313a0aef5d22cd9909c14e4b1b6dcbea79
4 files changed +47 -8
Documentation/config.txt
+3
@@ -1533,6 +1533,9 @@ rebase.stat::
1533 Whether to show a diffstat of what changed upstream since the last
1534 rebase. False by default.
1535
1536 +rebase.autosquash::
1537 + If set to true enable '--autosquash' option by default.
1538 +
1539 receive.autogc::
1540 By default, git-receive-pack will run "git-gc --auto" after
1541 receiving data from git-push and updating refs. You can stop
Documentation/git-rebase.txt
+8
@@ -199,6 +199,9 @@ rebase.stat::
199 Whether to show a diffstat of what changed upstream since the last
200 rebase. False by default.
201
202 +rebase.autosquash::
203 + If set to true enable '--autosquash' option by default.
204 +
205 OPTIONS
206 -------
207 <newbase>::
@@ -326,6 +329,7 @@ idea unless you know what you are doing (see BUGS below).
329 instead.
330
331 --autosquash::
332 +--no-autosquash::
333 When the commit log message begins with "squash! ..." (or
334 "fixup! ..."), and there is a commit whose title begins with
335 the same ..., automatically modify the todo list of rebase -i
@@ -334,6 +338,10 @@ idea unless you know what you are doing (see BUGS below).
338 commit from `pick` to `squash` (or `fixup`).
339 +
340 This option is only valid when the '--interactive' option is used.
341 ++
342 +If the '--autosquash' option is enabled by default using the
343 +configuration variable `rebase.autosquash`, this option can be
344 +used to override and disable this setting.
345
346 --no-ff::
347 With --interactive, cherry-pick all rebased commits instead of
git-rebase--interactive.sh
+4
@@ -111,6 +111,7 @@ VERBOSE=
111 OK_TO_SKIP_PRE_REBASE=
112 REBASE_ROOT=
113 AUTOSQUASH=
114 +test "$(git config --bool rebase.autosquash)" = "true" && AUTOSQUASH=t
115 NEVER_FF=
116
117 GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
@@ -795,6 +796,9 @@ first and then run 'git rebase --continue' again."
796 --autosquash)
797 AUTOSQUASH=t
798 ;;
799 + --no-autosquash)
800 + AUTOSQUASH=
801 + ;;
802 --onto)
803 shift
804 ONTO=$(parse_onto "$1") ||
t/t3415-rebase-autosquash.sh
+32 -8
@@ -21,38 +21,62 @@ test_expect_success setup '
21 git tag base
22 '
23
24 -test_expect_success 'auto fixup' '
24 +test_auto_fixup() {
25 git reset --hard base &&
26 echo 1 >file1 &&
27 git add -u &&
28 test_tick &&
29 git commit -m "fixup! first"
30
31 - git tag final-fixup &&
31 + git tag $1 &&
32 test_tick &&
33 - git rebase --autosquash -i HEAD^^^ &&
33 + git rebase $2 -i HEAD^^^ &&
34 git log --oneline >actual &&
35 test 3 = $(wc -l <actual) &&
36 - git diff --exit-code final-fixup &&
36 + git diff --exit-code $1 &&
37 test 1 = "$(git cat-file blob HEAD^:file1)" &&
38 test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
39 +}
40 +
41 +test_expect_success 'auto fixup (option)' '
42 + test_auto_fixup final-fixup-option --autosquash
43 +'
44 +
45 +test_expect_success 'auto fixup (config)' '
46 + git config rebase.autosquash true &&
47 + test_auto_fixup final-fixup-config-true &&
48 + test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash &&
49 + git config rebase.autosquash false &&
50 + test_must_fail test_auto_fixup final-fixup-config-false
51 '
52
41 -test_expect_success 'auto squash' '
53 +test_auto_squash() {
54 git reset --hard base &&
55 echo 1 >file1 &&
56 git add -u &&
57 test_tick &&
58 git commit -m "squash! first"
59
48 - git tag final-squash &&
60 + git tag $1 &&
61 test_tick &&
50 - git rebase --autosquash -i HEAD^^^ &&
62 + git rebase $2 -i HEAD^^^ &&
63 git log --oneline >actual &&
64 test 3 = $(wc -l <actual) &&
53 - git diff --exit-code final-squash &&
65 + git diff --exit-code $1 &&
66 test 1 = "$(git cat-file blob HEAD^:file1)" &&
67 test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
68 +}
69 +
70 +test_expect_success 'auto squash (option)' '
71 + test_auto_squash final-squash --autosquash
72 +'
73 +
74 +test_expect_success 'auto squash (config)' '
75 + git config rebase.autosquash true &&
76 + test_auto_squash final-squash-config-true &&
77 + test_must_fail test_auto_squash squash-config-true-no --no-autosquash &&
78 + git config rebase.autosquash false &&
79 + test_must_fail test_auto_squash final-squash-config-false
80 '
81
82 test_expect_success 'misspelled auto squash' '