{"thread":{"id":"27182","subject":"[PATCH] wt-status.c: Increase readability.","startedAt":"2011-04-26T07:08:33Z","lastAt":"2011-04-26T09:13:56Z","messageCount":3,"participants":["Henrik Hautakoski","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166357","messageId":"1303801713-22639-1-git-send-email-henrik@fiktivkod.org","threadId":"27182","inReplyTo":null,"subject":"[PATCH] wt-status.c: Increase readability.","fromName":"Henrik Hautakoski","fromEmail":"henrik@fiktivkod.org","sentAt":"2011-04-26T07:08:33Z","receivedAt":"2011-04-26T07:08:33Z","isPatch":true,"sender":{"key":"henrik@fiktivkod.org","avatar":"https://gravatar.com/avatar/d3cf481b598eb5a1163ac71224be2a8dc8409f25b23a018432d3bfff6b4bcb27?d=mp&s=160"},"body":"Add braces to if/else statements to make the code more readable.\n\nSigned-off-by: Henrik Hautakoski <henrik@fiktivkod.org>\n---\n wt-status.c |   26 ++++++++++++++------------\n 1 files changed, 14 insertions(+), 12 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 9f4e0ba..9d8a0ea 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -448,9 +448,9 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t\tif (ce_stage(ce)) {\n \t\t\td->index_status = DIFF_STATUS_UNMERGED;\n \t\t\td->stagemask |= (1 << (ce_stage(ce) - 1));\n-\t\t}\n-\t\telse\n+\t\t} else {\n \t\t\td->index_status = DIFF_STATUS_ADDED;\n+\t\t}\n \t}\n \tfree_pathspec(&pathspec);\n }\n@@ -745,35 +745,37 @@ void wt_status_print(struct wt_status *s)\n \t\twt_status_print_other(s, &s->untracked, _(\"Untracked\"), \"add\");\n \t\tif (s->show_ignored_files)\n \t\t\twt_status_print_other(s, &s->ignored, _(\"Ignored\"), \"add -f\");\n-\t} else if (s->commitable)\n+\t} else if (s->commitable) {\n \t\tstatus_printf_ln(s, GIT_COLOR_NORMAL, _(\"Untracked files not listed%s\"),\n \t\t\tadvice_status_hints\n \t\t\t? _(\" (use -u option to show untracked files)\") : \"\");\n+    }\n \n \tif (s->verbose)\n \t\twt_status_print_verbose(s);\n \tif (!s->commitable) {\n-\t\tif (s->amend)\n+\t\tif (s->amend) {\n \t\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL, _(\"No changes\"));\n-\t\telse if (s->nowarn)\n+\t\t} else if (s->nowarn) {\n \t\t\t; /* nothing */\n-\t\telse if (s->workdir_dirty)\n+\t\t} else if (s->workdir_dirty) {\n \t\t\tprintf(_(\"no changes added to commit%s\\n\"),\n \t\t\t\tadvice_status_hints\n \t\t\t\t? _(\" (use \\\"git add\\\" and/or \\\"git commit -a\\\")\") : \"\");\n-\t\telse if (s->untracked.nr)\n+\t\t} else if (s->untracked.nr) {\n \t\t\tprintf(_(\"nothing added to commit but untracked files present%s\\n\"),\n \t\t\t\tadvice_status_hints\n \t\t\t\t? _(\" (use \\\"git add\\\" to track)\") : \"\");\n-\t\telse if (s->is_initial)\n+\t\t} else if (s->is_initial) {\n \t\t\tprintf(_(\"nothing to commit%s\\n\"), advice_status_hints\n \t\t\t\t? _(\" (create/copy files and use \\\"git add\\\" to track)\") : \"\");\n-\t\telse if (!s->show_untracked_files)\n+\t\t} else if (!s->show_untracked_files) {\n \t\t\tprintf(_(\"nothing to commit%s\\n\"), advice_status_hints\n \t\t\t\t? _(\" (use -u to show untracked files)\") : \"\");\n-\t\telse\n+\t\t} else {\n \t\t\tprintf(_(\"nothing to commit%s\\n\"), advice_status_hints\n \t\t\t\t? _(\" (working directory clean)\") : \"\");\n+\t\t}\n \t}\n }\n \n@@ -878,9 +880,9 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \t\treturn;\n \tbranch_name = s->branch;\n \n-\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n+\tif (!prefixcmp(branch_name, \"refs/heads/\")) {\n \t\tbranch_name += 11;\n-\telse if (!strcmp(branch_name, \"HEAD\")) {\n+\t} else if (!strcmp(branch_name, \"HEAD\")) {\n \t\tbranch_name = _(\"HEAD (no branch)\");\n \t\tbranch_color_local = color(WT_STATUS_NOBRANCH, s);\n \t}\n-- \n1.7.3.4\n"},{"id":"166358","messageId":"vpqaafd8n9g.fsf@bauges.imag.fr","threadId":"27182","inReplyTo":"1303801713-22639-1-git-send-email-henrik@fiktivkod.org","subject":"Re: [PATCH] wt-status.c: Increase readability.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-04-26T07:50:19Z","receivedAt":"2011-04-26T07:50:19Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Henrik Hautakoski <henrik@fiktivkod.org> writes:\n\n> Subject: [PATCH] wt-status.c: Increase readability.\n\nMaybe \"increase code readability\" instead, I originally thought you\nwanted to increase the readability of the output.\n\n> Add braces to if/else statements to make the code more readable.\n\nGit's coding style usually do not use \"useless\" braces. I think you're\nonly adding some in if statements that already had one branch (then or\nelse) braced, which is OK, but you should state that in the commit\nmessage.\n\nI don't care much either way about the application of this patch, but\nexpect others to say \"this is useless code churn, not worth the\ntrouble\".\n\n> -\t} else if (s->commitable)\n> +\t} else if (s->commitable) {\n>  \t\tstatus_printf_ln(s, GIT_COLOR_NORMAL, _(\"Untracked files not listed%s\"),\n>  \t\t\tadvice_status_hints\n>  \t\t\t? _(\" (use -u option to show untracked files)\") : \"\");\n> +    }\n\nWhitespace damage on the last }.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"166366","messageId":"BANLkTimubS3m+QbZKYkTivVwfaHxze6fcw@mail.gmail.com","threadId":"27182","inReplyTo":"vpqaafd8n9g.fsf@bauges.imag.fr","subject":"Re: [PATCH] wt-status.c: Increase readability.","fromName":"Henrik Hautakoski","fromEmail":"henrik@fiktivkod.org","sentAt":"2011-04-26T09:13:56Z","receivedAt":"2011-04-26T09:13:56Z","isPatch":true,"sender":{"key":"henrik@fiktivkod.org","avatar":"https://gravatar.com/avatar/d3cf481b598eb5a1163ac71224be2a8dc8409f25b23a018432d3bfff6b4bcb27?d=mp&s=160"},"body":"> I don't care much either way about the application of this patch, but\n> expect others to say \"this is useless code churn, not worth the\n> trouble\".\n\nI was aware of this when i made this patch, but I am new to open\nsource and thought this might be a good start (was originally messing\naround in wt-status.c for another change).\nSo i pretty much only care about the communication on this list for\nnow so thanks for your input, it helps.\n\nWill fix the issues and resend.\n"}]}