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

Avoid lockup when running without arguments and stdin is connected to a tty #1112

Merged
merged 1 commit into from
Jun 22, 2022
Merged

Avoid lockup when running without arguments and stdin is connected to a tty #1112

merged 1 commit into from
Jun 22, 2022

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Jun 22, 2022

Up until commit 55287a8 "Run in diff mode iff two positional arguments
are supplied" diff mode was only supported when stdin is connected to a
tty, which meant that, for example, running delta a b in a git hook
would do the wrong thing.

As a fix, the tty check was removed, so now delta a b always works,
but the only error condition is now to pass only a single file. When
passing no files at all, we try parse to stdin even when connected to a
tty. Usually that wouldn't be that bad, because the user could press
Ctrl-C or Ctrl-D (EOF) to quit, unfortunately something in the pager
setup breaks this, and the only way to exit delta is to kill it.

Running delta with stdin connected to a tty would mean that the user
has to manually enter a diff (or paste it), which is not really an
expected scenario, as demonstrated by the error message that's currently
only emitted when running delta with only a single file argument. So
we can avoid the lockup by also emitting the error message when running
on a tty and there are no files to be diffed.

Fixes #1039, fixes #1090

… tty

Up until commit 55287a8 "Run in diff mode iff two positional arguments
are supplied" diff mode was only supported when stdin is connected to a
tty, which meant that, for example, running `delta a b` in a git hook
would do the wrong thing.

As a fix, the tty check was removed, so now `delta a b` always works,
but the only error condition is now to pass only a single file. When
passing no files at all, we try parse to stdin even when connected to a
tty. Usually that wouldn't be that bad, because the user could press
Ctrl-C or Ctrl-D (EOF) to quit, unfortunately something in the pager
setup breaks this, and the only way to exit `delta` is to kill it.

Running `delta` with stdin connected to a tty would mean that the user
has to manually enter a diff (or paste it), which is not really an
expected scenario, as demonstrated by the error message that's currently
only emitted when running `delta` with only a single file argument. So
we can avoid the lockup by also emitting the error message when running
on a tty and there are no files to be diffed.

Fixes #1039, fixes #1090
@dandavison
Copy link
Owner

Thanks a lot, LGTM!

@dandavison dandavison merged commit 37ea952 into dandavison:master Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants