diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-03-08 16:43:40 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-08 23:38:41 +0100 |
commit | ce83eadd9a2c63db6263df91933da1b1b865d26a (patch) | |
tree | 784557c4dda31707340440142db671375a36653f /t/t1501-work-tree.sh | |
parent | t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE (diff) | |
download | git-ce83eadd9a2c63db6263df91933da1b1b865d26a.tar.xz git-ce83eadd9a2c63db6263df91933da1b1b865d26a.zip |
real_pathdup(): fix callsites that wanted it to die on error
In 4ac9006f832 (real_path: have callers use real_pathdup and
strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
pattern to use real_pathdup() directly.
The problem with this change is that real_path() calls
strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
it with die_on_error = 0. Meaning that in cases where real_path()
causes Git to die() with an error message, real_pathdup() is silent
and returns NULL instead.
The callers, however, are ill-prepared for that change, as they expect
the return value to be non-NULL (and otherwise the function died
with an appropriate error message).
Fix this by extending real_pathdup()'s signature to accept the
die_on_error flag and simply pass it through to strbuf_realpath(),
and then adjust all callers after a careful audit whether they would
handle NULLs well.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1501-work-tree.sh')
-rwxr-xr-x | t/t1501-work-tree.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh index 046d9b7909..b06210ec5e 100755 --- a/t/t1501-work-tree.sh +++ b/t/t1501-work-tree.sh @@ -423,7 +423,7 @@ test_expect_success '$GIT_WORK_TREE overrides $GIT_DIR/common' ' ) ' -test_expect_failure 'error out gracefully on invalid $GIT_WORK_TREE' ' +test_expect_success 'error out gracefully on invalid $GIT_WORK_TREE' ' ( GIT_WORK_TREE=/.invalid/work/tree && export GIT_WORK_TREE && |