* [PATCH] [GSOC] branch.c: install_branch_config: simplify if chain
@ 2014-03-10 5:32 Adam
2014-03-10 21:18 ` Eric Sunshine
0 siblings, 1 reply; 2+ messages in thread
From: Adam @ 2014-03-10 5:32 UTC (permalink / raw)
To: git; +Cc: Adam
Simplify if chain in install_branch_config().
Signed-off-by: Adam <Adam@sigterm.info>
---
branch.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/branch.c b/branch.c
index 723a36b..b2d59f1 100644
--- a/branch.c
+++ b/branch.c
@@ -77,29 +77,29 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
strbuf_release(&key);
if (flag & BRANCH_CONFIG_VERBOSE) {
- if (remote_is_branch && origin)
- printf_ln(rebasing ?
- _("Branch %s set up to track remote branch %s from %s by rebasing.") :
- _("Branch %s set up to track remote branch %s from %s."),
- local, shortname, origin);
- else if (remote_is_branch && !origin)
- printf_ln(rebasing ?
- _("Branch %s set up to track local branch %s by rebasing.") :
- _("Branch %s set up to track local branch %s."),
- local, shortname);
- else if (!remote_is_branch && origin)
- printf_ln(rebasing ?
- _("Branch %s set up to track remote ref %s by rebasing.") :
- _("Branch %s set up to track remote ref %s."),
- local, remote);
- else if (!remote_is_branch && !origin)
- printf_ln(rebasing ?
- _("Branch %s set up to track local ref %s by rebasing.") :
- _("Branch %s set up to track local ref %s."),
- local, remote);
- else
- die("BUG: impossible combination of %d and %p",
- remote_is_branch, origin);
+ if (remote_is_branch) {
+ if (origin)
+ printf_ln(rebasing ?
+ _("Branch %s set up to track remote branch %s from %s by rebasing.") :
+ _("Branch %s set up to track remote branch %s from %s."),
+ local, shortname, origin);
+ else
+ printf_ln(rebasing ?
+ _("Branch %s set up to track local branch %s by rebasing.") :
+ _("Branch %s set up to track local branch %s."),
+ local, shortname);
+ } else {
+ if (origin)
+ printf_ln(rebasing ?
+ _("Branch %s set up to track remote ref %s by rebasing.") :
+ _("Branch %s set up to track remote ref %s."),
+ local, remote);
+ else
+ printf_ln(rebasing ?
+ _("Branch %s set up to track local ref %s by rebasing.") :
+ _("Branch %s set up to track local ref %s."),
+ local, remote);
+ }
}
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [GSOC] branch.c: install_branch_config: simplify if chain
2014-03-10 5:32 [PATCH] [GSOC] branch.c: install_branch_config: simplify if chain Adam
@ 2014-03-10 21:18 ` Eric Sunshine
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sunshine @ 2014-03-10 21:18 UTC (permalink / raw)
To: Adam; +Cc: Git List
On Mon, Mar 10, 2014 at 1:32 AM, Adam <adam@sigterm.info> wrote:
> Simplify if chain in install_branch_config().
Nicely done. Whether the rewritten code is indeed simpler is probably
a matter of taste, however, the submission itself is well executed.
> Signed-off-by: Adam <Adam@sigterm.info>
On this project, use your full name if possible.
> ---
The GSoC microproject which begat this submission asks if it would
make sense to change the code to be table-driven. If you considered
this suggestion, this area just below the "---" line following your
sign-off would be the perfect place to explain your reasons for
rejecting it.
> branch.c | 46 +++++++++++++++++++++++-----------------------
> 1 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/branch.c b/branch.c
> index 723a36b..b2d59f1 100644
> --- a/branch.c
> +++ b/branch.c
> @@ -77,29 +77,29 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
> strbuf_release(&key);
>
> if (flag & BRANCH_CONFIG_VERBOSE) {
> - if (remote_is_branch && origin)
> - printf_ln(rebasing ?
> - _("Branch %s set up to track remote branch %s from %s by rebasing.") :
> - _("Branch %s set up to track remote branch %s from %s."),
> - local, shortname, origin);
> - else if (remote_is_branch && !origin)
> - printf_ln(rebasing ?
> - _("Branch %s set up to track local branch %s by rebasing.") :
> - _("Branch %s set up to track local branch %s."),
> - local, shortname);
> - else if (!remote_is_branch && origin)
> - printf_ln(rebasing ?
> - _("Branch %s set up to track remote ref %s by rebasing.") :
> - _("Branch %s set up to track remote ref %s."),
> - local, remote);
> - else if (!remote_is_branch && !origin)
> - printf_ln(rebasing ?
> - _("Branch %s set up to track local ref %s by rebasing.") :
> - _("Branch %s set up to track local ref %s."),
> - local, remote);
> - else
> - die("BUG: impossible combination of %d and %p",
> - remote_is_branch, origin);
> + if (remote_is_branch) {
> + if (origin)
> + printf_ln(rebasing ?
> + _("Branch %s set up to track remote branch %s from %s by rebasing.") :
> + _("Branch %s set up to track remote branch %s from %s."),
> + local, shortname, origin);
> + else
> + printf_ln(rebasing ?
> + _("Branch %s set up to track local branch %s by rebasing.") :
> + _("Branch %s set up to track local branch %s."),
> + local, shortname);
> + } else {
> + if (origin)
> + printf_ln(rebasing ?
> + _("Branch %s set up to track remote ref %s by rebasing.") :
> + _("Branch %s set up to track remote ref %s."),
> + local, remote);
> + else
> + printf_ln(rebasing ?
> + _("Branch %s set up to track local ref %s by rebasing.") :
> + _("Branch %s set up to track local ref %s."),
> + local, remote);
> + }
> }
> }
>
> --
> 1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-10 21:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-10 5:32 [PATCH] [GSOC] branch.c: install_branch_config: simplify if chain Adam
2014-03-10 21:18 ` Eric Sunshine
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).