Re: [PATCH 2/2] git-jump: ignore deleted files in diff mode
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Sep 16, 2024, 20:14 UTC
- Message-ID
- <CAN0heSpk0f1-8tbguqAyTOQbuWrHYpkE-W6H29CJ-QBzqULCrg@mail.gmail.com>
- In-Reply-To
- <20240915112024.GB2017851@coredump.intra.peff.net>
On Sun, 15 Sept 2024 at 13:20, Jeff King <peff@peff.net> wrote:
Show 11 quoted lines
> > If you do something like this: > > rm file_a > echo change >file_b > git jump diff > > then we'll generate two quickfix entries for the diff, one for each > file. But the one for the deleted file is rather pointless. There's no > content to show since the file is gone, and in fact we open the editor > with the path /dev/null!
Ah, yes, I've seen this. I just went "I can see why this would happen" and moved on to the next hunk. Thanks for actually patching.
> Let's skip such entries entirely. There's nothing useful to show, since > the point is that the file has been deleted.
Agreed. Anybody who relies on `git jump diff` to produce an empty quickfix list (no entries to go through) if *and only if* the diff is empty is already in for a surprise due to binary files. Skipping /dev/null makes perfect sense.
> perl -ne '
> - if (m{^\+\+\+ (.*)}) { $file = $1; next }
> + if (m{^\+\+\+ (.*)}) { $file = $1 eq "/dev/null" ? undef : $1; next }
> defined($file) or next;This looks very reasonable. From my testing, this patch fixes the issue.
Martin