Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: diff: add --exclude flag #4961

Closed
wants to merge 1 commit into from

Conversation

bryceberger
Copy link
Contributor

First contribution, please let me know if this should be an issue / something else first.

Often, while iterating, I end up with a state where I've updated some dependencies (cargo update, etc) and some code. I want to inspect the diff, but jj diff (and jj show, etc) only accept an allowlist. This works ok when all the relevant changes are in a common directory, but is annoying when working in multiple (such as with workspaces).

This adds an --exclude flag to jj diff, which does what it says on the tin. jj diff -x Cargo.lock

Potential pitfalls: jj diff -x *.lock may not work as expected, as it could shell expand to something like jj diff -x Cargo.lock flake.lock, which would exclude Cargo.lock but include flake.lock. Unsure if this motivates a section in the docs.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)

@yuja
Copy link
Contributor

yuja commented Nov 24, 2024

I'm not sure if we want to add --exclude in addition to PATH patterns. Is it super inconvenient to specify '~Cargo.lock'?

@ilyagr
Copy link
Contributor

ilyagr commented Nov 24, 2024

Another possible approach for this would be to have a default-diff-filepattern config.

As I wrote this, I also realized you might be able to instead do

[aliases]
# "diffc" stands for "clean diff" in my mind, there might be better names
diffc = ["diff", "~root-file:Cargo.lock"]

I also ran into this problem, and I think it's worth addressing, but I'm not sure which way is best. (If the alias approach is good enough, which I'm not at all sure about, it could just be a documentation fix maybe)

One downside of the alias approach is that I already have a jj difft and jj delta aliases to pass the diff to difftastic/delta. It'd be annoying to create a "clean diff" variant for each alias.

@bryceberger
Copy link
Contributor Author

bryceberger commented Nov 24, 2024

I'm not sure if we want to add --exclude in addition to PATH patterns. Is it super inconvenient to specify '~Cargo.lock'?

No, it's not, just didn't realize that was an option, whoops.

Another possible approach for this would be to have a default-diff-filepattern config.

It would (probably) be a more involved change, but if this route is taken it would be nice to have something like the template system. jj diff -P no_nix to expand to jj diff '~root-path:(flake.lock | flake.nix)'

Regardless, my immediate use case is already solved by ~patterns. Should I close this?

@ilyagr
Copy link
Contributor

ilyagr commented Nov 24, 2024

[fileset-aliases] sound like an interesting idea to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants