{"thread":{"id":"14490","subject":"[PATCH] Reformat \"your branch has diverged...\" lines to reduce line length.","startedAt":"2008-07-16T19:19:27Z","lastAt":"2008-07-16T22:03:16Z","messageCount":4,"participants":["Avery Pennarun","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83567","messageId":"1216235967-9510-1-git-send-email-apenwarr@gmail.com","threadId":"14490","inReplyTo":null,"subject":"[PATCH] Reformat \"your branch has diverged...\" lines to reduce line length.","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-16T19:19:27Z","receivedAt":"2008-07-16T19:19:27Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"The message length depends on the length of the branch name.  In my case,\nthe branch name \"origin/add-chickens2\" put the first line of the \"your\nbranch has diverged\" message over 80 characters, which triggered \"less -FS\"\nto not exit automatically as expected.\n\nThis patch puts the newlines in slightly different places to reduce the\nprobability of this happening.  Now you'd need a significantly longer\nbranch name to trigger the problem.\n\nSigned-off-by: Avery Pennarun <apenwarr@gmail.com>\n---\n remote.c |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n \nI suppose a full-on automatic wordwrapper would be nicer :)\n \n\ndiff --git a/remote.c b/remote.c\nindex df8bd72..4f32032 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1321,19 +1321,19 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \t\tremote_msg = \"\";\n \t}\n \tif (!num_theirs)\n-\t\tstrbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s' \"\n+\t\tstrbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s'\\n\"\n \t\t\t    \"by %d commit%s.\\n\",\n \t\t\t    remote_msg, base,\n \t\t\t    num_ours, (num_ours == 1) ? \"\" : \"s\");\n \telse if (!num_ours)\n-\t\tstrbuf_addf(sb, \"Your branch is behind the tracked%s branch '%s' \"\n-\t\t\t    \"by %d commit%s,\\n\"\n+\t\tstrbuf_addf(sb, \"Your branch is behind the tracked%s branch '%s'\\n\"\n+\t\t\t    \"by %d commit%s, \"\n \t\t\t    \"and can be fast-forwarded.\\n\",\n \t\t\t    remote_msg, base,\n \t\t\t    num_theirs, (num_theirs == 1) ? \"\" : \"s\");\n \telse\n-\t\tstrbuf_addf(sb, \"Your branch and the tracked%s branch '%s' \"\n-\t\t\t    \"have diverged,\\nand respectively \"\n+\t\tstrbuf_addf(sb, \"Your branch and the tracked%s branch '%s'\\n\"\n+\t\t\t    \"have diverged, and respectively \"\n \t\t\t    \"have %d and %d different commit(s) each.\\n\",\n \t\t\t    remote_msg, base,\n \t\t\t    num_ours, num_theirs);\n-- \n1.5.6.3.385.g94745\n"},{"id":"83573","messageId":"7v4p6pr4ob.fsf@gitster.siamese.dyndns.org","threadId":"14490","inReplyTo":"1216235967-9510-1-git-send-email-apenwarr@gmail.com","subject":"Re: [PATCH] Reformat \"your branch has diverged...\" lines to reduce line length.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-16T19:48:36Z","receivedAt":"2008-07-16T19:48:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Avery Pennarun <apenwarr@gmail.com> writes:\n\n>  \tif (!num_theirs)\n> -\t\tstrbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s' \"\n> +\t\tstrbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s'\\n\"\n>  \t\t\t    \"by %d commit%s.\\n\",\n\nI wonder if a simple \"s/of the tracked%s branch //\" is better for this\nkind of thing.  If the message says 'origin/master', you know it is a\ntracked remote branch anyway, don't you?\n\nToo wide is bad, but too tall is worse.  Some of us still work in 80x24\n;-) and I prefer to make the message succinct when possible, rather than\nkeeping it long and spread over multiple lines.\n\n>  \telse\n> -\t\tstrbuf_addf(sb, \"Your branch and the tracked%s branch '%s' \"\n> -\t\t\t    \"have diverged,\\nand respectively \"\n> +\t\tstrbuf_addf(sb, \"Your branch and the tracked%s branch '%s'\\n\"\n> +\t\t\t    \"have diverged, and respectively \"\n>  \t\t\t    \"have %d and %d different commit(s) each.\\n\",\n\nThis does not make the message taller, but if we were to make the \"only\none side advanced\" cases shorter, we would need to reword this to be\nconsistent.  Perhaps something like this would be just as easy to read and\nmore compact?\n\n\tYour branch is ahead of 'origin/add-chickens2' by 21 commits.\n\n        Your branch is behind 'origin/add-chickens2' by 1 commit.\n\n        Your branch and 'origin/add-chickens2' have diverged, and have\n        21 and 1 different commit(s) each, respectively.\n\nI moved \"respectively\" so that the variable parts will come close to the\nbeginning of physical line.\n"},{"id":"83580","messageId":"32541b130807161327k17f3a58ay5ab2da75963a2d50@mail.gmail.com","threadId":"14490","inReplyTo":"7v4p6pr4ob.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Reformat \"your branch has diverged...\" lines to reduce line length.","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-16T20:27:15Z","receivedAt":"2008-07-16T20:27:15Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/16/08, Junio C Hamano <gitster@pobox.com> wrote:\n> Avery Pennarun <apenwarr@gmail.com> writes:\n>  >       if (!num_theirs)\n>  > -             strbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s' \"\n>  > +             strbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s'\\n\"\n>  >                           \"by %d commit%s.\\n\",\n>\n>  I wonder if a simple \"s/of the tracked%s branch //\" is better for this\n>  kind of thing.  If the message says 'origin/master', you know it is a\n>  tracked remote branch anyway, don't you?\n\nPersonally, I would be fine with shorter messages; this doesn't seem\nthe best time to\nreport the name of the tracked branch anyhow.  I use 80x24 terminals\ntoo most of the time.\n\nHowever, I didn't write the original patch either, and I recall that\nthis feature was so popular that it actually resulted in a list thread\ncomplimenting it, so I was hesitant to change it too much :)\n\n>         Your branch is ahead of 'origin/add-chickens2' by 21 commits.\n>\n>         Your branch is behind 'origin/add-chickens2' by 1 commit.\n>\n>         Your branch and 'origin/add-chickens2' have diverged, and have\n>         21 and 1 different commit(s) each, respectively.\n>\n>  I moved \"respectively\" so that the variable parts will come close to the\n>  beginning of physical line.\n\nWell, the fact that the number of commits is \"variable\" isn't so\nimportant, unless you start diverging by 1e9 commits or something :)\nIt might be nice to minimize the amount of static text on the line\ncontaining the branch name, though.  Your rephrasing would allow us to\ngo as far as:\n\n    Your branch and 'origin/add-chickens2'\n    have diverged, and have 21 and 1 different commit(s) each, respectively.\n\nWhich looks a little imbalanced, but works with long branch names.\n\nAlternatively, your rephrasing above made me think of the idea of just\nprinting *both* of the first two messages in the \"diverging\" case.\nDepending how you think of it, that would be either more clear or less\nclear.  It's actually easier to parse the two short sentences than the\nlong one.\n\nPlease let me know if you want me to resubmit the patch with your\nsuggestions or whether you'll handle it.  I'm still a little vague on\nthe exact patch approval process.\n\nHave fun,\n\nAvery\n"},{"id":"83604","messageId":"7v3am9pjvf.fsf@gitster.siamese.dyndns.org","threadId":"14490","inReplyTo":"32541b130807161327k17f3a58ay5ab2da75963a2d50@mail.gmail.com","subject":"Re: [PATCH] Reformat \"your branch has diverged...\" lines to reduce line length.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-16T22:03:16Z","receivedAt":"2008-07-16T22:03:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Avery Pennarun\" <apenwarr@gmail.com> writes:\n\n>>         Your branch is ahead of 'origin/add-chickens2' by 21 commits.\n>>\n>>         Your branch is behind 'origin/add-chickens2' by 1 commit.\n>>\n>>         Your branch and 'origin/add-chickens2' have diverged, and have\n>>         21 and 1 different commit(s) each, respectively.\n>>\n>>  I moved \"respectively\" so that the variable parts will come close to the\n>>  beginning of physical line.\n>\n> Well, the fact that the number of commits is \"variable\" isn't so\n> important, unless you start diverging by 1e9 commits or something :)\n\nNo, no, no.  The point is not about keeping it on screen when \"less -S\"\nchops at the right end.  The point is to limit eye-movement of the user;\ni.e. presenting important information consistently at around the same\ncolumn, closer to the left edge.  Probably the line break should be before\n\"and have\" to make it even easier to read.\n\n>>         Your branch and 'origin/add-chickens2' have diverged,\n>>         and have 21 and 1 different commit(s) each, respectively.\n\n> Alternatively, your rephrasing above made me think of the idea of just\n> printing *both* of the first two messages in the \"diverging\" case.\n\nI do not think it is such a good idea --- we invite silly comments like\n\"You say X is ahead of Y, and X is behind of Y, which is true?\".\n\n> Please let me know if you want me to resubmit the patch with your\n> suggestions or whether you'll handle it.  I'm still a little vague on\n> the exact patch approval process.\n\nIt is very much more \"consensus building\" than \"approval\", and at this\npoint we wait for a day or two to see if people come up with even better\nalternatives.  Just be kind enough to prod me if I forget after a few\ndays, though ;-)\n"}]}