Make cmd.exe ignore other key presses in git log --graph --all

57 views
Skip to first unread message

skybuck2000

unread,
Nov 20, 2021, 8:37:30 PM11/20/21
to git-for-windows
This toshiba L670 laptop is kinda annoying: page up/page down at the top above numpad... makes me hit * - while trying to scroll.

This causes cmd.exe to read these keys and then it can no longer scroll... have to mess with it to get out of that situation:

Example:
--*-*-*-ESC-*ESC-*ESC-*-*-*ESC[6~ESC[6~ESC[6~ESC[5~ESC[5~ESC[5~

There is no --*-*-*-***-*-*[6~option  (press RETURN)

^ Quite annoying and maybe dangerous

Have to press return first.

If - * can be disabled then great ???

Apperently cmd.exe or git.exe thinks I want to enter some kind of option ???

By pressing * or - ???

git bash does not have this issue.

Bye,
  Skybuck

Konstantin Khomoutov

unread,
Nov 21, 2021, 5:59:19 AM11/21/21
to skybuck2000, git-for-windows
Judging from the description, what you experience is `git log` piping its
output to a so-called "pager" [1] wich is `less` [2] (a Windows port of it).

Less is an interactive program which reacts on several keypresses - other than
arrow keys and PgUp/PgDown keys, and in particular, pressing the '-' key is
considered by less as starting a key combo designating an option to switch -
for instance, you'd dribble '-', 'i', Enter, to toggle the case-sensisitevess
the search (hence 'i') or, say, '-', 'S', Enter toggles chopping or wrapping
of overlong lines.

From cursory glancing of the less' manual page, I failed to gather if it
supports turning (most) of its interactive features off; looks like it doesn't.

If so, I would recommend to switch to another pager which does not react to
pressing of the '-' key. For instance, you could try `most` [3] which also has
a Windows port.

To change a pager Git uses, set the GIT_PAGER environment variable (see the
root Git's manual page for more info; you could do that by running
`git help git`).

1. https://en.wikipedia.org/wiki/Terminal_pager
2. https://en.wikipedia.org/wiki/Less_(Unix)
3. http://www.jedsoft.org/most/index.html

skybuck2000

unread,
Nov 22, 2021, 8:03:29 PM11/22/21
to git-for-windows
Judging from the description, what you experience is `git log` piping its
output to a so-called "pager" [1] wich is `less` [2] (a Windows port of it).

I think something slightly different might be going on.

There are two environments on my machine I think:

Environment 1: git-bash.exe which may run inside some kind of linux terminal/emulator/mingw which runs git.exe inside this mingw emulator.
Environment 2: cmd.exe which runs inside windows/ms-dos terminal which runs git.exe

The problem I described is with the cmd.exe environment.

As far as I can tell less.exe is not available and an invalid command.

So git.exe in ms-dos must be calling something else ? most like more.exe ?

So the problem could be with more.exe.

I have checked '.git/config' file and then under
[core]

there is no pager entry.
 
Less is an interactive program which reacts on several keypresses - other than
arrow keys and PgUp/PgDown keys, and in particular, pressing the '-' key is
considered by less as starting a key combo designating an option to switch -
for instance, you'd dribble '-', 'i', Enter, to toggle the case-sensisitevess
the search (hence 'i') or, say, '-', 'S', Enter toggles chopping or wrapping
of overlong lines.

I think you might be barking up the wrong tree. Perhaps you can figure this out for more.exe ? or more ?

Not sure if it's an executable, com file or build-in command for cmd.exe.
 
From cursory glancing of the less' manual page, I failed to gather if it
supports turning (most) of its interactive features off; looks like it doesn't.

less is probably being used inside the git-bash/mingw terminal emulator that could explain why git-bash.exe does not seem to have this problem.
 
If so, I would recommend to switch to another pager which does not react to
pressing of the '-' key. For instance, you could try `most` [3] which also has
a Windows port.

I am not sure how I can change the pager for cmd.exe if this is truely the problem.
 
To change a pager Git uses, set the GIT_PAGER environment variable (see the
root Git's manual page for more info; you could do that by running
`git help git`).


I could try this, the benefit of this is that it does not affect the git-bash since it will read the .git\config as well.

So to keep git-bash intact an enviroment variable only affecting cmd.exe would indeed be best.
Thanks for explanation !

Bye,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 8:15:12 PM11/22/21
to git-for-windows

The strange thing however is, when I run:

cmd.exe

and then

more example.txt

The weird behaviour is not present, which casts doubts on my hypothesis.

(*- has no effect in more.exe)

Bye for now,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 8:28:56 PM11/22/21
to git-for-windows
Funny stuff, I decided to give it a try because it can't hurt to try:

cmd.exe
set GIT_PAGER=more
git log --graph --all

The effect of this is that it keeps scrolling forever until the end of the log is reached, no control.

This at least proves that git is using something else and I think I know where to find it.

The path variable was modified to include a path to the bin folder of git.

E:\Tools\PortableGit\bin

There are only 3 executables in there:

git.exe
bash.exe
sh.exe

I was expecting to find less.exe or something else... but nope... hmm mystified.

Maybe the pager is build into git.exe itself

or git is using tricks like ..\ to load something from it's folder.

I may have been correct:

E:\Tools\PortableGit\usr\bin

does contain less.exe

This is a bit strange... but ok...

I will give less.exe a go

E:\Tools\PortableGit\usr\bin\less.exe SomeFile.txt

There is no -* option  (press RETURN)

You were right and I was wrong ! HAHA. Git surprised me here a little bit ! Fun times ! =D

It is indeed sneaky sneaky using that usr\bin folder, well at least I was right about that :)

There were no other git variables setup in the environment so git.exe must be using some folder tricks to find that.

less.exe does not run stand alone it needs msys-2.0.dll at the very least which is 3 MB.

OK well now I at least know the cause of the problem and now to work on your suggestion to find a replacement ! ;) =D

So far the only thing cmd.exe does not do is display the active branch in the prompt.

So it would be cool if prompt could be changed

so instead

C:\SomeFolder

it would read:

C:\SomeFolder\ [/Master]

Or something like that preferably with colors too.

I do know there is a command in ms-dos to setup the prompt, so it might somehow be possible ! ;)

For example drive letter and drive folder can be specified I think it was something like $p$g or something.

My have to check the ms-dos 6.0 book on this or maybe it's somewhere on the internet as well.. a tip for this ! ;)

Bye for now,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 8:36:41 PM11/22/21
to git-for-windows
If so, I would recommend to switch to another pager which does not react to
pressing of the '-' key. For instance, you could try `most` [3] which also has
a Windows port.

To change a pager Git uses, set the GIT_PAGER environment variable (see the
root Git's manual page for more info; you could do that by running
`git help git`).

1. https://en.wikipedia.org/wiki/Terminal_pager
2. https://en.wikipedia.org/wiki/Less_(Unix)
3. http://www.jedsoft.org/most/index.html

HOUSTON WE HAVE A PROBLEM:

So far I only see source code distributions ? No executables ?


Bye for now,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 8:46:35 PM11/22/21
to git-for-windows
Found the manual that was not so hard :) :


_ (Underscore.) Followed by one of the command line option letters, this will print a message describing the current setting of that option. The setting of the option is not changed.

__ (Double underscore.) Like the _ (underscore) command, but takes a long option name rather than a single option letter. You must press ENTER or RETURN after typing the option name.

^ This is what is tripping me up.

You were trying to find a way to turn this off... hmmm....

Bye for now,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 8:47:46 PM11/22/21
to git-for-windows
And also this from manual:

OPTIONS         top Command line options are described below. Most options may be changed while less is running, via the "-" command.

Bye for now,
  Skybuck.

skybuck2000

unread,
Nov 22, 2021, 9:10:10 PM11/22/21
to git-for-windows
Pressing H shows the help screen of less but nothing special in there.

Well my conclusion so far is:

1. Somehow git-bash.exe is using a (different version of?) less where this - and -- is disabled somehow.

2. There is no documented option in less.exe to turn this interactive - and -- mode off.

Perhaps inspecting source code of less might reveal if there is something undocumented to turn it off.

Bye for now,
  Skybuck.

Konstantin Khomoutov

unread,
Nov 23, 2021, 9:27:03 AM11/23/21
to skybuck2000, git-for-windows
On Mon, Nov 22, 2021 at 05:03:28PM -0800, skybuck2000 wrote:

[...]

> There are two environments on my machine I think:
>
> Environment 1: git-bash.exe which may run inside some kind of linux
> terminal/emulator/mingw which runs git.exe inside this mingw emulator.

MinGW is a software package developed to help port POSIX-compatible software
to the Windows platform with as less modifications as possible - while still
remaining native to the target platform.
MinGW stands for "Minimalist GNU for Windows"; GNU is a bit out-of-place in
that context though, because GNU is a software project which strives to
eventually produce a complete operating system which is "free-as-in-freedom".
In the context of MinGW, 'G' is better thought of as standing for "GCC" which
is a GNU Compiler Collection - a free implementation of compilers for several
popular programming languages, including C and C++.

Last time I checked, Git for Windows was built using MinGW, and I would say
it's the only place where MinGW appears in the picture when we're talking
about Git on Windows.

Regarding the other two points - Git for Windows does come with a Windows port
of bash which is a command-line shell typically used in Linux-based operating
systems, and MinTTY - which is Unix terminal emulator for Windows.

The Bash shell shipped with GfW is called "Git Bash" - primarily because the
devs had to give that thing a name to be able to display it in various context
menus displayed by Windows Explorer (the graphical shell providing the user
with the desktop, start menu, taskbar etc).
Still, on Windows, bash can be run both in MinTTY and in a standard console
window (cmd.exe).

The only thing which could be called "emulator" here is MinTTY - as it indeed
emulates a hardware Unix terminal.

> Environment 2: cmd.exe which runs inside windows/ms-dos terminal which runs
> git.exe

I recommend to refrain from using the term "MS-DOS" when talking about the
stock console program, cmd.exe, - unless you're running Windows 95 or 98 (or
ME): all flavors of Windows based on NT kernel series (Windows NT since 1.0
and "desktop" flavors beginning with Windows 2000) have nothing to do with
MS-DOS, just the command set and batch file syntax supported in cmd.exe
reproduces that of the last release of MS-DOS quite faithfully, but still it's
a 100% Windows-native implementation.

[...]

---

While we're at it, can I please ask you to refrain from bursting short e-mails
following your research and thought process? This is a mailing list, not a
chat; most folks check it only occasionally, and it's not convenient to see
like 5 or 6 e-mail replies to a single message - all dealing with the same
problem. Honestly, I got lost on may be the third of them; I would much prefer
a single thought-out reply with the final set of observations, conclusions and
further questions, if any, based on them.

Thanks in advance.

skybuck2000

unread,
Nov 24, 2021, 3:20:35 PM11/24/21
to git-for-windows
OK,

The main problem is there is no executable of most.exe.

Can you or anybody else build on for windows ? :)

I would like to try out most.exe to see what it is like compared to less.exe.

Bye,
  Skybuck.
Reply all
Reply to author
Forward
0 new messages