-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
1422 Properly Color Failed Remote Push Messages #1429
Conversation
That looks pretty awesome already! I am mostly offline this week, and Git v2.16.0 is probably coming out in a few hours (meaning: I'll have to spend some time on Git for Windows v2.16.0, despite being theoretically offline), but I will definitely review this PR properly next week (unless somebody else beats me to it). Thank you so much for working on this! |
6c5dcbc
to
9fb3edf
Compare
@maplion The spelling Please also squash the following commits into one:
Because of the way |
@kgybels Roger, roger. I think I follow all your requests and will do my best to amend this. Thank you. |
9fb3edf
to
20fe102
Compare
@maplion you're doing real great! FYI I am planning on releasing another Git for Windows version tomorrow (there have been a couple of CVEs in components used by Git for Windows, and while they all do not quite look exploitable to me, I would rather be safe than sorry), and should have time to review this PR properly after that. Sorry for the delay! |
20fe102
to
64a7848
Compare
bb15d03
to
3016f0c
Compare
@kgybels I think all has been updated as requested:
Let me know if I missed anything. Thank you. |
@@ -20,6 +21,33 @@ int advice_add_embedded_repo = 1; | |||
int advice_ignored_hook = 1; | |||
int advice_waiting_for_editor = 1; | |||
|
|||
static int advice_use_color = -1; |
@@ -59,7 +87,8 @@ void advise(const char *advice, ...) | |||
|
|||
for (cp = buf.buf; *cp; cp = np) { | |||
np = strchrnul(cp, '\n'); | |||
fprintf(stderr, _("hint: %.*s\n"), (int)(np - cp), cp); | |||
fprintf(stderr, _("%shint: %.*s%s\n"), advise_get_color(ADVICE_COLOR_HINT), | |||
(int)(np - cp), cp, advise_get_color(ADVICE_COLOR_RESET)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
error(_("failed to push some refs to '%s'"), transport->url); | ||
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_RESET)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -326,7 +354,11 @@ static void print_ref_status(char flag, const char *summary, | |||
else | |||
fprintf(stdout, "%s\n", summary); | |||
} else { | |||
fprintf(stderr, " %c %-*s ", flag, summary_width, summary); | |||
if (strstr(summary, "rejected") != NULL || strstr(summary, "failure") != NULL) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This looks pretty good already, and you took it already farther than I can help: I do not really know core Git's preference regarding coloring of So I would really like to take this to the Git mailing list. Before I can do that, can I ask you to provide a commit message? There are a couple of really important things that the commit message should do:
Maybe a good example to follow would be cf2f735. Or git-for-windows/build-extra@a64fe115. We even have a wiki page that should give some good advice about writing commit messages: https://github.com/git-for-windows/git/wiki/Good-commits Once you have this commit message, and once you have given your okay to contribute this to the Git mailing list, I will take it from there. Deal? |
@dscho Thank you for the information. I'll review this in length when I get the chance and will be happy to assist updating the necessaries to help you get this into the Git email chain if that is the next step. |
Thanks, @maplion! |
This is an attempt to resolve an issue I experience with people that are new to Git -- especially colleagues in a team setting -- where they miss that their push to a remote location failed because the failure and success both return a block of white text. An example is if I push something to a remote repository and then a colleague attempts to push to the same remote repository and the push fails because it requires him to pull first, but he doesn't notice because a success and failure both return a block of white text. He then continues about his business, thinking it has been successfully pushed. My solution was to try to change the stderr and hint colors (red and yellow, respectively) so whenever there is a failure when pushing to a remote repository that fails, it is more noticeable. The challenge was that it seemed that stderr has never been colored and I attempted to utilize what was already established; but this meant using functions like want_color() even if it targets stdout while I wanted to target stderr. Additionally, to check for all rejection types, I did a strstr check in transport.c, but this code could be problematic if there is need for translation. Signed-off-by: Ryan Dammrose ryandammrose@gmail.com
3392faa
to
81981e3
Compare
@dscho I think things should be ready for you to take to the Git mailing list. Sorry it took me so long -- been a busy week. Let me know if you need anything else. |
Finally managed to contribute it (with a little touchups: compiling it with |
@dscho I was just checking in to see what the status of this was? I was curious if there is a chance we'll see it in a release in the near future? |
@maplion sorry, this fell completely off my radar! Thanks for the prod! |
Phew. Five hours... here's the result: |
@dscho thanks a lot for the view into the discussion; it's a good learning experience. |
Certain errors, e.g. when pushing failed due to a non-fast-forwarding change, [are now colorful](git-for-windows/git#1429). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
area: transport.c, push.c, advice.c
problem: This is an attempt to resolve an issue I experience with people that are new to Git -- especially colleagues in a team setting -- where they miss that their push to a remote location failed because the failure and success both return a block of white text.
solution: I received some guidance from the community on how to do it myself and I did my best to model after existing code (especially since C is not my wheelhouse). When a push to remote errors/is rejected/fails, the output text for the rejection message and the error is colored red and the advice hints are colored yellow.
Before:
After:
#1422 (comment)
Signed-off-by: Ryan Dammrose ryandammrose@gmail.com