jj icon indicating copy to clipboard operation
jj copied to clipboard

`jj diff` should report nonexistent paths given to it

Open ilyagr opened this issue 2 years ago • 1 comments

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:

  1. Does there need to be an option to suppress this error?
  2. Should this be implemented in more commands than just jj diff.

ilyagr avatar Aug 31 '22 04:08 ilyagr

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.

martinvonz avatar Aug 31 '22 04:08 martinvonz

I created https://github.com/martinvonz/jj/pull/768 to handle a similar situation for jj log.

arxanas avatar Nov 18 '22 22:11 arxanas

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.

ilyagr avatar Apr 20 '23 04:04 ilyagr

We had an interesting discussion on this topic elsewhere, beginning at https://github.com/martinvonz/jj/discussions/2495#discussioncomment-7449790.

ilyagr avatar Nov 03 '23 03:11 ilyagr

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.

emesterhazy avatar Apr 09 '24 13:04 emesterhazy

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.

ilyagr avatar Apr 10 '24 23:04 ilyagr

I opened https://github.com/martinvonz/jj/issues/3809 as my preferred solution.

arxanas avatar Jun 01 '24 19:06 arxanas