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

🚀 ignore big file diff #288

Closed
swuecho opened this issue Aug 13, 2020 · 7 comments
Closed

🚀 ignore big file diff #288

swuecho opened this issue Aug 13, 2020 · 7 comments

Comments

@swuecho
Copy link

swuecho commented Aug 13, 2020

really like delta to show the diff but not usable when file too big.

when file is too big, delta will be no response. wonder if there is a way to stop diff specific file.

also, is there a way to tell git to stop using delta by some command line option while keep the git config unchanged? (I want to use delta by default, but when it does not work, I want to use the default git diff).

Thanks.

@dandavison
Copy link
Owner

dandavison commented Aug 13, 2020

Hi @swuecho, thank you!

Can you tell me, which of these is closest to your problem?

is there a way to tell git to stop using delta by some command line option while keep the git config unchanged?

Yes, there is. You can use the git config --global command. For example:

# Disable delta
git config --global --unset core.pager

# Enable delta
git config --global core.pager delta

You can use that to set any git config option (git options and delta options): there are a few examples in the delta README.

@Kr1ss-XD
Copy link
Contributor

FWIW, git config --global does modify the (global) git configuration. While it is easy to revert the effect (e.g. set up aliases for the two mentioned commands - delta-on and delta-off for example), you can also switch off paging for a single git call via command line option.

Just call git as git -P or git --no-pager. this won't alter your configuration.

@dandavison
Copy link
Owner

Hi @Kr1ss-XD, yes that's true that it modifies our gitconfig files on disk. However, git --no-pager doesn't use a pager at all, so it is no good for large diffs or git log -p. So perhaps an even better alternative is

git -c 'core.pager=less -R' {show/diff/log -p etc}

But... git -c ... cannot be used to set delta options. For example, git -c 'delta.side-by-side=true' does not work at all, because delta only sees git config on disk.

So I think for that reason I am currently embracing the idea of using my gitconfig as something that can be transiently mutated (I keep it in git, of course, so I can see the changes), and using aliases based on git config --global to alter git/delta options transiently.

@Kr1ss-XD
Copy link
Contributor

Agreed, those are good points.

@swuecho
Copy link
Author

swuecho commented Aug 14, 2020

Hi @swuecho, thank you!

Can you tell me, which of these is closest to your problem?

is there a way to tell git to stop using delta by some command line option while keep the git config unchanged?

Yes, there is. You can use the git config --global command. For example:

# Disable delta
git config --global --unset core.pager

# Enable delta
git config --global core.pager delta

You can use that to set any git config option (git options and delta options): there are a few examples in the delta README.

set alias to those as suggested by @Kr1ss-XD works great.

it is a long line of json, which is the result of snapshot test. -M, --max-columns <NUM> seems a reasonable fix.
not sure if it is possible to set a time limit in rust for a function run. such as run 1s if no result, then give up.

@dandavison
Copy link
Owner

Thanks @swuecho I'm going to make fixing this/#154 my next task. That's an interesting idea about a timeout. Delta only has a single thread at the moment, but it could be fun to learn how to do the timeout in Rust. However, hopefully we can avoid any such hangs by truncating long-lines or emitting them raw.

dandavison added a commit that referenced this issue Aug 14, 2020
dandavison added a commit that referenced this issue Aug 14, 2020
@dandavison
Copy link
Owner

Fixed in master branch (not released yet)

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

3 participants