From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id A89321F8C8 for ; Sun, 19 Sep 2021 02:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232931AbhISCSy (ORCPT ); Sat, 18 Sep 2021 22:18:54 -0400 Received: from cloud.peff.net ([104.130.231.41]:50526 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232448AbhISCSy (ORCPT ); Sat, 18 Sep 2021 22:18:54 -0400 Received: (qmail 17774 invoked by uid 109); 19 Sep 2021 02:17:29 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Sun, 19 Sep 2021 02:17:29 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 3242 invoked by uid 111); 19 Sep 2021 02:17:29 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Sat, 18 Sep 2021 22:17:29 -0400 Authentication-Results: peff.net; auth=none Date: Sat, 18 Sep 2021 22:17:28 -0400 From: Jeff King To: David Aguilar Cc: Junio C Hamano , Git Mailing List , Johannes Schindelin , Alan Blotz , =?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh Subject: Re: [PATCH 3/4] difftool: use a strbuf to create the tmpdir path Message-ID: References: <20210919015729.98323-1-davvid@gmail.com> <20210919015729.98323-3-davvid@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210919015729.98323-3-davvid@gmail.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sat, Sep 18, 2021 at 06:57:28PM -0700, David Aguilar wrote: > + /* Remove trailing slashes when $TMPDIR ends in '/'. */ > + while (tmpdir.len > 0 && tmpdir.buf[tmpdir.len - 1] == '/') { > + strbuf_setlen(&tmpdir, tmpdir.len - 1); > + } > + strbuf_addstr(&tmpdir, "/git-difftool.XXXXXX"); It sounds like this should remove any directory separator (so on Windows, it should also drop backslashes). You can use is_dir_sep() for that, but better still, you can then do: strbuf_trim_trailing_dir_sep(&tmpdir); -Peff