<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/contrib/git-jump, branch main</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=main</id>
<link rel='self' href='https://git.shady.money/git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-08-11T15:58:21Z</updated>
<entry>
<title>git-jump: make `diff` work with filenames containing spaces</title>
<updated>2025-08-11T15:58:21Z</updated>
<author>
<name>Greg Hurrell</name>
<email>greg.hurrell@datadoghq.com</email>
</author>
<published>2025-08-11T11:55:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=621ce9c1c6cfe5a6467ef62cb81992b3a318b70e'/>
<id>urn:sha1:621ce9c1c6cfe5a6467ef62cb81992b3a318b70e</id>
<content type='text'>
In diff.c, we output a trailing "\t" at the end of any filename that
contains a space:

    case DIFF_SYMBOL_FILEPAIR_PLUS:
            meta = diff_get_color_opt(o, DIFF_METAINFO);
            reset = diff_get_color_opt(o, DIFF_RESET);
            fprintf(o-&gt;file, "%s%s+++ %s%s%s\n", diff_line_prefix(o), meta,
                    line, reset,
                    strchr(line, ' ') ? "\t" : "");
            break;

That is, for a file "foo.txt", `git diff --no-prefix` will emit:

    +++ foo.txt

but for "foo bar.txt" it will emit:

    +++ foo bar.txt\t

This in turn leads `git-jump` to produce a quickfix format like this:

    foo bar.txt\t:1:1:contents

Because no "foo bar.txt\t" file actually exists on disk, opening it in
Vim will just land the user in an empty buffer.

This commit takes the simple approach of unconditionally stripping any
trailing tab. Consider the following three examples:

1. For file "foo", Git will emit "foo".
2. For file "foo bar", Git will emit "foo bar\t".
3. For file "foo\t", Git will emit "\"foo\t\"".
4. For file "foo bar\t", Git will emit "\"foo bar\t\"".

Before this commit, `git-jump` correctly handled only case "1".

After this commit, `git-jump` correctly handles cases "1" and "2". In
reality, these are the only cases people are going to run into with any
regularity, and the other two are rare edge cases, which probably aren't
worth the effort to support unless somebody actually complains about
them.

Signed-off-by: Greg Hurrell &lt;greg.hurrell@datadoghq.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/jump-quickfix-fixes'</title>
<updated>2024-09-23T17:35:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-09-23T17:35:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=621ac241be8d7898bf05a3f8dfac3222f7899a70'/>
<id>urn:sha1:621ac241be8d7898bf05a3f8dfac3222f7899a70</id>
<content type='text'>
A few usability fixes to "git jump" (in contrib/).

* jk/jump-quickfix-fixes:
  git-jump: ignore deleted files in diff mode
  git-jump: always specify column 1 for diff entries
</content>
</entry>
<entry>
<title>git-jump: ignore deleted files in diff mode</title>
<updated>2024-09-16T16:20:46Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-09-15T11:20:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=083b82544d6e5b27a4b3fa7f105ba330f490227b'/>
<id>urn:sha1:083b82544d6e5b27a4b3fa7f105ba330f490227b</id>
<content type='text'>
If you do something like this:

  rm file_a
  echo change &gt;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!

In vim, at least, the result is a confusing annoyance: the editor opens
with an empty buffer, and you have to skip past it to the useful
quickfix entry (after scratching your head and figuring out that no,
nothing is broken).

Let's skip such entries entirely. There's nothing useful to show, since
the point is that the file has been deleted.

It is possible that you could be doing a diff whose post-image is not
the working tree, and then you'd perhaps be jumping to the deleted
content (or at least something that was in the same spot). But I don't
think it's worth worrying about that case. For one thing, using git-jump
for such diffs is a bad idea in general, as it's going to sometimes move
you to the wrong spot. And two, a deletion is always going to have one
hunk starting at line 1, which is not that interesting to jump to in the
first place.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: always specify column 1 for diff entries</title>
<updated>2024-09-16T16:20:43Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-09-15T11:18:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9f5978e7778843bb729baef121c92f98bd187044'/>
<id>urn:sha1:9f5978e7778843bb729baef121c92f98bd187044</id>
<content type='text'>
When we generate a quickfix entry for a diff hunk, we provide just the
filename and line number along with the content, like:

  file:1: contents of the line

This can be a problem if the line itself looks like a quickfix header.
For example (and this is adapted from a real-world case that bit me):

  echo 'static_lease 10:11:12:13:14:15:16 10.0.0.1' &gt;file
  git add file
  echo change &gt;file

produces:

  file:1: static_lease 10:11:12:13:14:15:16 10.0.0.1

which is ambiguous. It could be line 1 of "file", or line 11 of the file
"file:1: static_lease 10", and so on. In the case of vim's default
config, it seems to prefer the latter (you can configure "errorformat"
with a variety of patterns, but out of the box it matches some common
ones).

One easy way to fix this is to provide a column number, like:

  file:1:1: static_lease 10:11:12:13:14:15:16 10.0.0.1

which causes vim to prefer line 1 of "file" again (due to the preference
order of the various patterns in the default errorformat).

There are other options. For example, at least in my version of vim,
wrapping the file in quotation marks like:

  "file":1: static_lease 10:11:12:13:14:15:16 10.0.0.1

also works. That perhaps would the right thing even if you had the silly
file name "file:1:1: foo 10". But it's not clear what would happen if
you had a filename with quotes in it.

This feature is inherently scraping text, and there's bound to be some
ambiguities. I don't think it's worth worrying too much about unlikely
filenames, as its the file content that is more likely to introduce
unexpected characters.

So let's just go with the extra ":1" column specifier. We know this is
supported everywhere, as git-jump's "grep" mode already uses it (and
thus doesn't exhibit the same problem).

The "merge" mode is mostly immune to this, as it only matches "&lt;&lt;&lt;&lt;&lt;&lt;&lt;"
conflict marker lines. It's possible of course to have a marker that
says "foo 10:11" later in the line, but in practice these will only have
branches and perhaps file names, so it's probably not worth worrying
about (and fixing it would involve passing --column to the system grep,
which may not be portable).

I also gave some thought as to whether we could put something more
useful than "1" in the column field for diffs. In theory we could find
the first changed character of the line, but this is tricky in practice.
You'd have to correlate before/after lines of the hunk to decide what
changed. So:

  -this is a foo line
  +this is a bar line

is easy (column 11). But:

  -this is a foo line
  +another line
  +this is a bar line

is harder.

This commit certainly doesn't preclude trying to do something more
clever later, but it's a much deeper rabbit hole than just fixing the
syntactic ambiguity.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: admit to passing merge mode args to ls-files</title>
<updated>2023-10-05T19:55:38Z</updated>
<author>
<name>Štěpán Němec</name>
<email>stepnem@smrk.net</email>
</author>
<published>2023-10-05T09:00:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a62a7060a50e09089fb63b793b97c4b570993142'/>
<id>urn:sha1:a62a7060a50e09089fb63b793b97c4b570993142</id>
<content type='text'>
There's even an example of such usage in the README.

Fixes: 67ba13e5a4b2 ("git-jump: pass "merge" arguments to ls-files")
Signed-off-by: Štěpán Němec &lt;stepnem@smrk.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: invoke emacs/emacsclient</title>
<updated>2022-11-27T01:49:51Z</updated>
<author>
<name>Yoichi Nakayama</name>
<email>yoichi.nakayama@gmail.com</email>
</author>
<published>2022-11-27T01:18:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9508dfd9f553019c2e3b2869926a0dcaed7a498f'/>
<id>urn:sha1:9508dfd9f553019c2e3b2869926a0dcaed7a498f</id>
<content type='text'>
It works with GIT_EDITOR="emacs", "emacsclient" or "emacsclient -t"

Signed-off-by: Yoichi Nakayama &lt;yoichi.nakayama@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: move valid-mode check earlier</title>
<updated>2022-11-27T01:49:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2022-11-27T01:18:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=64685cb85566c1b0fb288690a300978d3c035431'/>
<id>urn:sha1:64685cb85566c1b0fb288690a300978d3c035431</id>
<content type='text'>
We check if the "mode" argument supplied by the user is valid by seeing
if we have a mode_$mode function defined. But we don't do that until
after creating the tempfile. This is wasteful (we create a tempfile but
never use it), and makes it harder to add new options (the recent stdout
option exits before creating the tempfile, so it misses the check and
"git jump --stdout foo" will produce "git-jump: 92: mode_foo: not found"
rather than the regular usage message).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: add an optional argument '--stdout'</title>
<updated>2022-11-27T01:49:51Z</updated>
<author>
<name>Yoichi Nakayama</name>
<email>yoichi.nakayama@gmail.com</email>
</author>
<published>2022-11-27T01:18:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cfb7b3b39183e9711340ee464e58199f44e0de4e'/>
<id>urn:sha1:cfb7b3b39183e9711340ee464e58199f44e0de4e</id>
<content type='text'>
It can be used with M-x grep on Emacs.

Signed-off-by: Yoichi Nakayama &lt;yoichi.nakayama@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-jump: pass "merge" arguments to ls-files</title>
<updated>2021-11-09T19:15:21Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-11-09T16:35:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=67ba13e5a4b27785391a0e1673d71e506edae13b'/>
<id>urn:sha1:67ba13e5a4b27785391a0e1673d71e506edae13b</id>
<content type='text'>
We currently throw away any arguments given to "git jump merge". We
should instead pass them along to ls-files, since they're likely to be
pathspecs. This matches the behavior of "git jump diff", etc.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>contrib/git-jump/git-jump: jump to exact location</title>
<updated>2018-06-22T19:59:02Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2018-06-22T15:49:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=240cf2a25744b45c514fe850363721615a1c4b8c'/>
<id>urn:sha1:240cf2a25744b45c514fe850363721615a1c4b8c</id>
<content type='text'>
Take advantage of 'git-grep(1)''s new option, '--column' in order to
teach Peff's 'git-jump' script how to jump to the correct column for any
given match.

'git-grep(1)''s output is in the correct format for Vim's jump list, so
no additional cleanup is necessary.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
