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

[feature] Add a --time-limit? #814

Open
melonmouse opened this issue Feb 11, 2025 · 1 comment
Open

[feature] Add a --time-limit? #814

melonmouse opened this issue Feb 11, 2025 · 1 comment

Comments

@melonmouse
Copy link

melonmouse commented Feb 11, 2025

The runtime of difft depends on the inputs, hardware, state of the system, etc. Often, --byte-limit and --graph-limit are used to limit the maximum user time. But they are approximations. As difft improves, the ideal limits change, but limits set in dotfiles linger. A solution that fits user needs, and is robust under changes of inputs, difft, hardware etc: --time-limit, which reverts to a text diff (or a --fallback-diff passed in) after a set amount of time is used.

Thanks for working on difft, which I use every day and which is amazing. This is just a feature request, no worries if its out of scope.

@melonmouse melonmouse changed the title Add a --time-limit? [feature] Add a --time-limit? Feb 11, 2025
@melonmouse
Copy link
Author

melonmouse commented Feb 11, 2025

An alternative is for users to create a script like this:

#!/bin/bash

timeout 3s difft "$@"
case $? in
  0)
    # [difft succeeded]
    ;;
  124)
    echo "[difft timed out.]"
    ;;
  *)
    echo "[difft failed.]"
    ;;
esac

So e.g. in .gitconfig, they can set:

[diff]
  external = /path/to/git-external-difft-with-timeout.sh

To my surprise, it seems git diff or difft automatically reverts to a text-only diff if difft fails (so on time-out, no explicit call to the fallback diff was needed in the above script).

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

No branches or pull requests

1 participant