jj
jj copied to clipboard
`jj diff` should report nonexistent paths given to it
I often type jj diff @-
instead of jj diff -r @-
and see no results. I can also imagine a situation when I want to check for diffs in a file, mistype its name, and remain unaware of some important change in that file.
I think jj diff
should report an error if it's given a path that doesn't exist in either of the commits it's diffing between.
There are a couple of questions I haven't yet resolved for myself:
- Does there need to be an option to suppress this error?
- Should this be implemented in more commands than just
jj diff
.
I agree. Mercurial does that in many commands (hg diff
, hg add/rm
, hg cat
, hg commit
, ...) and it's quite helpful.
Another complication is when you do things like jj diff foo bar
the foo
and bar
there is interpreted as a prefix and not necessarily a file. I suppose we can handle that by calculating (and displaying?) the diff as usual and record which paths we visit. If not every positional command line argument matches at least one file, then we print that error/warning. Once we support other kinds of patterns than just prefixes (e.g. like hg's set:**.rs
), your first question becomes especially relevant.
I created https://github.com/martinvonz/jj/pull/768 to handle a similar situation for jj log
.
I stole the title of the now-closed #1538.
I created https://github.com/martinvonz/jj/pull/768 to handle a similar situation for jj log.
That turned out to be extremely effective, for me at least, so it might be an easier approach than what I originally suggested.
We had an interesting discussion on this topic elsewhere, beginning at https://github.com/martinvonz/jj/discussions/2495#discussioncomment-7449790.
RE: Ilya's last comment, I would also prefer if jj diff
took a revision argument instead of a path argument. I very frequently diff revisions and rarely want to limit the diff to a specific path.
Thanks Yuya! I feel a bit nostalgic; I think this bug was either the first or one of the very first things I did in this repo.
I opened https://github.com/martinvonz/jj/issues/3809 as my preferred solution.