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

External diff tool exiting with code 1 should not cause a warning #5250

Open
dotdash opened this issue Jan 3, 2025 · 4 comments
Open

External diff tool exiting with code 1 should not cause a warning #5250

dotdash opened this issue Jan 3, 2025 · 4 comments
Labels
good first issue Good for newcomers

Comments

@dotdash
Copy link

dotdash commented Jan 3, 2025

Description

diff uses exit code 0 to signal that there were no changes, 1 to signal that there were changes, and an exit code >1 to signal an error. Tools like delta do the same, but jj treats exit code 1 as a problem.

Steps to Reproduce the Problem

  1. Change something in your working copy
  2. Run jj diff --config ui.diff.tool=diff or jj diff --config ui.diff.tool=delta

Expected Behavior

No warnings show up.

Actual Behavior

The output ends with:

Warning: Tool exited with exit status: 1 (run with --debug to see the exact invocation)

Specifications

  • Platform: Linux Debian Sid
  • Version: jj 0.25.0-041c4fecb77434dd6720e7d7f1ce48d9575ac5f7
@yuja
Copy link
Contributor

yuja commented Jan 3, 2025

It's not an error but a warning for that reason. Maybe we can add a per-tool list of expected exit codes to suppress the warning.

fwiw, you might want to set up delta as a pager, not a diff generator.

@bryceberger
Copy link
Member

Comment from PR (#5257 (review)):

Perhaps it would be better to reduce complexity in jj by having the user write their own wrapper for the tool? Then it can handle arbitrary exit conditions.

I'm in favor of a wrapper. Minimal example:

#!/usr/bin/env bash
diff "$@"
status=$?
case $status in
0 | 1) ;;
*)
    # custom handling, etc
    exit $status
    ;;
esac

@dotdash
Copy link
Author

dotdash commented Jan 7, 2025

fwiw, you might want to set up delta as a pager, not a diff generator.

That works for e.g. jj diff but not for jj log -p because delta doesn't recognize the diff format due to the vertical bar left of the diff (it fails the same way with git log --graph -p). Though using ui.diff.tool the output in jj log -p is still broken WRT the file path, because delta gets the raw paths instead of a git style diff 🤔

Should I file a separate issue for that?

@arxanas
Copy link
Contributor

arxanas commented Jan 7, 2025

fwiw, you might want to set up delta as a pager, not a diff generator.

That works for e.g. jj diff but not for jj log -p because delta doesn't recognize the diff format due to the vertical bar left of the diff (it fails the same way with git log --graph -p). Though using ui.diff.tool the output in jj log -p is still broken WRT the file path, because delta gets the raw paths instead of a git style diff 🤔

Should I file a separate issue for that?

I don't know if it's relevant, but there's a specific note for configuring delta here, is it applicable? https://jj-vcs.github.io/jj/v0.25.0/config/#processing-contents-to-be-paged

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

No branches or pull requests

4 participants