From: Jeff King <peff@peff.net>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Torsten Bögershausen" <tboegi@web.de>
Subject: Re: [PATCH 2/2] connect: improve check for plink to reduce false positives
Date: Thu, 23 Apr 2015 11:53:04 -0400 [thread overview]
Message-ID: <20150423155304.GA26018@peff.net> (raw)
In-Reply-To: <b6b4da1f7735b834043375e3d8eaa331@www.dscho.org>
On Thu, Apr 23, 2015 at 08:50:17AM +0200, Johannes Schindelin wrote:
> > + tortoiseplink = tplink == ssh ||
> > + (tplink && is_dir_sep(tplink[-1]));
>
> Maybe have a helper function here? Something like
> `basename_matches(const char *path, const char *basename, int
> ignore_case)`? That would be easier to read (I have to admit that I
> had to wrap my head around the logic to ensure that tplink[-1] is
> valid; It is, but it requires more brain cycles to verify than I would
> like).
Yeah, I had a similar thought when reading the patch.
> Also, I am really hesitant to just test the start of the basename; I
> would rather have an entire basename match so that something like
> "PLinKoeln" would not match. (And of course, for Windows I would want
> that hypothetical `basename_matches()` function to allow basenames to
> end in `.exe` automatically).
What about "plink-0.83" that was mentioned earlier in the thread? I
think that is the reason brian's patch stuck to matching the start and
not the end. But I have no idea if that is actually a real thing, or
just a hypothetical.
If I were writing from scratch, I would probably keep things as tight as
possible, like:
const char *base = basename(ssh);
plink = !strcasecmp(base, "plink") ||
!strcasecmp(base, "plink.exe");
tplink = !strcasecmp(base, "tortoiseplink") ||
!strcasecmp(base, "tortoiseplink.exe"));
but maybe that is too tight at this point in time; we don't really know
what's out there and working (or maybe _we_ do, but _I_ do not :) ).
At any rate, brian's patch only looks for a dir-separator anywhere, not
the actual basename. So:
/path/to/plink/ssh
would match, and I'm not sure if that's a good thing or not. So yet
another variant is to use basename(), and then just check that the
basename starts with "plink" (to catch "plink.exe", "plink-0.83", etc).
That avoids cruft in the intermediate path, and unless your actual
binary is named PlinKoeln, it will not false positive on the example you
gave.
-Peff
next prev parent reply other threads:[~2015-04-23 15:53 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-22 14:36 [BUG] having 'plink' anywhere in the GIT_SSH environment variables sets putty = true Patrick Sharp
2015-04-22 17:46 ` Johannes Schindelin
2015-04-22 19:12 ` Patrick Sharp
2015-04-22 20:29 ` Jeff King
2015-04-22 21:19 ` brian m. carlson
2015-04-22 21:29 ` Jeff King
2015-04-22 21:44 ` brian m. carlson
2015-04-22 22:00 ` Jeff King
2015-04-22 22:24 ` brian m. carlson
2015-04-22 23:23 ` Jeff King
2015-04-23 0:06 ` [PATCH 1/2] connect: simplify SSH connection code path brian m. carlson
2015-04-23 0:06 ` [PATCH 2/2] connect: improve check for plink to reduce false positives brian m. carlson
2015-04-23 6:50 ` Johannes Schindelin
2015-04-23 15:53 ` Jeff King [this message]
2015-04-23 23:14 ` brian m. carlson
2015-04-24 6:41 ` Johannes Schindelin
2015-04-24 22:28 ` [PATCH v2 1/2] connect: simplify SSH connection code path brian m. carlson
2015-04-24 22:28 ` [PATCH v2 2/2] connect: improve check for plink to reduce false positives brian m. carlson
2015-04-24 22:46 ` Pete Harlan
2015-04-24 22:48 ` brian m. carlson
2015-04-25 16:03 ` Torsten Bögershausen
2015-04-26 18:52 ` brian m. carlson
2015-04-26 20:30 ` [PATCH v3 0/3] Improve robustness of putty detection brian m. carlson
2015-04-26 20:30 ` [PATCH v3 1/3] connect: simplify SSH connection code path brian m. carlson
2015-04-26 20:30 ` [PATCH v3 2/3] t5601: fix quotation error leading to skipped tests brian m. carlson
2015-04-26 20:30 ` [PATCH v3 3/3] connect: improve check for plink to reduce false positives brian m. carlson
2015-04-27 7:57 ` Johannes Schindelin
2015-04-28 3:53 ` Jeff King
2015-06-26 13:15 ` Jeff King
2015-06-26 16:16 ` Junio C Hamano
2015-06-26 16:27 ` Jeff King
2015-06-26 17:13 ` Johannes Schindelin
2015-06-26 17:23 ` Jeff King
2015-06-26 20:43 ` brian m. carlson
2015-04-26 22:04 ` [PATCH v3 0/3] Improve robustness of putty detection Junio C Hamano
2015-04-27 15:46 ` Torsten Bögershausen
2015-04-28 4:15 ` Jeff King
2015-04-29 1:38 ` brian m. carlson
2015-04-24 6:37 ` [PATCH 2/2] connect: improve check for plink to reduce false positives Johannes Schindelin
2015-04-23 5:08 ` [BUG] having 'plink' anywhere in the GIT_SSH environment variables sets putty = true Torsten Bögershausen
2015-04-23 13:15 ` Patrick Sharp
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150423155304.GA26018@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=pclouds@gmail.com \
--cc=sandals@crustytoothpaste.net \
--cc=tboegi@web.de \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.