{"thread":{"id":"50369","subject":"[PATCH] help: align the longest command in the command listing","startedAt":"2019-01-31T09:24:05Z","lastAt":"2019-02-01T08:24:49Z","messageCount":3,"participants":["Nguyễn Thái Ngọc Duy","Johannes Schindelin","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"368230","messageId":"20190131092349.11469-1-pclouds@gmail.com","threadId":"50369","inReplyTo":null,"subject":"[PATCH] help: align the longest command in the command listing","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-01-31T09:23:49Z","receivedAt":"2019-01-31T09:24:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"longest\" is used to determine how many extra spaces we need to print\nto keep the command description aligned. For the longest command, we\nshould print no extra space instead of one, or we'll get unaligned\noutput like this (notice the \"checkout\" line):\n\n    grow, mark and tweak your common history\n       branch     List, create, or delete branches\n       checkout    Switch branches or restore working tree files\n       commit     Record changes to the repository\n       diff       Show changes between commits, commit and ...\n       merge      Join two or more development histories together\n       rebase     Reapply commits on top of another base tip\n       tag        Create, list, delete or verify a tag ...\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n help.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/help.c b/help.c\nindex ff05fd22df..520c9080e8 100644\n--- a/help.c\n+++ b/help.c\n@@ -85,7 +85,8 @@ static void print_command_list(const struct cmdname_help *cmds,\n \t\tif (cmds[i].category & mask) {\n \t\t\tsize_t len = strlen(cmds[i].name);\n \t\t\tprintf(\"   %s   \", cmds[i].name);\n-\t\t\tmput_char(' ', longest > len ? longest - len : 1);\n+\t\t\tif (longest > len)\n+\t\t\t\tmput_char(' ', longest - len);\n \t\t\tputs(_(cmds[i].help));\n \t\t}\n \t}\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368308","messageId":"nycvar.QRO.7.76.6.1902010842010.41@tvgsbejvaqbjf.bet","threadId":"50369","inReplyTo":"20190131092349.11469-1-pclouds@gmail.com","subject":"Re: [PATCH] help: align the longest command in the command listing","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-02-01T07:42:36Z","receivedAt":"2019-02-01T07:42:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Duy,\n\nOn Thu, 31 Jan 2019, Nguyễn Thái Ngọc Duy wrote:\n\n> \"longest\" is used to determine how many extra spaces we need to print\n> to keep the command description aligned. For the longest command, we\n> should print no extra space instead of one, or we'll get unaligned\n> output like this (notice the \"checkout\" line):\n> \n>     grow, mark and tweak your common history\n>        branch     List, create, or delete branches\n>        checkout    Switch branches or restore working tree files\n>        commit     Record changes to the repository\n>        diff       Show changes between commits, commit and ...\n>        merge      Join two or more development histories together\n>        rebase     Reapply commits on top of another base tip\n>        tag        Create, list, delete or verify a tag ...\n> \n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  help.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/help.c b/help.c\n> index ff05fd22df..520c9080e8 100644\n> --- a/help.c\n> +++ b/help.c\n> @@ -85,7 +85,8 @@ static void print_command_list(const struct cmdname_help *cmds,\n>  \t\tif (cmds[i].category & mask) {\n>  \t\t\tsize_t len = strlen(cmds[i].name);\n>  \t\t\tprintf(\"   %s   \", cmds[i].name);\n> -\t\t\tmput_char(' ', longest > len ? longest - len : 1);\n> +\t\t\tif (longest > len)\n> +\t\t\t\tmput_char(' ', longest - len);\n\nWhy not simply replace the `1` by `0`?\n\nCiao,\nDscho\n\n>  \t\t\tputs(_(cmds[i].help));\n>  \t\t}\n>  \t}\n> -- \n> 2.20.1.682.gd5861c6d90\n> \n> "},{"id":"368310","messageId":"CACsJy8B=7NsnnoSH1Bt_C-Nop95ky=rudHU3SOVERVudDD7Tfw@mail.gmail.com","threadId":"50369","inReplyTo":"nycvar.QRO.7.76.6.1902010842010.41@tvgsbejvaqbjf.bet","subject":"Re: [PATCH] help: align the longest command in the command listing","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-01T08:24:21Z","receivedAt":"2019-02-01T08:24:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 1, 2019 at 2:42 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> > diff --git a/help.c b/help.c\n> > index ff05fd22df..520c9080e8 100644\n> > --- a/help.c\n> > +++ b/help.c\n> > @@ -85,7 +85,8 @@ static void print_command_list(const struct cmdname_help *cmds,\n> >               if (cmds[i].category & mask) {\n> >                       size_t len = strlen(cmds[i].name);\n> >                       printf(\"   %s   \", cmds[i].name);\n> > -                     mput_char(' ', longest > len ? longest - len : 1);\n> > +                     if (longest > len)\n> > +                             mput_char(' ', longest - len);\n>\n> Why not simply replace the `1` by `0`?\n\nWhile it makes the diff shorter, I think it's a bit more confusing\n(why add zero spaces?)\n-- \nDuy\n"}]}