From ec8a896eb54f326f65b4103307a50475424d9a03 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 6 Mar 2015 10:43:33 +0100 Subject: t7508: .gitignore 'expect' and 'output' files These files are used to observe the behaviour of the 'status' command and if there weren't any such observer, the expected output from 'status' wouldn't even mention them. Place them in .gitignore to unclutter the output expected by the tests. An added benefit is that future tests can add such files that are purely for use by the observer, i.e. the tests themselves, by naming them as expect-foo and/or output-bar. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7508-status.sh | 78 ++++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 65 deletions(-) (limited to 't/t7508-status.sh') diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 8ed5788808..514df671c9 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -66,6 +66,12 @@ strip_comments () { rm "$1" && mv "$1".tmp "$1" } +cat >.gitignore <<\EOF +.gitignore +expect* +output* +EOF + test_expect_success 'status --column' ' cat >expect <<\EOF && # On branch master @@ -83,8 +89,8 @@ test_expect_success 'status --column' ' # Untracked files: # (use "git add ..." to include in what will be committed) # -# dir1/untracked dir2/untracked output -# dir2/modified expect untracked +# dir1/untracked dir2/untracked +# dir2/modified untracked # EOF COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && @@ -116,8 +122,6 @@ cat >expect <<\EOF # dir1/untracked # dir2/modified # dir2/untracked -# expect -# output # untracked # EOF @@ -167,8 +171,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -186,8 +188,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -320,7 +320,11 @@ EOF test_i18ncmp expect output ' -rm -f .gitignore +cat >.gitignore <<\EOF +.gitignore +expect* +output* +EOF cat >expect <<\EOF ## master @@ -329,8 +333,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -434,8 +436,6 @@ Untracked files: dir2/modified dir2/untracked dir3/ - expect - output untracked EOF @@ -456,8 +456,6 @@ A dir2/added ?? dir2/modified ?? dir2/untracked ?? dir3/ -?? expect -?? output ?? untracked EOF test_expect_success 'status -s -unormal' ' @@ -493,8 +491,6 @@ Untracked files: dir2/untracked dir3/untracked1 dir3/untracked2 - expect - output untracked EOF @@ -518,8 +514,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s -uall' ' @@ -554,8 +548,6 @@ Untracked files: untracked ../dir2/modified ../dir2/untracked - ../expect - ../output ../untracked EOF @@ -569,8 +561,6 @@ A ../dir2/added ?? untracked ?? ../dir2/modified ?? ../dir2/untracked -?? ../expect -?? ../output ?? ../untracked EOF test_expect_success 'status -s with relative paths' ' @@ -586,8 +576,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -625,8 +613,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -647,8 +633,6 @@ cat >expect <<\EOF ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -676,8 +660,6 @@ cat >expect <<\EOF ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -694,8 +676,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -755,8 +735,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -772,8 +750,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -798,8 +774,6 @@ Untracked files: dir1/untracked dir2/ - expect - output untracked EOF @@ -848,8 +822,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -870,8 +842,6 @@ A sm ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s submodule summary is disabled by default' ' @@ -913,8 +883,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -940,8 +908,6 @@ A sm ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s submodule summary' ' @@ -964,8 +930,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked no changes added to commit (use "git add" and/or "git commit -a") @@ -983,8 +947,6 @@ cat >expect < expect << EOF ; dir1/untracked ; dir2/modified ; dir2/untracked -; expect -; output ; untracked ; EOF @@ -1369,8 +1321,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked no changes added to commit (use "git add" and/or "git commit -a") @@ -1400,8 +1350,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF -- cgit v1.2.3 From f8c65c1f97b364a8e90267e66193cf20aa60ca6e Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 6 Mar 2015 10:43:34 +0100 Subject: t7508: test git status -v "status -v" had no test. Include one. This also requires changing the .gitignore subtests, which is a good thing: they include testing a .gitignore pattern now. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7508-status.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 't/t7508-status.sh') diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 514df671c9..e3c9cf9c10 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -137,6 +137,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' ' test_i18ncmp expect output ' +test_expect_success 'status -v' ' + (cat expect && git diff --cached) >expect-with-v && + git status -v >output && + test_i18ncmp expect-with-v output +' + test_expect_success 'setup fake editor' ' cat >.git/editor <<-\EOF && #! /bin/sh @@ -201,7 +207,7 @@ test_expect_success 'status -s' ' test_expect_success 'status with gitignore' ' { echo ".gitignore" && - echo "expect" && + echo "expect*" && echo "output" && echo "untracked" } >.gitignore && @@ -222,6 +228,7 @@ test_expect_success 'status with gitignore' ' !! dir1/untracked !! dir2/untracked !! expect + !! expect-with-v !! output !! untracked EOF @@ -253,6 +260,7 @@ Ignored files: dir1/untracked dir2/untracked expect + expect-with-v output untracked @@ -264,7 +272,7 @@ EOF test_expect_success 'status with gitignore (nothing untracked)' ' { echo ".gitignore" && - echo "expect" && + echo "expect*" && echo "dir2/modified" && echo "output" && echo "untracked" @@ -285,6 +293,7 @@ test_expect_success 'status with gitignore (nothing untracked)' ' !! dir2/modified !! dir2/untracked !! expect + !! expect-with-v !! output !! untracked EOF @@ -312,6 +321,7 @@ Ignored files: dir2/modified dir2/untracked expect + expect-with-v output untracked -- cgit v1.2.3 From 40555000935147f56896e75b919b25f1f2d23aca Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 6 Mar 2015 10:43:35 +0100 Subject: commit/status: show the index-worktree diff with -v -v git commit and git status in long format show the diff between HEAD and the index when given -v. This allows previewing a commit to be made. They also list tracked files with unstaged changes, but without a diff. Introduce '-v -v' which shows the diff between the index and the worktree in addition to the HEAD index diff. This allows a review of unstaged changes which might be missing from the commit. In the case of '-v -v', additonal header lines Changes to be committed: and Changes not staged for commit: are inserted before the diffs, which are equal to those in the status part; the latter preceded by 50*"-" to make it stick out more. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7508-status.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t7508-status.sh') diff --git a/t/t7508-status.sh b/t/t7508-status.sh index e3c9cf9c10..6b16bcb640 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -143,6 +143,17 @@ test_expect_success 'status -v' ' test_i18ncmp expect-with-v output ' +test_expect_success 'status -v -v' ' + (cat expect && + echo "Changes to be committed:" && + git -c diff.mnemonicprefix=true diff --cached && + echo "--------------------------------------------------" && + echo "Changes not staged for commit:" && + git -c diff.mnemonicprefix=true diff) >expect-with-v && + git status -v -v >output && + test_i18ncmp expect-with-v output +' + test_expect_success 'setup fake editor' ' cat >.git/editor <<-\EOF && #! /bin/sh -- cgit v1.2.3