eang
eang

Reputation: 1645

Prevent empty pager in 'git diff'

When there are no changes in a git repo, git diff used to immediately return with no output. Since git 2.9, such git diff commands open a less-like window with no text, which I have to manually close by pressing q. Is there a way to restore the old git diff behavior?

EDIT

Title changed.

git 2.9 is actually unrelated, this new behavior is due to having recently introduced LESS="-Ri" in my environment. How should I change this variable to achieve what I want?

Upvotes: 1

Views: 353

Answers (2)

qehgt
qehgt

Reputation: 2990

Try to use LESS="-RFi"

From man:

-F or --quit-if-one-screen
Causes less to automatically exit if the entire file can be displayed on the first screen.

If you don't want to change your environment LESS variable, you can archive the same via .gitconfig:

[pager]
    log  = less -FRX
    diff = less -FRX
    show = less -FRX

Upvotes: 4

eckes
eckes

Reputation: 67047

If you ask for

git --no-pager diff

the behavior should be the same again.

Upvotes: 0

Related Questions