git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] git-jump: ignore deleted files in diff mode

From
MÅ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
Previous: Jeff KingNext: Taylor Blau
Message 5 of 10 in “a few git-jump quality-of-life fixes”
  1. 0/2 a few git-jump quality-of-life fixesJeff King, Sep 15, 2024
  2. 1/2 git-jump: always specify column 1 for diff entriesJeff King, Sep 15, 2024
  3. Martin ÅgrenSep 16, 2024
  4. 2/2 git-jump: ignore deleted files in diff modeJeff King, Sep 15, 2024
  5. Martin ÅgrenSep 16, 2024
  6. Taylor BlauSep 17, 2024
  7. Junio C HamanoSep 17, 2024
  8. Jeff KingSep 24, 2024
  9. Taylor BlauSep 24, 2024
  10. Junio C HamanoSep 25, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.