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

[PATCH 2/5] test git-rev-parse

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Mar 17, 2007, 14:43 UTC
Message-ID
<20070317144342.GB26290@moooo.ath.cx>
In-Reply-To
<20070317143452.GA21140@moooo.ath.cx>

this tests --is-bare-repository, --is-inside-git-dir, --show-cdup and --show-prefix

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 t/t1500-rev-parse.sh |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100755 t/t1500-rev-parse.sh
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
new file mode 100755
index 0000000..c385660
--- /dev/null
+++ b/t/t1500-rev-parse.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='test git rev-parse'
+. ./test-lib.sh
+
+test_expect_success 'toplevel: is-bare-repository' \
+	'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'toplevel: is-inside-git-dir' \
+	'test "false" = "$(git rev-parse --is-inside-git-dir)"'
+test_expect_success 'toplevel: show-cdup' \
+	'test "" = "$(git rev-parse --show-cdup)"'
+test_expect_success 'toplevel: show-prefix' \
+	'test "" = "$(git rev-parse --show-prefix)"'
+
+cd .git/objects || exit 1
+test_expect_success 'in-git-dir: is-bare-repository' \
+	'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'in-git-dir: is-inside-git-dir' \
+	'test "true" = "$(git rev-parse --is-inside-git-dir)"'
+test_expect_success 'in-git-dir: show-cdup' \
+	'test "../../" = "$(git rev-parse --show-cdup)"'
+test_expect_success 'in-git-dir: show-prefix' \
+	'test ".git/objects/" = "$(git rev-parse --show-prefix)"'
+cd ../.. || exit 1
+
+mkdir sub || exit 1
+cd sub || exit 1
+test_expect_success 'subdirectory: is-bare-repository' \
+	'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'subdirectory: is-inside-git-dir' \
+	'test "false" = "$(git rev-parse --is-inside-git-dir)"'
+test_expect_success 'subdirectory: show-cdup' \
+	'test "../" = "$(git rev-parse --show-cdup)"'
+test_expect_success 'subdirectory: show-prefix' \
+	'test "sub/" = "$(git rev-parse --show-prefix)"'
+cd .. || exit 1
+
+test_expect_success 'core.bare = true: is-bare-repository' \
+	'git config core.bare true &&
+	test "true" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'unset core.bare: is-bare-repository' \
+	'git config --unset core.bare &&
+	test "false" = "$(git rev-parse --is-bare-repository)"'
+
+mv .git foo.git || exit 1
+export GIT_DIR=foo.git
+export GIT_CONFIG=foo.git/config
+test_expect_success 'GIT_DIR=foo.git: is-bare-repository' \
+	'test "true" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'GIT_DIR=foo.git, core.bare = true: is-bare-repository' \
+	'git --git-dir foo.git config core.bare true &&
+	test "true" = "$(git --git-dir foo.git rev-parse --is-bare-repository)"'
+test_expect_success 'GIT_DIR=foo.git, core.bare = false: is-bare-repository' \
+	'git config core.bare false &&
+	test "false" = "$(git rev-parse --is-bare-repository)"'
+
+test_done
-- 
1.5.0.4.414.g32da9
Previous: Matthias LederhoferNext: Matthias Lederhofer
Message 6 of 18 in “git-init: set core.workdir when GIT_WORK_DIR is specified”
  1. git-init: set core.workdir when GIT_WORK_DIR is specifiedMatthias Lederhofer, Mar 17, 2007
  2. Junio C HamanoMar 17, 2007
  3. Matthias LederhoferMar 17, 2007
  4. Matthias LederhoferMar 17, 2007
  5. 1/5 rev-parse: --is-bare-repository optionMatthias Lederhofer, Mar 17, 2007
  6. 2/5 test git-rev-parseMatthias Lederhofer, Mar 17, 2007
  7. test git-rev-parseMatthias Lederhofer, Mar 27, 2007
  8. 3/5 introduce GIT_WORK_TREE environment variableMatthias Lederhofer, Mar 17, 2007
  9. Matthias LederhoferMar 18, 2007
  10. Matthias LederhoferMar 18, 2007
  11. Matthias LederhoferMar 18, 2007
  12. Junio C HamanoMar 18, 2007
  13. 4/5 test GIT_WORK_TREEMatthias Lederhofer, Mar 17, 2007
  14. 5/5 git-init: set core.worktree when GIT_WORK_TREE is specifiedMatthias Lederhofer, Mar 17, 2007
  15. Junio C HamanoMar 18, 2007
  16. Matthias LederhoferMar 18, 2007
  17. Matthias LederhoferMar 18, 2007
  18. Johannes SchindelinMar 19, 2007

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.