Skip to content

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

Merged
dandavison merged 1 commit intodandavison:masterfrom
dotdash:fix_lockup_on_no_args
Jun 22, 2022
Merged

Avoid lockup when running without arguments and stdin is connected to a tty#1112
dandavison merged 1 commit intodandavison:masterfrom
dotdash:fix_lockup_on_no_args

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

Development

Successfully merging this pull request may close these issues.

Executing the delta command alone causes program to lock🐛 🐛 Running delta with no args doesn't print anything, can't be exited with CTRL-c

2 participants