]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'pn/commit-autosquash'
authorJunio C Hamano <gitster@pobox.com>
Sat, 4 Dec 2010 00:13:06 +0000 (16:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 4 Dec 2010 00:13:06 +0000 (16:13 -0800)
* pn/commit-autosquash:
  add tests of commit --squash
  commit: --squash option for use with rebase --autosquash
  add tests of commit --fixup
  commit: --fixup option for use with rebase --autosquash
  pretty.c: teach format_commit_message() to reencode the output
  commit: helper methods to reduce redundant blocks of code

Conflicts:
Documentation/git-commit.txt
t/t3415-rebase-autosquash.sh

1  2 
Documentation/git-commit.txt
builtin/commit.c
builtin/log.c
cache.h
commit.c
environment.c
t/t3415-rebase-autosquash.sh

index ec7b577b85ae5a320b1006380f5abd03946ba44b,6e4c220f205a8f4dd29527acf7b637c0e855239b..b586c0f442afd33c2875af26b83bb261de7361b0
@@@ -9,10 -9,10 +9,10 @@@ SYNOPSI
  --------
  [verse]
  'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
-          [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
-          [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
-          [--date=<date>] [--cleanup=<mode>] [--status | --no-status]
-          [-i | -o] [--] [<file>...]
+          [(-c | -C | --fixup | --squash) <commit>] [-F <file> | -m <msg>]
+          [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify]
+          [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>]
 -         [--status | --no-status] [--] [[-i | -o ]<file>...]
++         [--status | --no-status] [-i | -o] [--] [<file>...]
  
  DESCRIPTION
  -----------
Simple merge
diff --cc builtin/log.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc commit.c
Simple merge
diff --cc environment.c
Simple merge
index ca16b70373b5595f4a5e3c460638c7aa2edb8663,0028533e0bfb544598ca6dc0de489bf9948b4eb4..b38be8e93723991d717b6b7fb690560efb58c36d
@@@ -94,78 -95,28 +95,102 @@@ test_expect_success 'misspelled auto sq
        test 0 = $(git rev-list final-missquash...HEAD | wc -l)
  '
  
 +test_expect_success 'auto squash that matches 2 commits' '
 +      git reset --hard base &&
 +      echo 4 >file4 &&
 +      git add file4 &&
 +      test_tick &&
 +      git commit -m "first new commit" &&
 +      echo 1 >file1 &&
 +      git add -u &&
 +      test_tick &&
 +      git commit -m "squash! first" &&
 +      git tag final-multisquash &&
 +      test_tick &&
 +      git rebase --autosquash -i HEAD~4 &&
 +      git log --oneline >actual &&
 +      test 4 = $(wc -l <actual) &&
 +      git diff --exit-code final-multisquash &&
 +      test 1 = "$(git cat-file blob HEAD^^:file1)" &&
 +      test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
 +      test 1 = $(git cat-file commit HEAD | grep first | wc -l)
 +'
 +
 +test_expect_success 'auto squash that matches a commit after the squash' '
 +      git reset --hard base &&
 +      echo 1 >file1 &&
 +      git add -u &&
 +      test_tick &&
 +      git commit -m "squash! third" &&
 +      echo 4 >file4 &&
 +      git add file4 &&
 +      test_tick &&
 +      git commit -m "third commit" &&
 +      git tag final-presquash &&
 +      test_tick &&
 +      git rebase --autosquash -i HEAD~4 &&
 +      git log --oneline >actual &&
 +      test 5 = $(wc -l <actual) &&
 +      git diff --exit-code final-presquash &&
 +      test 0 = "$(git cat-file blob HEAD^^:file1)" &&
 +      test 1 = "$(git cat-file blob HEAD^:file1)" &&
 +      test 1 = $(git cat-file commit HEAD | grep third | wc -l) &&
 +      test 1 = $(git cat-file commit HEAD^ | grep third | wc -l)
 +'
 +test_expect_success 'auto squash that matches a sha1' '
 +      git reset --hard base &&
 +      echo 1 >file1 &&
 +      git add -u &&
 +      test_tick &&
 +      git commit -m "squash! $(git rev-parse --short HEAD^)" &&
 +      git tag final-shasquash &&
 +      test_tick &&
 +      git rebase --autosquash -i HEAD^^^ &&
 +      git log --oneline >actual &&
 +      test 3 = $(wc -l <actual) &&
 +      git diff --exit-code final-shasquash &&
 +      test 1 = "$(git cat-file blob HEAD^:file1)" &&
 +      test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 +'
 +
 +test_expect_success 'auto squash that matches longer sha1' '
 +      git reset --hard base &&
 +      echo 1 >file1 &&
 +      git add -u &&
 +      test_tick &&
 +      git commit -m "squash! $(git rev-parse --short=11 HEAD^)" &&
 +      git tag final-longshasquash &&
 +      test_tick &&
 +      git rebase --autosquash -i HEAD^^^ &&
 +      git log --oneline >actual &&
 +      test 3 = $(wc -l <actual) &&
 +      git diff --exit-code final-longshasquash &&
 +      test 1 = "$(git cat-file blob HEAD^:file1)" &&
 +      test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 +'
 +
+ test_auto_commit_flags () {
+       git reset --hard base &&
+       echo 1 >file1 &&
+       git add -u &&
+       test_tick &&
+       git commit --$1 first-commit &&
+       git tag final-commit-$1 &&
+       test_tick &&
+       git rebase --autosquash -i HEAD^^^ &&
+       git log --oneline >actual &&
+       test 3 = $(wc -l <actual) &&
+       git diff --exit-code final-commit-$1 &&
+       test 1 = "$(git cat-file blob HEAD^:file1)" &&
+       test $2 = $(git cat-file commit HEAD^ | grep first | wc -l)
+ }
+ test_expect_success 'use commit --fixup' '
+       test_auto_commit_flags fixup 1
+ '
+ test_expect_success 'use commit --squash' '
+       test_auto_commit_flags squash 2
+ '
  test_done