Web lists-archives.com

[PATCH 1/2] Demonstrate NULL pointer access with invalid GIT_WORK_TREE




When GIT_WORK_TREE does not specify a valid path, we should error out.
Not crash.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---
 t/t1501-work-tree.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
index cc5b870e587..046d9b7909f 100755
--- a/t/t1501-work-tree.sh
+++ b/t/t1501-work-tree.sh
@@ -423,4 +423,12 @@ test_expect_success '$GIT_WORK_TREE overrides $GIT_DIR/common' '
 	)
 '
 
+test_expect_failure 'error out gracefully on invalid $GIT_WORK_TREE' '
+	(
+		GIT_WORK_TREE=/.invalid/work/tree &&
+		export GIT_WORK_TREE &&
+		test_expect_code 128 git rev-parse
+	)
+'
+
 test_done
-- 
2.12.0.windows.1.7.g94dafc3b124