]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7501-commit-basic-functionality.sh
t7501: add tests for --include and --only
[thirdparty/git.git] / t / t7501-commit-basic-functionality.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
4 #
5
6 # FIXME: Test the various index usages, test reflog,
7 # signoff
8
9 test_description='git commit'
10 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
11 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
12
13 . ./test-lib.sh
14 . "$TEST_DIRECTORY/lib-diff.sh"
15
16 author='The Real Author <someguy@his.email.org>'
17
18 test_tick
19
20 test_expect_success 'initial status' '
21 echo bongo bongo >file &&
22 git add file &&
23 git status >actual &&
24 test_grep "No commits yet" actual
25 '
26
27 test_expect_success 'fail initial amend' '
28 test_must_fail git commit --amend
29 '
30
31 test_expect_success 'setup: initial commit' '
32 git commit -m initial
33 '
34
35 test_expect_success '-m and -F do not mix' '
36 git checkout HEAD file && echo >>file && git add file &&
37 test_must_fail git commit -m foo -m bar -F file
38 '
39
40 test_expect_success '-m and -C do not mix' '
41 git checkout HEAD file && echo >>file && git add file &&
42 test_must_fail git commit -C HEAD -m illegal
43 '
44
45 test_expect_success 'paths and -a do not mix' '
46 echo King of the bongo >file &&
47 test_must_fail git commit -m foo -a file
48 '
49
50 test_expect_success PERL 'can use paths with --interactive' '
51 echo bong-o-bong >file &&
52 # 2: update, 1:st path, that is all, 7: quit
53 test_write_lines 2 1 "" 7 |
54 git commit -m foo --interactive file &&
55 git reset --hard HEAD^
56 '
57
58 test_expect_success 'removed files and relative paths' '
59 test_when_finished "rm -rf foo" &&
60 git init foo &&
61 >foo/foo.txt &&
62 git -C foo add foo.txt &&
63 git -C foo commit -m first &&
64 git -C foo rm foo.txt &&
65
66 mkdir -p foo/bar &&
67 git -C foo/bar commit -m second ../foo.txt
68 '
69
70 test_expect_success 'using invalid commit with -C' '
71 test_must_fail git commit --allow-empty -C bogus
72 '
73
74 test_expect_success 'nothing to commit' '
75 git reset --hard &&
76 test_must_fail git commit -m initial
77 '
78
79 test_expect_success '--dry-run fails with nothing to commit' '
80 test_must_fail git commit -m initial --dry-run
81 '
82
83 test_expect_success '--short fails with nothing to commit' '
84 test_must_fail git commit -m initial --short
85 '
86
87 test_expect_success '--porcelain fails with nothing to commit' '
88 test_must_fail git commit -m initial --porcelain
89 '
90
91 test_expect_success '--long fails with nothing to commit' '
92 test_must_fail git commit -m initial --long
93 '
94
95 test_expect_success 'fail to commit untracked file (even with --include/--only)' '
96 echo content >baz &&
97 error="error: pathspec .baz. did not match any file(s) known to git" &&
98
99 test_must_fail git commit -m "baz" baz 2>err &&
100 test_grep -e "$error" err &&
101
102 test_must_fail git commit --only -m "baz" baz 2>err &&
103 test_grep -e "$error" err &&
104
105 # TODO: as for --include, the below command will fail because
106 # nothing is staged. If something was staged, it would not fail
107 # even though the provided pathspec does not match any tracked
108 # path. (However, the untracked paths that match the pathspec are
109 # not committed and only the staged changes get committed.)
110 # In either cases, no error is returned to stderr like in (--only
111 # and without --only/--include) cases. In a similar manner,
112 # "git add -u baz" also does not error out.
113 #
114 # Therefore, the below test is just to document the current behavior
115 # and is not an endorsement to the current behavior, and we may
116 # want to fix this. And when that happens, this test should be
117 # updated accordingly.
118
119 test_must_fail git commit --include -m "baz" baz 2>err &&
120 test_must_be_empty err
121 '
122
123 test_expect_success 'setup: non-initial commit' '
124 echo bongo bongo bongo >file &&
125 git commit -m next -a
126 '
127
128 test_expect_success '--dry-run with stuff to commit returns ok' '
129 echo bongo bongo bongo >>file &&
130 git commit -m next -a --dry-run
131 '
132
133 test_expect_success '--short with stuff to commit returns ok' '
134 echo bongo bongo bongo >>file &&
135 git commit -m next -a --short
136 '
137
138 test_expect_success '--porcelain with stuff to commit returns ok' '
139 echo bongo bongo bongo >>file &&
140 git commit -m next -a --porcelain
141 '
142
143 test_expect_success '--long with stuff to commit returns ok' '
144 echo bongo bongo bongo >>file &&
145 git commit -m next -a --long
146 '
147
148 for opt in "" "-o" "--only"
149 do
150 test_expect_success 'exclude additional staged changes when given pathspec' '
151 echo content >>file &&
152 echo content >>baz &&
153 git add baz &&
154 git commit $opt -m "file" file &&
155
156 git diff --name-only >actual &&
157 test_must_be_empty actual &&
158
159 test_write_lines baz >expect &&
160 git diff --name-only --cached >actual &&
161 test_cmp expect actual &&
162
163 test_write_lines file >expect &&
164 git diff --name-only HEAD^ HEAD >actual &&
165 test_cmp expect actual
166 '
167 done
168
169 test_expect_success '-i/--include includes staged changes' '
170 echo content >>file &&
171 echo content >>baz &&
172 git add file &&
173
174 # baz is in the index, therefore, it will be committed
175 git commit --include -m "file and baz" baz &&
176
177 git diff --name-only HEAD >remaining &&
178 test_must_be_empty remaining &&
179
180 test_write_lines baz file >expect &&
181 git diff --name-only HEAD^ HEAD >actual &&
182 test_cmp expect actual
183 '
184
185 test_expect_success '--include and --only do not mix' '
186 test_when_finished "git reset --hard" &&
187 echo content >>file &&
188 echo content >>baz &&
189 test_must_fail git commit --include --only -m "file baz" file baz 2>actual &&
190 test_grep -e "fatal: options .-i/--include. and .-o/--only. cannot be used together" actual
191 '
192
193 test_expect_success 'commit message from non-existing file' '
194 echo more bongo: bongo bongo bongo bongo >file &&
195 test_must_fail git commit -F gah -a
196 '
197
198 test_expect_success 'empty commit message' '
199 # Empty except stray tabs and spaces on a few lines.
200 sed -e "s/@//g" >msg <<-\EOF &&
201 @ @
202 @@
203 @ @
204 @Signed-off-by: hula@
205 EOF
206 test_must_fail git commit -F msg -a
207 '
208
209 test_expect_success 'template "emptyness" check does not kick in with -F' '
210 git checkout HEAD file && echo >>file && git add file &&
211 git commit -t file -F file
212 '
213
214 test_expect_success 'template "emptyness" check' '
215 git checkout HEAD file && echo >>file && git add file &&
216 test_must_fail git commit -t file 2>err &&
217 test_grep "did not edit" err
218 '
219
220 test_expect_success 'setup: commit message from file' '
221 git checkout HEAD file && echo >>file && git add file &&
222 echo this is the commit message, coming from a file >msg &&
223 git commit -F msg -a
224 '
225
226 test_expect_success 'amend commit' '
227 cat >editor <<-\EOF &&
228 #!/bin/sh
229 sed -e "s/a file/an amend commit/g" <"$1" >"$1-"
230 mv "$1-" "$1"
231 EOF
232 chmod 755 editor &&
233 EDITOR=./editor git commit --amend
234 '
235
236 test_expect_success 'amend --only ignores staged contents' '
237 cp file file.expect &&
238 echo changed >file &&
239 git add file &&
240 git commit --no-edit --amend --only &&
241 git cat-file blob HEAD:file >file.actual &&
242 test_cmp file.expect file.actual &&
243 git diff --exit-code
244 '
245
246 test_expect_success 'allow-empty --only ignores staged contents' '
247 echo changed-again >file &&
248 git add file &&
249 git commit --allow-empty --only -m "empty" &&
250 git cat-file blob HEAD:file >file.actual &&
251 test_cmp file.expect file.actual &&
252 git diff --exit-code
253 '
254
255 test_expect_success 'set up editor' '
256 cat >editor <<-\EOF &&
257 #!/bin/sh
258 sed -e "s/unamended/amended/g" <"$1" >"$1-"
259 mv "$1-" "$1"
260 EOF
261 chmod 755 editor
262 '
263
264 test_expect_success 'amend without launching editor' '
265 echo unamended >expect &&
266 git commit --allow-empty -m "unamended" &&
267 echo needs more bongo >file &&
268 git add file &&
269 EDITOR=./editor git commit --no-edit --amend &&
270 git diff --exit-code HEAD -- file &&
271 git diff-tree -s --format=%s HEAD >msg &&
272 test_cmp expect msg
273 '
274
275 test_expect_success '--amend --edit' '
276 echo amended >expect &&
277 git commit --allow-empty -m "unamended" &&
278 echo bongo again >file &&
279 git add file &&
280 EDITOR=./editor git commit --edit --amend &&
281 git diff-tree -s --format=%s HEAD >msg &&
282 test_cmp expect msg
283 '
284
285 test_expect_success '--amend --edit of empty message' '
286 cat >replace <<-\EOF &&
287 #!/bin/sh
288 echo "amended" >"$1"
289 EOF
290 chmod 755 replace &&
291 git commit --allow-empty --allow-empty-message -m "" &&
292 echo more bongo >file &&
293 git add file &&
294 EDITOR=./replace git commit --edit --amend &&
295 git diff-tree -s --format=%s HEAD >msg &&
296 ./replace expect &&
297 test_cmp expect msg
298 '
299
300 test_expect_success '--amend to set message to empty' '
301 echo bata >file &&
302 git add file &&
303 git commit -m "unamended" &&
304 git commit --amend --allow-empty-message -m "" &&
305 git diff-tree -s --format=%s HEAD >msg &&
306 echo "" >expect &&
307 test_cmp expect msg
308 '
309
310 test_expect_success '--amend to set empty message needs --allow-empty-message' '
311 echo conga >file &&
312 git add file &&
313 git commit -m "unamended" &&
314 test_must_fail git commit --amend -m "" &&
315 git diff-tree -s --format=%s HEAD >msg &&
316 echo "unamended" >expect &&
317 test_cmp expect msg
318 '
319
320 test_expect_success '-m --edit' '
321 echo amended >expect &&
322 git commit --allow-empty -m buffer &&
323 echo bongo bongo >file &&
324 git add file &&
325 EDITOR=./editor git commit -m unamended --edit &&
326 git diff-tree -s --format=%s HEAD >msg &&
327 test_cmp expect msg
328 '
329
330 test_expect_success '-m and -F do not mix' '
331 echo enough with the bongos >file &&
332 test_must_fail git commit -F msg -m amending .
333 '
334
335 test_expect_success 'using message from other commit' '
336 git commit -C HEAD^ .
337 '
338
339 test_expect_success 'editing message from other commit' '
340 cat >editor <<-\EOF &&
341 #!/bin/sh
342 sed -e "s/amend/older/g" <"$1" >"$1-"
343 mv "$1-" "$1"
344 EOF
345 chmod 755 editor &&
346 echo hula hula >file &&
347 EDITOR=./editor git commit -c HEAD^ -a
348 '
349
350 test_expect_success 'message from stdin' '
351 echo silly new contents >file &&
352 echo commit message from stdin |
353 git commit -F - -a
354 '
355
356 test_expect_success 'overriding author from command line' '
357 echo gak >file &&
358 git commit -m author \
359 --author "Rubber Duck <rduck@convoy.org>" -a >output 2>&1 &&
360 grep Rubber.Duck output
361 '
362
363 test_expect_success PERL 'interactive add' '
364 echo 7 | test_must_fail git commit --interactive >out &&
365 grep "What now" out
366 '
367
368 test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
369 echo zoo >file &&
370 test_must_fail git diff --exit-code >diff1 &&
371 test_write_lines u "*" q |
372 (
373 EDITOR=: &&
374 export EDITOR &&
375 test_must_fail git commit --interactive
376 ) &&
377 git diff >diff2 &&
378 compare_diff_patch diff1 diff2
379 '
380
381 test_expect_success 'editor not invoked if -F is given' '
382 cat >editor <<-\EOF &&
383 #!/bin/sh
384 sed -e s/good/bad/g <"$1" >"$1-"
385 mv "$1-" "$1"
386 EOF
387 chmod 755 editor &&
388
389 echo A good commit message. >msg &&
390 echo moo >file &&
391
392 EDITOR=./editor git commit -a -F msg &&
393 git show -s --pretty=format:%s >subject &&
394 grep -q good subject &&
395
396 echo quack >file &&
397 echo Another good message. |
398 EDITOR=./editor git commit -a -F - &&
399 git show -s --pretty=format:%s >subject &&
400 grep -q good subject
401 '
402
403 test_expect_success 'partial commit that involves removal (1)' '
404
405 git rm --cached file &&
406 mv file elif &&
407 git add elif &&
408 git commit -m "Partial: add elif" elif &&
409 git diff-tree --name-status HEAD^ HEAD >current &&
410 echo "A elif" >expected &&
411 test_cmp expected current
412
413 '
414
415 test_expect_success 'partial commit that involves removal (2)' '
416
417 git commit -m "Partial: remove file" file &&
418 git diff-tree --name-status HEAD^ HEAD >current &&
419 echo "D file" >expected &&
420 test_cmp expected current
421
422 '
423
424 test_expect_success 'partial commit that involves removal (3)' '
425
426 git rm --cached elif &&
427 echo elif >elif &&
428 git commit -m "Partial: modify elif" elif &&
429 git diff-tree --name-status HEAD^ HEAD >current &&
430 echo "M elif" >expected &&
431 test_cmp expected current
432
433 '
434
435 test_expect_success 'amend commit to fix author' '
436
437 oldtick=$GIT_AUTHOR_DATE &&
438 test_tick &&
439 git reset --hard &&
440 git cat-file -p HEAD >commit &&
441 sed -e "s/author.*/author $author $oldtick/" \
442 -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
443 commit >expected &&
444 git commit --amend --author="$author" &&
445 git cat-file -p HEAD >current &&
446 test_cmp expected current
447
448 '
449
450 test_expect_success 'amend commit to fix date' '
451
452 test_tick &&
453 newtick=$GIT_AUTHOR_DATE &&
454 git reset --hard &&
455 git cat-file -p HEAD >commit &&
456 sed -e "s/author.*/author $author $newtick/" \
457 -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
458 commit >expected &&
459 git commit --amend --date="$newtick" &&
460 git cat-file -p HEAD >current &&
461 test_cmp expected current
462
463 '
464
465 test_expect_success 'commit mentions forced date in output' '
466 git commit --amend --date=2010-01-02T03:04:05 >output &&
467 grep "Date: *Sat Jan 2 03:04:05 2010" output
468 '
469
470 test_expect_success 'commit complains about completely bogus dates' '
471 test_must_fail git commit --amend --date=seventeen
472 '
473
474 test_expect_success 'commit --date allows approxidate' '
475 git commit --amend \
476 --date="midnight the 12th of october, anno domini 1979" &&
477 echo "Fri Oct 12 00:00:00 1979 +0000" >expect &&
478 git log -1 --format=%ad >actual &&
479 test_cmp expect actual
480 '
481
482 test_expect_success 'sign off (1)' '
483
484 echo 1 >positive &&
485 git add positive &&
486 git commit -s -m "thank you" &&
487 git cat-file commit HEAD >commit &&
488 sed -e "1,/^\$/d" commit >actual &&
489 (
490 echo thank you &&
491 echo &&
492 git var GIT_COMMITTER_IDENT >ident &&
493 sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
494 ) >expected &&
495 test_cmp expected actual
496
497 '
498
499 test_expect_success 'sign off (2)' '
500
501 echo 2 >positive &&
502 git add positive &&
503 existing="Signed-off-by: Watch This <watchthis@example.com>" &&
504 git commit -s -m "thank you
505
506 $existing" &&
507 git cat-file commit HEAD >commit &&
508 sed -e "1,/^\$/d" commit >actual &&
509 (
510 echo thank you &&
511 echo &&
512 echo $existing &&
513 git var GIT_COMMITTER_IDENT >ident &&
514 sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
515 ) >expected &&
516 test_cmp expected actual
517
518 '
519
520 test_expect_success 'signoff gap' '
521
522 echo 3 >positive &&
523 git add positive &&
524 alt="Alt-RFC-822-Header: Value" &&
525 git commit -s -m "welcome
526
527 $alt" &&
528 git cat-file commit HEAD >commit &&
529 sed -e "1,/^\$/d" commit >actual &&
530 (
531 echo welcome &&
532 echo &&
533 echo $alt &&
534 git var GIT_COMMITTER_IDENT >ident &&
535 sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
536 ) >expected &&
537 test_cmp expected actual
538 '
539
540 test_expect_success 'signoff gap 2' '
541
542 echo 4 >positive &&
543 git add positive &&
544 alt="fixed: 34" &&
545 git commit -s -m "welcome
546
547 We have now
548 $alt" &&
549 git cat-file commit HEAD >commit &&
550 sed -e "1,/^\$/d" commit >actual &&
551 (
552 echo welcome &&
553 echo &&
554 echo We have now &&
555 echo $alt &&
556 echo &&
557 git var GIT_COMMITTER_IDENT >ident &&
558 sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
559 ) >expected &&
560 test_cmp expected actual
561 '
562
563 test_expect_success 'signoff respects trailer config' '
564
565 echo 5 >positive &&
566 git add positive &&
567 git commit -s -m "subject
568
569 non-trailer line
570 Myfooter: x" &&
571 git cat-file commit HEAD >commit &&
572 sed -e "1,/^\$/d" commit >actual &&
573 (
574 echo subject &&
575 echo &&
576 echo non-trailer line &&
577 echo Myfooter: x &&
578 echo &&
579 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
580 ) >expected &&
581 test_cmp expected actual &&
582
583 echo 6 >positive &&
584 git add positive &&
585 git -c "trailer.Myfooter.ifexists=add" commit -s -m "subject
586
587 non-trailer line
588 Myfooter: x" &&
589 git cat-file commit HEAD >commit &&
590 sed -e "1,/^\$/d" commit >actual &&
591 (
592 echo subject &&
593 echo &&
594 echo non-trailer line &&
595 echo Myfooter: x &&
596 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
597 ) >expected &&
598 test_cmp expected actual
599 '
600
601 test_expect_success 'signoff not confused by ---' '
602 cat >expected <<-EOF &&
603 subject
604
605 body
606 ---
607 these dashes confuse the parser!
608
609 Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
610 EOF
611 # should be a noop, since we already signed
612 git commit --allow-empty --signoff -F expected &&
613 git log -1 --pretty=format:%B >actual &&
614 test_cmp expected actual
615 '
616
617 test_expect_success 'multiple -m' '
618
619 >negative &&
620 git add negative &&
621 git commit -m "one" -m "two" -m "three" &&
622 git cat-file commit HEAD >commit &&
623 sed -e "1,/^\$/d" commit >actual &&
624 (
625 echo one &&
626 echo &&
627 echo two &&
628 echo &&
629 echo three
630 ) >expected &&
631 test_cmp expected actual
632
633 '
634
635 test_expect_success 'amend commit to fix author' '
636
637 oldtick=$GIT_AUTHOR_DATE &&
638 test_tick &&
639 git reset --hard &&
640 git cat-file -p HEAD >commit &&
641 sed -e "s/author.*/author $author $oldtick/" \
642 -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
643 commit >expected &&
644 git commit --amend --author="$author" &&
645 git cat-file -p HEAD >current &&
646 test_cmp expected current
647
648 '
649
650 test_expect_success 'git commit <file> with dirty index' '
651 echo tacocat >elif &&
652 echo tehlulz >chz &&
653 git add chz &&
654 git commit elif -m "tacocat is a palindrome" &&
655 git show --stat >stat &&
656 grep elif stat &&
657 git diff --cached >diff &&
658 grep chz diff
659 '
660
661 test_expect_success 'same tree (single parent)' '
662
663 git reset --hard &&
664 test_must_fail git commit -m empty
665
666 '
667
668 test_expect_success 'same tree (single parent) --allow-empty' '
669
670 git commit --allow-empty -m "forced empty" &&
671 git cat-file commit HEAD >commit &&
672 grep forced commit
673
674 '
675
676 test_expect_success 'same tree (merge and amend merge)' '
677
678 git checkout -b side HEAD^ &&
679 echo zero >zero &&
680 git add zero &&
681 git commit -m "add zero" &&
682 git checkout main &&
683
684 git merge -s ours side -m "empty ok" &&
685 git diff HEAD^ HEAD >actual &&
686 test_must_be_empty actual &&
687
688 git commit --amend -m "empty really ok" &&
689 git diff HEAD^ HEAD >actual &&
690 test_must_be_empty actual
691
692 '
693
694 test_expect_success 'amend using the message from another commit' '
695
696 git reset --hard &&
697 test_tick &&
698 git commit --allow-empty -m "old commit" &&
699 old=$(git rev-parse --verify HEAD) &&
700 test_tick &&
701 git commit --allow-empty -m "new commit" &&
702 new=$(git rev-parse --verify HEAD) &&
703 test_tick &&
704 git commit --allow-empty --amend -C "$old" &&
705 git show --pretty="format:%ad %s" "$old" >expected &&
706 git show --pretty="format:%ad %s" HEAD >actual &&
707 test_cmp expected actual
708
709 '
710
711 test_expect_success 'amend using the message from a commit named with tag' '
712
713 git reset --hard &&
714 test_tick &&
715 git commit --allow-empty -m "old commit" &&
716 old=$(git rev-parse --verify HEAD) &&
717 git tag -a -m "tag on old" tagged-old HEAD &&
718 test_tick &&
719 git commit --allow-empty -m "new commit" &&
720 new=$(git rev-parse --verify HEAD) &&
721 test_tick &&
722 git commit --allow-empty --amend -C tagged-old &&
723 git show --pretty="format:%ad %s" "$old" >expected &&
724 git show --pretty="format:%ad %s" HEAD >actual &&
725 test_cmp expected actual
726
727 '
728
729 test_expect_success 'amend can copy notes' '
730
731 git config notes.rewrite.amend true &&
732 git config notes.rewriteRef "refs/notes/*" &&
733 test_commit foo &&
734 git notes add -m"a note" &&
735 test_tick &&
736 git commit --amend -m"new foo" &&
737 test "$(git notes show)" = "a note"
738
739 '
740
741 test_expect_success 'commit a file whose name is a dash' '
742 git reset --hard &&
743 test_write_lines 1 2 3 4 5 >./- &&
744 git add ./- &&
745 test_tick &&
746 git commit -m "add dash" >output </dev/null &&
747 test_grep " changed, 5 insertions" output
748 '
749
750 test_expect_success '--only works on to-be-born branch' '
751 # This test relies on having something in the index, as it
752 # would not otherwise actually prove much. So check this.
753 test -n "$(git ls-files)" &&
754 git checkout --orphan orphan &&
755 echo foo >newfile &&
756 git add newfile &&
757 git commit --only newfile -m"--only on unborn branch" &&
758 echo newfile >expected &&
759 git ls-tree -r --name-only HEAD >actual &&
760 test_cmp expected actual
761 '
762
763 test_expect_success '--dry-run with conflicts fixed from a merge' '
764 # setup two branches with conflicting information
765 # in the same file, resolve the conflict,
766 # call commit with --dry-run
767 echo "Initial contents, unimportant" >test-file &&
768 git add test-file &&
769 git commit -m "Initial commit" &&
770 echo "commit-1-state" >test-file &&
771 git commit -m "commit 1" -i test-file &&
772 git tag commit-1 &&
773 git checkout -b branch-2 HEAD^1 &&
774 echo "commit-2-state" >test-file &&
775 git commit -m "commit 2" -i test-file &&
776 test_must_fail git merge --no-commit commit-1 &&
777 echo "commit-2-state" >test-file &&
778 git add test-file &&
779 git commit --dry-run &&
780 git commit -m "conflicts fixed from merge."
781 '
782
783 test_expect_success '--dry-run --short' '
784 >test-file &&
785 git add test-file &&
786 git commit --dry-run --short
787 '
788
789 test_done