t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE
When GIT_WORK_TREE does not specify a valid path, we should error out, instead of crashing. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Mar 8, 2017 at 16:43 UTC
aac3eaa6242d00d358a077aa740cf5051905a569
1 file changed
+8
t/t1501-work-tree.sh
+8
@@ -423,4 +423,12 @@ test_expect_success '$GIT_WORK_TREE overrides $GIT_DIR/common' '
423
)
424
'
425
426
+test_expect_failure 'error out gracefully on invalid $GIT_WORK_TREE' '
427
+ (
428
+ GIT_WORK_TREE=/.invalid/work/tree &&
429
+ export GIT_WORK_TREE &&
430
+ test_expect_code 128 git rev-parse
431
+ )
432
+'
433
+
434
test_done