git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
	Greg Hurrell via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Greg Hurrell <greg.hurrell@datadoghq.com>
Subject: Re: [PATCH] git-jump: make `diff` work with filenames containing spaces
Date: Thu, 14 Aug 2025 19:14:02 -0400	[thread overview]
Message-ID: <20250814231402.GA2937@coredump.intra.peff.net> (raw)
In-Reply-To: <3f9eb0ed-576d-451a-93db-9b9508c99c27@gmail.com>

On Sun, Aug 10, 2025 at 02:20:13PM +0100, Phillip Wood wrote:

> On 10/08/2025 11:09, Phillip Wood wrote:
> > On 09/08/2025 15:44, D. Ben Knoble wrote:
> > > On Fri, Aug 8, 2025 at 1:43 PM Greg Hurrell via GitGitGadget
> > > <gitgitgadget@gmail.com> wrote:
> > > > From: Greg Hurrell <greg.hurrell@datadoghq.com>
> > > > 
> > > > This commit takes the simple approach of unconditionally stripping any
> > > > trailing tab. Consider the following three examples:
> > > > 
> > > > 1. For file "foo bar", Git will emit "foo bar\t".
> > > > 2. For file "foo\t", Git will emit "foo\t".
> > > > 3. For file "foo bar\t", Git will emit "foo bar\t\t".
> 
> When I wrote earlier I forgot that git quotes filenames with control
> characters. If a name contains a tab it it quoted and so cases 2 and 3 will
> be quoted and so there is no ambiguity when trimming a literal tab character
> from the end. I haven't checked but I suspect git-jump does not handle
> quoted filenames, if we wanted to add support it should be pretty easy as
> Git.pm has a function to do the unquoting for us.

Yeah, git-jump does not do any unquoting at all. Ironically I used the
"+++" line because I wanted to avoid quoting and whitespace headaches on
the "diff --git" line. But I guess it is unavoidable for truly weird
path names. ;)

I'd prefer to avoid an extra dependency on Git.pm and just leave it
broken for quoted names. Since names with spaces are the likely thing to
see, and those aren't quoted, I think running into this should be pretty
rare (another alternative is to lazy-load Git.pm only when necessary,
since we're already in a perl script).

I wondered if it might almost work without any intelligence on the part
of git-jump, just because vim's quickfix parser already does a bunch of
heuristic regex matches, some of which understand quotes. But it looks
like the answer is no. This one from the default set:

  "%f"%*\D%l: %m

is quite close, and would match:

  echo content >'foo bar'
  vim -q <(printf '"foo bar":1: some error')

but it won't automatically undo backslash escapes inside the quoted
portion. So in something that actually needed quoting would end up
looking for a file with the literal sequence "\t" in it, rather than a
tab. Oh well.

-Peff

  reply	other threads:[~2025-08-14 23:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-08 17:42 [PATCH] git-jump: make `diff` work with filenames containing spaces Greg Hurrell via GitGitGadget
2025-08-09 14:44 ` D. Ben Knoble
2025-08-10 10:09   ` Phillip Wood
2025-08-10 13:20     ` Phillip Wood
2025-08-14 23:14       ` Jeff King [this message]
2025-08-15 15:51         ` Phillip Wood
2025-08-10  0:03 ` Junio C Hamano
2025-08-11 11:55 ` [PATCH v2] " Greg Hurrell via GitGitGadget
2025-08-11 13:16   ` Phillip Wood
2025-08-11 21:05     ` D. Ben Knoble
2025-08-14 23:18   ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250814231402.GA2937@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=greg.hurrell@datadoghq.com \
    --cc=phillip.wood123@gmail.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.
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 NNTP newsgroup(s).