[vim/vim] Vim: Warning: Output is not to a terminal (Issue #12071)

37 views
Skip to first unread message

huang bin bin

unread,
Feb 26, 2023, 11:48:16 AM2/26/23
to vim/vim, Subscribed

Steps to reproduce

1.git config difftool = vimdiff ,
2.use git difftool open vimdiff compare git index file .
3. execute :r ! git diff or !git diff > newfile then you will see bash get hung, it can't back to vim . yout will have to ctrl+z to back terminal ,but vim and previous bash process still alive background.

by the way, use vim without git , this bug can't reproduct,even in vimdiff mode

Expected behaviour

git difftool = vimdiff
compare git index , can use "!git diff >newfile" write data to a new file

Version of Vim

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 25 2021 21:26:36)

Environment

windows
git bash
xterm

Logs and stack traces

none


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12071@github.com>

Gary Johnson

unread,
Feb 26, 2023, 4:57:32 PM2/26/23
to reply+ACY5DGD2D4LMQXBUOL...@reply.github.com, vim...@googlegroups.com
On 2023-02-26, huang bin bin wrote:
> Steps to reproduce
>
> 1.git config difftool = vimdiff ,
> 2.use git difftool open vimdiff compare git index file .
> 3. execute :r ! git diff or !git diff > newfile then you will see bash get
> hung, it can't back to vim . yout will have to ctrl+z to back terminal ,but vim
> and previous bash process still alive background.
>
> by the way, use vim without git , this bug can't reproduct,even in vimdiff mode
>
> Expected behaviour
>
> git difftool = vimdiff
> compare git index , can use "!git diff >newfile" write data to a new file
>
> Version of Vim
>
> VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 25 2021 21:26:36)
>
> Environment
>
> windows
> git bash
> xterm

I can reproduce this with:

- Vim 9.0.1355
- Git 2.34.1
- Ubuntu 22.04

I made sure my vimrc was not a factor by creating a file named vim
in my home directory:

#!/bin/bash
exec /usr/local/bin/vim -N -u NONE -i NONE "$@"

and starting git like this:

$ PATH=$HOME:$PATH git difftool

:r!git diff

I did notice that with my normal vimrc, the ":r!git diff" command
does not hang Vim, but instead inserts these three lines into the
buffer:

Vim: Warning: Output is not to a terminal
^[[24;1H^[[23;2t^[[23;1t^[[J2 files to edit
fatal: external diff died, stopping at src/search.c

where those ^[ are Vim's rendering of escape characters and
src/search.c is the only modified file in my Vim repo, where I ran
these commands. The difference is probably due to some workarounds
in my vimrc for other problems Vim has with launching sub-shells.
I haven't tried to identify the settings that affect this problem.

Regards,
Gary

vim-dev ML

unread,
Feb 26, 2023, 4:57:53 PM2/26/23
to vim/vim, vim-dev ML, Your activity

On 2023-02-26, huang bin bin wrote:
> Steps to reproduce
>
> 1.git config difftool = vimdiff ,
> 2.use git difftool open vimdiff compare git index file .
> 3. execute :r ! git diff or !git diff > newfile then you will see bash get
> hung, it can't back to vim . yout will have to ctrl+z to back terminal ,but vim
> and previous bash process still alive background.
>
> by the way, use vim without git , this bug can't reproduct,even in vimdiff mode
>
> Expected behaviour
>
> git difftool = vimdiff
> compare git index , can use "!git diff >newfile" write data to a new file
>
> Version of Vim
>
> VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 25 2021 21:26:36)
>
> Environment
>
> windows
> git bash
> xterm

I can reproduce this with:

- Vim 9.0.1355
- Git 2.34.1
- Ubuntu 22.04

I made sure my vimrc was not a factor by creating a file named vim
in my home directory:

#!/bin/bash
exec /usr/local/bin/vim -N -u NONE -i NONE "$@"

and starting git like this:

$ PATH=$HOME:$PATH git difftool

:r!git diff

I did notice that with my normal vimrc, the ":r!git diff" command
does not hang Vim, but instead inserts these three lines into the
buffer:

Vim: Warning: Output is not to a terminal
^[[24;1H^[[23;2t^[[23;1t^[[J2 files to edit
fatal: external diff died, stopping at src/search.c

where those ^[ are Vim's rendering of escape characters and
src/search.c is the only modified file in my Vim repo, where I ran
these commands. The difference is probably due to some workarounds
in my vimrc for other problems Vim has with launching sub-shells.
I haven't tried to identify the settings that affect this problem.

Regards,
Gary


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12071/1445477869@github.com>

huang bin bin

unread,
Feb 26, 2023, 9:51:36 PM2/26/23
to vim/vim, vim-dev ML, Comment

if use git difftool open vimdiff, execute :!git diff
it will not print patch to screen ,
but open a new vimdiff process


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1445607260@github.com>

Gary Johnson

unread,
Feb 26, 2023, 10:16:01 PM2/26/23
to vim...@googlegroups.com, reply+ACY5DGD2D4LMQXBUOL...@reply.github.com
This appears to be a bug in git rather than a bug in vim. The 'git
diff' command normally pipes a context diff to less. Under the
conditions of this bug report, it appears that git is using 'vim -d
...' _and_ piping the output to less. I can't tell exactly what git
thinks it's doing, but I think I've found a workaround: after
executing 'git difftool', in Vim, execute:

:unlet $GIT_EXTERNAL_DIFF

before executing ':r!git diff' or any other git command. That could
probably be put in your vimrc, but I haven't tried that yet to check
for side-effects.

HTH,
Gary

vim-dev ML

unread,
Feb 26, 2023, 10:16:20 PM2/26/23
to vim/vim, vim-dev ML, Your activity

On 2023-02-26, Gary Johnson wrote:
> On 2023-02-26, huang bin bin wrote:
> > Steps to reproduce
> >
> > 1.git config difftool = vimdiff ,
> > 2.use git difftool open vimdiff compare git index file .
> > 3. execute :r ! git diff or !git diff > newfile then you will see bash get
> > hung, it can't back to vim . yout will have to ctrl+z to back terminal ,but vim
> > and previous bash process still alive background.
> >
> > by the way, use vim without git , this bug can't reproduct,even in vimdiff mode
> >
> > Expected behaviour
> >
> > git difftool = vimdiff
> > compare git index , can use "!git diff >newfile" write data to a new file
> >
> > Version of Vim
> >
> > VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 25 2021 21:26:36)
> >
> > Environment
> >
> > windows
> > git bash
> > xterm
>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12071/1445629123@github.com>

huang bin bin

unread,
Feb 26, 2023, 10:28:47 PM2/26/23
to vim/vim, vim-dev ML, Comment

i will try once i get free time
thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1445639007@github.com>

huang bin bin

unread,
Feb 27, 2023, 9:19:35 AM2/27/23
to vim/vim, vim-dev ML, Comment

1111
Now I can selected some lines or whole of hunk to do git stage in vimdiff ,thank you very mush


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1446404720@github.com>

ben.k...@gmail.com

unread,
Feb 27, 2023, 9:52:16 AM2/27/23
to vim_dev
Documented in `man git`, though not that using `git difftool` sets the variable. 

Bram Moolenaar

unread,
Feb 27, 2023, 4:00:36 PM2/27/23
to vim/vim, vim-dev ML, Comment

So, can this issue be closed, or should we change something in Vim?
E.g. adding that :unlet command in the diff filetype plugin?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1447080822@github.com>

huang bin bin

unread,
Feb 27, 2023, 8:28:11 PM2/27/23
to vim/vim, vim-dev ML, Comment

Closed #12071 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/12071/issue_event/8621890230@github.com>

Gary Johnson

unread,
Feb 27, 2023, 9:10:23 PM2/27/23
to reply+ACY5DGCXZ5DOEU6VSL...@reply.github.com, vim...@googlegroups.com
On 2023-02-27, Bram Moolenaar wrote:
> So, can this issue be closed, or should we change something in Vim?
> E.g. adding that :unlet command in the diff filetype plugin?

I think it could be closed, but it's not my issue. I don't think
there is anything to change in Vim. There are a few other GIT_
environment variables that I unlet in my vimrc because their
presence causes odd behavior of git commands launched from Vim or in
subshells of Vim, but some users may want to know about the presence
of those variables or their values, so I wouldn't automatically
unlet them in, say, defaults.vim.

The "git difftool" command opens files in their normal file type, so
the diff filetype plugin wouldn't apply. By the time the "git diff"
command is executed, it's too late to change the command's behavior.
At least that's what I observe with my bash, git and Vim
configurations.

Regards,
Gary

vim-dev ML

unread,
Feb 27, 2023, 9:10:44 PM2/27/23
to vim/vim, vim-dev ML, Your activity


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12071/1447460846@github.com>

huang bin bin

unread,
Mar 4, 2023, 3:54:41 AM3/4/23
to vim/vim, vim-dev ML, Comment

use git difftool open vimdiff in ubuntu , can't execute successly :unlet $GIT_EXTERNAL_DIFF ,
will get error E488: Trailing characters when executed
i typed this command one by one,still got E488: Trailing characters
ubuntu version

***@***:~/source/repos/dv-detector/dv_ui$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial

vim version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 13 2020 16:04:38)
Included patches: 1-1689
Extra patches: 8.0.0056
Modified by pkg-vim-m...@lists.alioth.debian.org
Compiled by pkg-vim-m...@lists.alioth.debian.org
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
+balloon_eval    +float           +mouse_urxvt     +tcl
+browse          +folding         +mouse_xterm     +terminfo
++builtin_terms  -footer          +multi_byte      +termresponse
+byte_offset     +fork()          +multi_lang      +textobjects
+channel         +gettext         -mzscheme        +timers
+cindent         -hangul_input    +netbeans_intg   +title
+clientserver    +iconv           +packages        +toolbar
+clipboard       +insert_expand   +path_extra      +user_commands
+cmdline_compl   +job             +perl            +vertsplit
+cmdline_hist    +jumplist        +persistent_undo +virtualedit
+cmdline_info    +keymap          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  +lua             +rightleft       +writebackup
+diff            +menu            +ruby            +X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     +xsmp_interact
+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard
+eval            +mouse_dec       +statusline      -xterm_save
+ex_extra        +mouse_gpm       -sun_workshop    +xpm
+extra_search    -mouse_jsbterm   +syntax          
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircore -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm     

bash version

4.3.48(1)-release

terminal

GNOME Terminal 3.18.3

i tested this vim command in windows , macOs, both work well
but ubuntu not, so i open this issue again


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1454668343@github.com>

huang bin bin

unread,
Mar 4, 2023, 3:55:55 AM3/4/23
to vim/vim, vim-dev ML, Comment

Reopened #12071.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/12071/issue_event/8665617049@github.com>

huang bin bin

unread,
Mar 4, 2023, 3:56:11 AM3/4/23
to vim/vim, vim-dev ML, Comment

open


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1454668598@github.com>

Christian Brabandt

unread,
Mar 4, 2023, 5:09:47 AM3/4/23
to vim/vim, vim-dev ML, Comment

your Vim may be too old to unlet environment variables. you may try :! GIT_EXTERNAL_DIFF= git diff , not sure if this works.

Also please note, Ubuntu 16.04 LTS is end-of-life for almost 2 years already.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1454687252@github.com>

Christian Brabandt

unread,
Mar 4, 2023, 5:34:56 AM3/4/23
to vim/vim, vim-dev ML, Comment

Note you can also try: git diff --no-ext-diff


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1454693587@github.com>

huang bin bin

unread,
Mar 4, 2023, 7:21:17 AM3/4/23
to vim/vim, vim-dev ML, Comment

Note you can also try: git diff --no-ext-diff

where you found git diff --no-ext-diff , it is that i search long time thing


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/12071/1454721821@github.com>

huang bin bin

unread,
Mar 4, 2023, 11:43:41 PM3/4/23
to vim/vim, vim-dev ML, Comment

Closed #12071 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/12071/issue_event/8667319740@github.com>

Reply all
Reply to author
Forward
0 new messages