From patchwork Mon Feb 4 20:50:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_=C3=85gren?= X-Patchwork-Id: 10796623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48B106C2 for ; Mon, 4 Feb 2019 20:51:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34A862B8F3 for ; Mon, 4 Feb 2019 20:51:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3281B2B9E4; Mon, 4 Feb 2019 20:51:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADEAC2C2AF for ; Mon, 4 Feb 2019 20:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727750AbfBDUvj (ORCPT ); Mon, 4 Feb 2019 15:51:39 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41451 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727276AbfBDUvi (ORCPT ); Mon, 4 Feb 2019 15:51:38 -0500 Received: by mail-lf1-f65.google.com with SMTP id e27so979153lfj.8 for ; Mon, 04 Feb 2019 12:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/P1j/dbTN50cx23Asa/rE4j5dyjjPSsolANJCCDxxVA=; b=pTkF2Jfj+JCB+ulKgLYyS2vwrlN2xRsOwBt4aoud9LAFL/vNyFw7jneYmOzhgs236s 4qKA1O4AvuvIcYzAvPo9qgQ4URzX74OtgUw9HVLJ9+M6LA2SP4/Lq56ARPfhdF71xeEk h/7/uxO7uxum2ORINEwjgRqgGFwpBY2JVFATMazGacmu5P1u4fCxxzrz5qGB4bVExjSq AsqOj8LS2fI1VRik/XUmCMKatTDAsPB06mZOfs6WSuwC6ri/bfZm53joGb4jKt1ZedMi ocMSDjUO9Y2xMRwYB/Pd20fdS+dLkfvS1VDEDbqam/uhPhnjlvrUNMJEvaButJ6Fjo+K rhuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/P1j/dbTN50cx23Asa/rE4j5dyjjPSsolANJCCDxxVA=; b=Y3LE+1KXvqREoqc9y1Gqh3/U0hSC0EZA3Dgic74aCAFLbV1gyS8B6h+/SkbrRKOdC6 i1j2iAoEC0dYH+dnV3scWMspAFUjA2Pkym9PkYr/squ4UOw2I/Erw2pc46LHPo1DFane Y9+XiMmJuVEhAFYBo82bh9gWYkUYU6zz9LQLq/wi4c2Pq7RinR7Q5roNAd/k8ow77OeL XfEjt1yz+IIeYBWAVPEFY5c/JqFasZ1tE6bjBc0OEhAFYWC8ov3GQNc3SKdMZzYeFRQW 2l5haQCVLd7hroma5X8jDYsg5QwdfPsPwD2Dk8q/RpQ3vlOPLg0PIWVKmoO11rX018oe MZGQ== X-Gm-Message-State: AHQUAuYZZiQmsgoP+T4o9ftxTToRbbCZ9/UMfHzNunpQh0eBZeq5JPVm 24sNGVNyzVikGHuvITH/C4o= X-Google-Smtp-Source: AHgI3IbWEorKY4xJmNNCXsg7vxv27Cu9d+WyfyxwwnTSbRLQ8cfHXygOVYVcHqQBJhM5rHAofBr7iw== X-Received: by 2002:a19:9508:: with SMTP id x8mr803213lfd.112.1549313495862; Mon, 04 Feb 2019 12:51:35 -0800 (PST) Received: from localhost.localdomain (31-211-229-121.customers.ownit.se. [31.211.229.121]) by smtp.gmail.com with ESMTPSA id d5sm3275674lfi.65.2019.02.04.12.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 12:51:34 -0800 (PST) From: =?utf-8?q?Martin_=C3=85gren?= To: Jeff King Cc: git@vger.kernel.org, Eric Sunshine Subject: [PATCH v3] doc-diff: don't `cd_to_toplevel` Date: Mon, 4 Feb 2019 21:50:37 +0100 Message-Id: <20190204205037.32143-1-martin.agren@gmail.com> X-Mailer: git-send-email 2.20.1.390.gb5101f9297 In-Reply-To: <20190203230152.GA25608@sigill.intra.peff.net> References: <20190203230152.GA25608@sigill.intra.peff.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP `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 Signed-off-by: Martin Ă…gren --- 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 &&