summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2013-09-06 17:43:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-09-06 20:33:18 (GMT)
commit2556b9962e7c0353d562b7bf70eed11d8f29d0b0 (patch)
tree7f1e9ca52eac054c468bd7ab54e8be32940907a5 /t
parent3ba7407b8b7b7a75f720641327207d6cfdb163a2 (diff)
downloadgit-2556b9962e7c0353d562b7bf70eed11d8f29d0b0.zip
git-2556b9962e7c0353d562b7bf70eed11d8f29d0b0.tar.gz
git-2556b9962e7c0353d562b7bf70eed11d8f29d0b0.tar.bz2
status: disable display of '#' comment prefix by default
Historically, "git status" needed to prefix each output line with '#' so that the output could be added as comment to the commit message. This prefix comment has no real purpose when "git status" is ran from the command-line, and this may distract users from the real content. Disable this prefix comment by default, and make it re-activable for users needing backward compatibility with status.displayCommentPrefix. Obviously, "git commit" ignores status.displayCommentPrefix and keeps the comment unconditionnaly when writing to COMMIT_EDITMSG (but not when writing to stdout for an error message or with --dry-run). Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3001-ls-files-others-exclude.sh2
-rwxr-xr-xt/t7060-wtstatus.sh4
-rwxr-xr-xt/t7508-status.sh63
-rwxr-xr-xt/t7512-status-help.sh4
4 files changed, 67 insertions, 6 deletions
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index f0421c0..b2798fe 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -115,7 +115,7 @@ EOF
git config core.excludesFile excludes-file
-git status | grep "^# " > output
+git -c status.displayCommentPrefix=true status | grep "^# " > output
cat > expect << EOF
# .gitignore
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 52ef06b..5ecafac 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -4,6 +4,10 @@ test_description='basic work tree status reporting'
. ./test-lib.sh
+test_expect_success 'use status.displayCommentPrefix by default ' '
+ git config --global status.displayCommentPrefix true
+'
+
test_expect_success setup '
git config --global advice.statusuoption false &&
test_commit A &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index ac3d0fe..8d28280 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -7,6 +7,10 @@ test_description='git status'
. ./test-lib.sh
+test_expect_success 'use status.displayCommentPrefix by default ' '
+ git config --global status.displayCommentPrefix true
+'
+
test_expect_success 'status -h in broken repository' '
git config --global advice.statusuoption false &&
mkdir broken &&
@@ -60,8 +64,12 @@ test_expect_success 'status (1)' '
test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
'
+strip_comments () {
+ sed "s/^\# //; s/^\#$//; s/^#\t/\t/" <"$1" >"$1".tmp &&
+ rm "$1" && mv "$1".tmp "$1"
+}
+
test_expect_success 'status --column' '
- COLUMNS=50 git status --column="column dense" >output &&
cat >expect <<\EOF &&
# On branch master
# Changes to be committed:
@@ -78,9 +86,16 @@ test_expect_success 'status --column' '
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
-# dir1/untracked dir2/untracked untracked
-# dir2/modified output
+# dir1/untracked dir2/untracked output
+# dir2/modified expect untracked
EOF
+ COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
+ test_i18ncmp expect output
+'
+
+test_expect_success 'status --column status.displayCommentPrefix=false' '
+ strip_comments expect &&
+ COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
test_i18ncmp expect output
'
@@ -108,11 +123,39 @@ cat >expect <<\EOF
# untracked
EOF
-test_expect_success 'status (2)' '
- git status >output &&
+test_expect_success 'status with status.displayCommentPrefix=true' '
+ git -c status.displayCommentPrefix=true status >output &&
+ test_i18ncmp expect output
+'
+
+test_expect_success 'status with status.displayCommentPrefix=false' '
+ strip_comments expect &&
+ git -c status.displayCommentPrefix=false status >output &&
test_i18ncmp expect output
'
+test_expect_success 'setup fake editor' '
+ cat >.git/editor <<-\EOF &&
+ #! /bin/sh
+ cp "$1" output
+EOF
+ chmod 755 .git/editor
+'
+
+commit_template_commented () {
+ (
+ EDITOR=.git/editor &&
+ export EDITOR &&
+ # Fails due to empty message
+ test_must_fail git commit
+ ) &&
+ ! grep '^[^#]' output
+}
+
+test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
+ commit_template_commented
+'
+
cat >expect <<\EOF
# On branch master
# Changes to be committed:
@@ -872,6 +915,16 @@ test_expect_success 'status submodule summary' '
test_i18ncmp expect output
'
+test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
+ strip_comments expect &&
+ git -c status.displayCommentPrefix=false status >output &&
+ test_i18ncmp expect output
+'
+
+test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
+ commit_template_commented
+'
+
cat >expect <<EOF
M dir1/modified
A dir2/added
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 31a798f..312f417 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -13,6 +13,10 @@ test_description='git status advice'
set_fake_editor
+test_expect_success 'use status.displayCommentPrefix by default ' '
+ git config --global status.displayCommentPrefix true
+'
+
test_expect_success 'prepare for conflicts' '
git config --global advice.statusuoption false &&
test_commit init main.txt init &&