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

Properly Color Failed Remote Push Messages #1422

Closed
maplion opened this issue Jan 7, 2018 · 16 comments
Closed

Properly Color Failed Remote Push Messages #1422

maplion opened this issue Jan 7, 2018 · 16 comments

Comments

@maplion
Copy link

maplion commented Jan 7, 2018

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-push-message

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
    64-bit
$ git --version --build-options
git version 2.15.0.windows.1
built from commit: ed3d106bc93775b62b3860176d7501e079a089b9
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
    Windows 10 64-bit
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.16299.125]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
    defaults
# 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

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

no

Details

  • 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
  • What did you expect to occur after running these commands?

Not relevant

  • What actually happened instead?

Not relevant

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?
    Not relevant
@shiftkey
Copy link

shiftkey commented Jan 8, 2018

@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.

@dscho
Copy link
Member

dscho commented Jan 8, 2018

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

Step 1: decide how you want to develop this

There are essentially two options:

Step 2: identify the code that prints the message you want color-coded

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).

Step 3: use color

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.

Step 4: test locally

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.

Step 5: contribute

Open a Pull Request and earn glory ;-)

Questions?

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.

@maplion
Copy link
Author

maplion commented Jan 8, 2018

@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.

@maplion
Copy link
Author

maplion commented Jan 8, 2018

@dscho Thank you for the information. If I get a spot of free time, I'll take you up on your challenge.

@maplion
Copy link
Author

maplion commented Jan 15, 2018

@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]?

capture

@PhilipOakley
Copy link

@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

@kgybels
Copy link

kgybels commented Jan 15, 2018

@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:

  1. Get back into a clean state, execute on repository root directory:
    git clean -xdff && git reset --hard
  2. Open git.sln with Visual Studio
  3. Build project libgit (right-click project in Solution Explorer, select Build)
  4. Build project git-remote-http
  5. Build solution

Step 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.

@maplion
Copy link
Author

maplion commented Jan 15, 2018

@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.

@maplion
Copy link
Author

maplion commented Jan 16, 2018

How do I run the test suite?

@maplion
Copy link
Author

maplion commented Jan 16, 2018

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]?

@maplion
Copy link
Author

maplion commented Jan 16, 2018

How do I create a production-like build so I can use it in the mean time?

@kgybels
Copy link

kgybels commented Jan 16, 2018

@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.

@maplion
Copy link
Author

maplion commented Jan 16, 2018

@kgybels thank you again. I will try out the SDK for the learning experience, if nothing else.

@michaelblyons
Copy link

Coming v2.18.0? 😃 git@a56fb3d

@maplion
Copy link
Author

maplion commented May 16, 2018

@michaelblyons Looks that way. 🎉

@dscho
Copy link
Member

dscho commented May 16, 2018

Yaaaaay! It only took, what, 3 iterations to get it into core Git...

@dscho dscho added this to the v2.17.0(2) milestone May 17, 2018
@dscho dscho closed this as completed in b911995 May 17, 2018
dscho added a commit that referenced this issue May 29, 2018
To help users discern large chunks of white text (when the push
succeeds) from large chunks of white text (when the push fails), let's
add some color to the latter.

This closes #1429 and fixes
#1422

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 29, 2018
To help users discern large chunks of white text (when the push
succeeds) from large chunks of white text (when the push fails), let's
add some color to the latter.

This closes #1429 and fixes
#1422

Signed-off-by: Johannes Schindelin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants