git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wt-status.c: Increase readability.
@ 2011-04-26  7:08 Henrik Hautakoski
  2011-04-26  7:50 ` Matthieu Moy
  0 siblings, 1 reply; 3+ messages in thread
From: Henrik Hautakoski @ 2011-04-26  7:08 UTC (permalink / raw)
  To: git; +Cc: Henrik Hautakoski

Add braces to if/else statements to make the code more readable.

Signed-off-by: Henrik Hautakoski <henrik@fiktivkod.org>
---
 wt-status.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 9f4e0ba..9d8a0ea 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -448,9 +448,9 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
 		if (ce_stage(ce)) {
 			d->index_status = DIFF_STATUS_UNMERGED;
 			d->stagemask |= (1 << (ce_stage(ce) - 1));
-		}
-		else
+		} else {
 			d->index_status = DIFF_STATUS_ADDED;
+		}
 	}
 	free_pathspec(&pathspec);
 }
@@ -745,35 +745,37 @@ void wt_status_print(struct wt_status *s)
 		wt_status_print_other(s, &s->untracked, _("Untracked"), "add");
 		if (s->show_ignored_files)
 			wt_status_print_other(s, &s->ignored, _("Ignored"), "add -f");
-	} else if (s->commitable)
+	} else if (s->commitable) {
 		status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
 			advice_status_hints
 			? _(" (use -u option to show untracked files)") : "");
+    }
 
 	if (s->verbose)
 		wt_status_print_verbose(s);
 	if (!s->commitable) {
-		if (s->amend)
+		if (s->amend) {
 			status_printf_ln(s, GIT_COLOR_NORMAL, _("No changes"));
-		else if (s->nowarn)
+		} else if (s->nowarn) {
 			; /* nothing */
-		else if (s->workdir_dirty)
+		} else if (s->workdir_dirty) {
 			printf(_("no changes added to commit%s\n"),
 				advice_status_hints
 				? _(" (use \"git add\" and/or \"git commit -a\")") : "");
-		else if (s->untracked.nr)
+		} else if (s->untracked.nr) {
 			printf(_("nothing added to commit but untracked files present%s\n"),
 				advice_status_hints
 				? _(" (use \"git add\" to track)") : "");
-		else if (s->is_initial)
+		} else if (s->is_initial) {
 			printf(_("nothing to commit%s\n"), advice_status_hints
 				? _(" (create/copy files and use \"git add\" to track)") : "");
-		else if (!s->show_untracked_files)
+		} else if (!s->show_untracked_files) {
 			printf(_("nothing to commit%s\n"), advice_status_hints
 				? _(" (use -u to show untracked files)") : "");
-		else
+		} else {
 			printf(_("nothing to commit%s\n"), advice_status_hints
 				? _(" (working directory clean)") : "");
+		}
 	}
 }
 
@@ -878,9 +880,9 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 		return;
 	branch_name = s->branch;
 
-	if (!prefixcmp(branch_name, "refs/heads/"))
+	if (!prefixcmp(branch_name, "refs/heads/")) {
 		branch_name += 11;
-	else if (!strcmp(branch_name, "HEAD")) {
+	} else if (!strcmp(branch_name, "HEAD")) {
 		branch_name = _("HEAD (no branch)");
 		branch_color_local = color(WT_STATUS_NOBRANCH, s);
 	}
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] wt-status.c: Increase readability.
  2011-04-26  7:08 [PATCH] wt-status.c: Increase readability Henrik Hautakoski
@ 2011-04-26  7:50 ` Matthieu Moy
  2011-04-26  9:13   ` Henrik Hautakoski
  0 siblings, 1 reply; 3+ messages in thread
From: Matthieu Moy @ 2011-04-26  7:50 UTC (permalink / raw)
  To: Henrik Hautakoski; +Cc: git

Henrik Hautakoski <henrik@fiktivkod.org> writes:

> Subject: [PATCH] wt-status.c: Increase readability.

Maybe "increase code readability" instead, I originally thought you
wanted to increase the readability of the output.

> Add braces to if/else statements to make the code more readable.

Git's coding style usually do not use "useless" braces. I think you're
only adding some in if statements that already had one branch (then or
else) braced, which is OK, but you should state that in the commit
message.

I don't care much either way about the application of this patch, but
expect others to say "this is useless code churn, not worth the
trouble".

> -	} else if (s->commitable)
> +	} else if (s->commitable) {
>  		status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
>  			advice_status_hints
>  			? _(" (use -u option to show untracked files)") : "");
> +    }

Whitespace damage on the last }.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] wt-status.c: Increase readability.
  2011-04-26  7:50 ` Matthieu Moy
@ 2011-04-26  9:13   ` Henrik Hautakoski
  0 siblings, 0 replies; 3+ messages in thread
From: Henrik Hautakoski @ 2011-04-26  9:13 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

> I don't care much either way about the application of this patch, but
> expect others to say "this is useless code churn, not worth the
> trouble".

I was aware of this when i made this patch, but I am new to open
source and thought this might be a good start (was originally messing
around in wt-status.c for another change).
So i pretty much only care about the communication on this list for
now so thanks for your input, it helps.

Will fix the issues and resend.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-26  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26  7:08 [PATCH] wt-status.c: Increase readability Henrik Hautakoski
2011-04-26  7:50 ` Matthieu Moy
2011-04-26  9:13   ` Henrik Hautakoski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).