git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] doc-diff: don't `cd_to_toplevel` before calling `usage`
@ 2019-02-03  8:35 Martin Ågren
  2019-02-03  9:08 ` Eric Sunshine
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Ågren @ 2019-02-03  8:35 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Jeff King

`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. Granted, all of these `usage` calls are in error paths, so
we're about to exit anyway, but the user experience of something like
`(cd Documentation && ./doc-diff)` could be a bit better than
"./doc-diff: not found".

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. Move it back to where it was, and
teach the "--clean" code to cd on its own. This way, we only cd once
we've verified the arguments.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 Documentation/doc-diff | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Documentation/doc-diff b/Documentation/doc-diff
index dfd9418778..f820febf8f 100755
--- a/Documentation/doc-diff
+++ b/Documentation/doc-diff
@@ -39,12 +39,11 @@ do
 	shift
 done
 
-cd_to_toplevel
-tmp=Documentation/tmp-doc-diff
-
 if test -n "$clean"
 then
 	test $# -eq 0 || usage
+	cd_to_toplevel
+	tmp=Documentation/tmp-doc-diff
 	git worktree remove --force "$tmp/worktree" 2>/dev/null
 	rm -rf "$tmp"
 	exit 0
@@ -66,6 +65,9 @@ to=$1; shift
 from_oid=$(git rev-parse --verify "$from") || exit 1
 to_oid=$(git rev-parse --verify "$to") || exit 1
 
+cd_to_toplevel
+tmp=Documentation/tmp-doc-diff
+
 if test -n "$force"
 then
 	rm -rf "$tmp"
-- 
2.20.1.309.g16a465bc01


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-02-08  4:34 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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             ` [PATCH v3] doc-diff: don't `cd_to_toplevel` Martin Ågren
2019-02-04 23:34               ` 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

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).