From: "Martin Ågren" <martin.agren@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v3] doc-diff: don't `cd_to_toplevel`
Date: Mon, 4 Feb 2019 21:50:37 +0100 [thread overview]
Message-ID: <20190204205037.32143-1-martin.agren@gmail.com> (raw)
In-Reply-To: <20190203230152.GA25608@sigill.intra.peff.net>
`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 ad51743007 ("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., d2addc3b96 ("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 ad51743007 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: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
Thanks Peff for the suggestions. Trying not to cd at all seems sane to
me. That it allows `./Documentation/doc-diff` is a bonus, I guess, but
you're right that it's probably nothing anyone will use.
I've verified that diffs produced by `./Documentation/doc-diff foo bar`
and `./doc-diff foo bar` are identical, FWIW.
Martin
Documentation/doc-diff | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/Documentation/doc-diff b/Documentation/doc-diff
index dfd9418778..32c83dd26f 100755
--- a/Documentation/doc-diff
+++ b/Documentation/doc-diff
@@ -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 &&
--
2.20.1.390.gb5101f9297
next prev parent reply other threads:[~2019-02-04 20:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-03 8:35 [PATCH] doc-diff: don't `cd_to_toplevel` before calling `usage` Martin Ågren
2019-02-03 9:08 ` Eric Sunshine
2019-02-03 9:11 ` Eric Sunshine
2019-02-03 10:35 ` Martin Ågren
2019-02-03 11:01 ` Eric Sunshine
2019-02-03 11:08 ` [PATCH v2] " Martin Ågren
2019-02-03 23:01 ` Jeff King
2019-02-04 20:50 ` Martin Ågren [this message]
2019-02-04 23:34 ` [PATCH v3] doc-diff: don't `cd_to_toplevel` Jeff King
2019-02-05 10:34 ` Johannes Schindelin
2019-02-05 18:45 ` Junio C Hamano
2019-02-06 12:20 ` Johannes Schindelin
2019-02-06 17:24 ` Junio C Hamano
2019-02-06 18:55 ` Jeff King
2019-02-07 15:41 ` Johannes Schindelin
2019-02-07 17:37 ` Junio C Hamano
2019-02-07 21:34 ` Johannes Schindelin
2019-02-07 20:49 ` Jeff King
2019-02-07 21:42 ` Johannes Schindelin
2019-02-06 18:49 ` Jeff King
2019-02-07 14:26 ` Johannes Schindelin
2019-02-07 20:45 ` Jeff King
2019-02-07 21:57 ` Johannes Schindelin
2019-02-08 2:53 ` Jeff King
2019-02-08 4:34 ` Jeff King
2019-02-08 0:58 ` SZEDER Gábor
2019-02-08 2:51 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190204205037.32143-1-martin.agren@gmail.com \
--to=martin.agren@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).