{"thread":{"id":"10840","subject":"[PATCH] Beautify the output of send-pack a bit","startedAt":"2007-11-12T22:11:40Z","lastAt":"2007-11-13T07:55:23Z","messageCount":2,"participants":["Alex Riesen","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"59583","messageId":"20071112221140.GD2918@steel.home","threadId":"10840","inReplyTo":null,"subject":"[PATCH] Beautify the output of send-pack a bit","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-11-12T22:11:40Z","receivedAt":"2007-11-12T22:11:40Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Cluster the errors regarding ancestry violation and output them\nin one batch, together with a hint to pull before pushing.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nCatching trend...\n\n send-pack.c |   33 ++++++++++++++++++++++-----------\n 1 files changed, 22 insertions(+), 11 deletions(-)\n\ndiff --git a/send-pack.c b/send-pack.c\nindex d56d980..e6da567 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -215,6 +215,7 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \tint ask_for_status_report = 0;\n \tint allow_deleting_refs = 0;\n \tint expect_status_report = 0;\n+\tstruct ref *failed_refs = NULL, **failed_tail = &failed_refs;\n \n \t/* No funny business with the matcher */\n \tremote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);\n@@ -243,25 +244,27 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t * Finally, tell the other end!\n \t */\n \tnew_refs = 0;\n-\tfor (ref = remote_refs; ref; ref = ref->next) {\n+\tref = remote_refs;\n+\tremote_refs = NULL;\n+\tremote_tail = &remote_refs;\n+\tfor (; ref; ref = ref->next) {\n \t\tchar old_hex[60], *new_hex;\n \t\tint will_delete_ref;\n \n \t\tif (!ref->peer_ref)\n-\t\t\tcontinue;\n-\n+\t\t\tgoto remote_ok;\n \n \t\twill_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);\n \t\tif (will_delete_ref && !allow_deleting_refs) {\n \t\t\terror(\"remote does not support deleting refs\");\n \t\t\tret = -2;\n-\t\t\tcontinue;\n+\t\t\tgoto remote_ok;\n \t\t}\n \t\tif (!will_delete_ref &&\n \t\t    !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {\n \t\t\tif (verbose)\n \t\t\t\tfprintf(stderr, \"'%s': up-to-date\\n\", ref->name);\n-\t\t\tcontinue;\n+\t\t\tgoto remote_ok;\n \t\t}\n \n \t\t/* This part determines what can overwrite what.\n@@ -297,13 +300,9 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t\t\t\t * commits at the remote end and likely\n \t\t\t\t * we were not up to date to begin with.\n \t\t\t\t */\n-\t\t\t\terror(\"remote '%s' is not an ancestor of\\n\"\n-\t\t\t\t      \" local  '%s'.\\n\"\n-\t\t\t\t      \" Maybe you are not up-to-date and \"\n-\t\t\t\t      \"need to pull first?\",\n-\t\t\t\t      ref->name,\n-\t\t\t\t      ref->peer_ref->name);\n \t\t\t\tret = -2;\n+\t\t\t\t*failed_tail = ref;\n+\t\t\t\tfailed_tail = &ref->next;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n@@ -335,6 +334,18 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t\t\tfprintf(stderr, \"\\n  from %s\\n  to   %s\\n\",\n \t\t\t\told_hex, new_hex);\n \t\t}\n+\tremote_ok:\n+\t\t*remote_tail = ref;\n+\t\tremote_tail = &ref->next;\n+\t}\n+\t*remote_tail = NULL;\n+\t*failed_tail = NULL;\n+\n+\tif (failed_refs) {\n+\t\tfor (ref = failed_refs; ref; ref = ref->next)\n+\t\t\terror(\"remote '%s' is not an ancestor of local '%s'\",\n+\t\t\t      ref->name, ref->peer_ref->name);\n+\t\tfprintf(stderr, \"Maybe you are not up-to-date and need to pull first?\\n\");\n \t}\n \n \tpacket_flush(out);\n-- \n1.5.3.5.648.g1e92c\n"},{"id":"59628","messageId":"20071113075523.GB21799@sigill.intra.peff.net","threadId":"10840","inReplyTo":"20071112221140.GD2918@steel.home","subject":"Re: [PATCH] Beautify the output of send-pack a bit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-13T07:55:23Z","receivedAt":"2007-11-13T07:55:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 12, 2007 at 11:11:40PM +0100, Alex Riesen wrote:\n\n> Cluster the errors regarding ancestry violation and output them\n> in one batch, together with a hint to pull before pushing.\n\nI think this is a good direction, but I think it might be simpler if\njust record error information for each ref as we go, and then dump all\nof them at the end. That will let us add remote-generated error\ninformation easily.\n\n-Peff\n"}]}