git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] Add tests for GIT_FORCE_TTY

From
AMAvishay Matayev <me@avishay.dev>
Date
Jul 6, 2021, 21:03 UTC
Message-ID
<20210706210317.706313-4-me@avishay.dev>
In-Reply-To
<20210706210317.706313-1-me@avishay.dev>
Signed-off-by: Avishay Matayev <me@avishay.dev>
---
 t/t9904-git-force-tty.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 t/t9904-git-force-tty.sh
diff --git a/t/t9904-git-force-tty.sh b/t/t9904-git-force-tty.sh
new file mode 100755
index 0000000000..c954e27c9a
--- /dev/null
+++ b/t/t9904-git-force-tty.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='Test GIT_FORCE_TTY'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	echo test_data > test_file &&
+	git add test_file &&
+	git commit -m first
+'
+
+test_expect_success 'no output without force' '
+    GIT_FORCE_TTY=0 GIT_PAGER="cat - > log_data" git log > /dev/null &&
+    test ! -f log_data
+'
+
+test_expect_success 'output with force' '
+    GIT_FORCE_TTY=1 GIT_PAGER="cat - > log_data2" git log > /dev/null &&
+    test -f log_data2
+'
+
+test_expect_success 'cant tell pager present in git reflog without force' '
+    GIT_FORCE_TTY=false PAGER="touch pager2" git reflog > /dev/null &&
+    test ! -f pager2
+'
+
+test_expect_success 'pager present in git reflog' '
+    GIT_FORCE_TTY=yes PAGER="touch pager" git reflog > /dev/null &&
+    test -f pager
+'
+
+test_expect_success 'pager not present in git reflog expire' '
+    GIT_FORCE_TTY=true PAGER="touch pager3" git reflog expire > /dev/null &&
+    test ! -f pager3
+'
+
+test_done
-- 
2.25.1
Previous: Avishay MatayevNext: Avishay Matayev
Message 12 of 13 in “Override isatty with GIT_FORCE_TTY”
  1. 0/3 Override isatty with GIT_FORCE_TTYAvishay Matayev, Jul 6, 2021
  2. 1/3 Change isatty's parameter to a *_FILENO defineAvishay Matayev, Jul 6, 2021
  3. Junio C HamanoJul 6, 2021
  4. Avishay MatayevJul 9, 2021
  5. 2/3 Allow isatty to be overriden with GIT_FORCE_TTYAvishay Matayev, Jul 6, 2021
  6. Junio C HamanoJul 6, 2021
  7. Avishay MatayevJul 9, 2021
  8. Junio C HamanoJul 9, 2021
  9. Avishay MatayevJul 9, 2021
  10. Junio C HamanoJul 9, 2021
  11. Avishay MatayevJul 9, 2021
  12. 3/3 Add tests for GIT_FORCE_TTYAvishay Matayev, Jul 6, 2021
  13. Avishay MatayevJul 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.