I have some colleagues that occasionally have issues with Git [in a team setting] simply because they miss the message when a push is made prior to a required pull and they miss the message that it failed to successfully push. This is because a success shows a block of white text and a failure shows a block of white text. It would make sense for usability purposes if a git push origin <branch name> fails, for example, that the text returned is a different color (e.g. yellow/red). I tried to find ways to do this in Windows Git Bash and it seems less than trivial -- and I also think it is something that should be built in; so I am requesting this feature.
Example message:
$ git --version --build-options
git version 2.15.0.windows.1
built from commit: ed3d106bc93775b62b3860176d7501e079a089b9
sizeof-long: 4
machine: x86_64
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.16299.125]
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
no
Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
Git Bash
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
`git push origin <branch name>` when a pull is required first
Not relevant
Not relevant
@maplion can you attach screenshots of the error messages, for completeness?
Also, I think this might need to be addressed in Git core, rather than Git for Windows. But we can talk about that in more detail later.
It would make sense for usability purposes if a git push origin
fails, for example, that the text returned is a different color (e.g. yellow/red). I tried to find ways to do this in Windows Git Bash and it seems less than trivial -- and I also think it is something that should be built in; so I am requesting this feature.
That's a good idea.
Please understand that this project is not lacking in feature requests, but seriously lacking in contributors implementing said features.
So here is a New Year's challenge for you: implement the desired feature yourself. It is not witch craft, look at how many contributors succeed in adding their work to Git: https://github.com/git/git/pulse
There are essentially two options:
if you are a command-line person: install Git for Windows' SDK
if you are more of an IDE person, compile Git using Visual Studio
The easiest way is to use git grep on a substring of the message, e.g. git grep 'Could not push' (I do not know the exact message, you will have to adjust this obviously).
To add color to stuff you print, look at the functions provided by color.h, most likely color_fprintf() or color_print_strbuf() is what you will need.
Once you build, you should use the Git in-place, which takes a little fiddling:
/path/to/git/git.exe --exec-path=/path/to/git push ...
where /path/to/git is the absolute path of the directory where you built Git, e.g. /c/git-sdk-64/usr/src/git.
To test this, you probably want to create a toy project using git init, add a couple of dummy commits and then clone it to simulate the situation of your co-workers.
Open a Pull Request and earn glory ;-)
If there is anything unclear, do not hesitate to ask away. Once you have code to show, a Pull Request will do fine (mark it as [Do not merge yet]), before that this here ticket will do just fine.
@shiftkey Yes, I thought that might be the case, but since I am primarily using Git for Windows, I figured I'd start here and work up if needed.
Screenshot was added.
@dscho Thank you for the information. If I get a spot of free time, I'll take you up on your challenge.
@dscho I am having difficulty in building my project. I went with the IDE option running it in Visual Studio with the solution file. With a fresh pull (no changes), it doesn't seem to recognize a lot of identifiers, such as stderr, time_t, FILE, SSL, DWORD, etc., etc. Is there a library or something I am missing? I thought it had me install what it needed when I first loaded the solution. Any recommendations on how to resolve this [I haven't done anything in C in about 20 years]?
@maplion Which of the steps had you done, and which not?
I'm suspecting that you may need something that is downloaded via the SDK, even though you are using the Visual Studio build process. It (compiling) will depend on the state of the repository work tree, and if bits are 'missing' they maybe part of the SDK's download (most contributors at some time or other have downloaded the SDK, so that may be where the mising definitions are hidden).
Philip
@PhilipOakley I'm suspecting that you may need something that is downloaded via the SDK, even though you are using the Visual Studio build process.
Our own documentation states that the SDK is not necessary:
When building Git in Visual Studio, you do not actually need a full-blown Git for Windows SDK.
@maplion I also had issues building the solution when investigating a bug over the weekend. The problem is that the projects are not being build in the correct order.
Try the following:
git clean -xdff && git reset --hardStep 3. will take long because it will trigger:
<PreBuildEvent Condition="!Exists('..\compat\vcbuild\vcpkg')">
<Message>Initialize VCPKG</Message>
<Command>call "..\compat\vcbuild\vcpkg_install.bat" </Command>
</PreBuildEvent>
That script will download, compile and install all the packages that are needed.
@kgybels Thank you. The key was step 3. Step 4 didn't work for me; complained about a missing file, but I was able to compile the whole solution successfully anyway.
How do I run the test suite?
Also, could someone explain the documentation and how to properly contribute to it in my case [not sure how this particular change would be relevant to the documentation I am seeing]?
How do I create a production-like build so I can use it in the mean time?
@maplion How do I create a production-like build so I can use it in the mean time?
Check the Making an installer and Making a portable Git topics on the wiki, both methods require you to install the Git for Windows SDK though.
I think it would also work to install a Git for Windows release, and then copy a release build over the provided git.exe. However, do keep in mind that there are lots of files hardlinked to it, so you might need to update those as well.
@kgybels thank you again. I will try out the SDK for the learning experience, if nothing else.
Coming v2.18.0? 馃槂 https://github.com/git/git/commit/a56fb3dcc09239795823de40ffcbbf5713114eb5
@michaelblyons Looks that way. 馃帀
Yaaaaay! It only took, what, 3 iterations to get it into core Git...
Most helpful comment
@michaelblyons Looks that way. 馃帀