提交 2afe9278 编写于 作者: M Martin Ågren 提交者: Junio C Hamano

doc-diff: don't `cd_to_toplevel`

`usage` tries to call $0, which might very well be "./doc-diff", so if
we `cd_to_toplevel` before calling `usage`, we'll end with an error to
the effect of "./doc-diff: not found" rather than a friendly `doc-diff
-h` output. This regressed in ad517430 ("doc-diff: add --clean mode to
remove temporary working gunk", 2018-08-31) where we moved the call to
`cd_to_toplevel` to much earlier.

A general fix might be to teach git-sh-setup to save away the absolute
path for $0 and then use that, instead. I'm not aware of any portable
way of doing that, see, e.g., d2addc3b ("t7800: readlink may not be
available", 2016-05-31).

An early version of this patch moved `cd_to_toplevel` back to where it
was before ad517430 and taught the "--clean" code to cd on its own.
But let's try instead to get rid of the cd-ing entirely. We don't really
need it and we can work with absolute paths instead. There's just one
use of $PWD that we need to adjust by simply dropping it.
Suggested-by: NJeff King <peff@peff.net>
Signed-off-by: NMartin Ågren <martin.agren@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ad517430
......@@ -39,8 +39,7 @@ do
shift
done
cd_to_toplevel
tmp=Documentation/tmp-doc-diff
tmp="$(git rev-parse --show-toplevel)/Documentation/tmp-doc-diff" || exit 1
if test -n "$clean"
then
......@@ -109,7 +108,7 @@ render_tree () {
make -j$parallel -C "$tmp/worktree" \
GIT_VERSION=omitted \
SOURCE_DATE_EPOCH=0 \
DESTDIR="$PWD/$tmp/installed/$1+" \
DESTDIR="$tmp/installed/$1+" \
install-man &&
mv "$tmp/installed/$1+" "$tmp/installed/$1"
fi &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册