{"thread":{"id":"36105","subject":"[PATCH] [GSOC] branch.c: install_branch_config: simplify if chain","startedAt":"2014-03-10T05:32:01Z","lastAt":"2014-03-10T21:18:18Z","messageCount":2,"participants":["Adam","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"236348","messageId":"1394429521-10974-1-git-send-email-Adam@sigterm.info","threadId":"36105","inReplyTo":null,"subject":"[PATCH] [GSOC] branch.c: install_branch_config: simplify if chain","fromName":"Adam","fromEmail":"adam@sigterm.info","sentAt":"2014-03-10T05:32:01Z","receivedAt":"2014-03-10T05:32:01Z","isPatch":true,"sender":{"key":"adam@sigterm.info","avatar":null},"body":"Simplify if chain in install_branch_config().\n\nSigned-off-by: Adam <Adam@sigterm.info>\n---\n branch.c |   46 +++++++++++++++++++++++-----------------------\n 1 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 723a36b..b2d59f1 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -77,29 +77,29 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \tstrbuf_release(&key);\n \n \tif (flag & BRANCH_CONFIG_VERBOSE) {\n-\t\tif (remote_is_branch && origin)\n-\t\t\tprintf_ln(rebasing ?\n-\t\t\t\t  _(\"Branch %s set up to track remote branch %s from %s by rebasing.\") :\n-\t\t\t\t  _(\"Branch %s set up to track remote branch %s from %s.\"),\n-\t\t\t\t  local, shortname, origin);\n-\t\telse if (remote_is_branch && !origin)\n-\t\t\tprintf_ln(rebasing ?\n-\t\t\t\t  _(\"Branch %s set up to track local branch %s by rebasing.\") :\n-\t\t\t\t  _(\"Branch %s set up to track local branch %s.\"),\n-\t\t\t\t  local, shortname);\n-\t\telse if (!remote_is_branch && origin)\n-\t\t\tprintf_ln(rebasing ?\n-\t\t\t\t  _(\"Branch %s set up to track remote ref %s by rebasing.\") :\n-\t\t\t\t  _(\"Branch %s set up to track remote ref %s.\"),\n-\t\t\t\t  local, remote);\n-\t\telse if (!remote_is_branch && !origin)\n-\t\t\tprintf_ln(rebasing ?\n-\t\t\t\t  _(\"Branch %s set up to track local ref %s by rebasing.\") :\n-\t\t\t\t  _(\"Branch %s set up to track local ref %s.\"),\n-\t\t\t\t  local, remote);\n-\t\telse\n-\t\t\tdie(\"BUG: impossible combination of %d and %p\",\n-\t\t\t    remote_is_branch, origin);\n+\t\tif (remote_is_branch) {\n+\t\t\tif (origin)\n+\t\t\t\tprintf_ln(rebasing ?\n+\t\t\t\t\t  _(\"Branch %s set up to track remote branch %s from %s by rebasing.\") :\n+\t\t\t\t\t  _(\"Branch %s set up to track remote branch %s from %s.\"),\n+\t\t\t\t\t  local, shortname, origin);\n+\t\t\telse\n+\t\t\t\tprintf_ln(rebasing ?\n+\t\t\t\t\t  _(\"Branch %s set up to track local branch %s by rebasing.\") :\n+\t\t\t\t\t  _(\"Branch %s set up to track local branch %s.\"),\n+\t\t\t\t\t  local, shortname);\n+\t\t} else {\n+\t\t\tif (origin)\n+\t\t\t\tprintf_ln(rebasing ?\n+\t\t\t\t\t  _(\"Branch %s set up to track remote ref %s by rebasing.\") :\n+\t\t\t\t\t  _(\"Branch %s set up to track remote ref %s.\"),\n+\t\t\t\t\t  local, remote);\n+\t\t\telse\n+\t\t\t\tprintf_ln(rebasing ?\n+\t\t\t\t\t  _(\"Branch %s set up to track local ref %s by rebasing.\") :\n+\t\t\t\t\t  _(\"Branch %s set up to track local ref %s.\"),\n+\t\t\t\t\t  local, remote);\n+\t\t}\n \t}\n }\n \n-- \n1.7.1\n"},{"id":"236461","messageId":"CAPig+cSybcLaPbMfHfRVW47o9v7qrM9XZVyoiEPf1GocUAsAWg@mail.gmail.com","threadId":"36105","inReplyTo":"1394429521-10974-1-git-send-email-Adam@sigterm.info","subject":"Re: [PATCH] [GSOC] branch.c: install_branch_config: simplify if chain","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-10T21:18:18Z","receivedAt":"2014-03-10T21:18:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Mar 10, 2014 at 1:32 AM, Adam <adam@sigterm.info> wrote:\n> Simplify if chain in install_branch_config().\n\nNicely done. Whether the rewritten code is indeed simpler is probably\na matter of taste, however, the submission itself is well executed.\n\n> Signed-off-by: Adam <Adam@sigterm.info>\n\nOn this project, use your full name if possible.\n\n> ---\n\nThe GSoC microproject which begat this submission asks if it would\nmake sense to change the code to be table-driven. If you considered\nthis suggestion, this area just below the \"---\" line following your\nsign-off would be the perfect place to explain your reasons for\nrejecting it.\n\n>  branch.c |   46 +++++++++++++++++++++++-----------------------\n>  1 files changed, 23 insertions(+), 23 deletions(-)\n>\n> diff --git a/branch.c b/branch.c\n> index 723a36b..b2d59f1 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -77,29 +77,29 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n>         strbuf_release(&key);\n>\n>         if (flag & BRANCH_CONFIG_VERBOSE) {\n> -               if (remote_is_branch && origin)\n> -                       printf_ln(rebasing ?\n> -                                 _(\"Branch %s set up to track remote branch %s from %s by rebasing.\") :\n> -                                 _(\"Branch %s set up to track remote branch %s from %s.\"),\n> -                                 local, shortname, origin);\n> -               else if (remote_is_branch && !origin)\n> -                       printf_ln(rebasing ?\n> -                                 _(\"Branch %s set up to track local branch %s by rebasing.\") :\n> -                                 _(\"Branch %s set up to track local branch %s.\"),\n> -                                 local, shortname);\n> -               else if (!remote_is_branch && origin)\n> -                       printf_ln(rebasing ?\n> -                                 _(\"Branch %s set up to track remote ref %s by rebasing.\") :\n> -                                 _(\"Branch %s set up to track remote ref %s.\"),\n> -                                 local, remote);\n> -               else if (!remote_is_branch && !origin)\n> -                       printf_ln(rebasing ?\n> -                                 _(\"Branch %s set up to track local ref %s by rebasing.\") :\n> -                                 _(\"Branch %s set up to track local ref %s.\"),\n> -                                 local, remote);\n> -               else\n> -                       die(\"BUG: impossible combination of %d and %p\",\n> -                           remote_is_branch, origin);\n> +               if (remote_is_branch) {\n> +                       if (origin)\n> +                               printf_ln(rebasing ?\n> +                                         _(\"Branch %s set up to track remote branch %s from %s by rebasing.\") :\n> +                                         _(\"Branch %s set up to track remote branch %s from %s.\"),\n> +                                         local, shortname, origin);\n> +                       else\n> +                               printf_ln(rebasing ?\n> +                                         _(\"Branch %s set up to track local branch %s by rebasing.\") :\n> +                                         _(\"Branch %s set up to track local branch %s.\"),\n> +                                         local, shortname);\n> +               } else {\n> +                       if (origin)\n> +                               printf_ln(rebasing ?\n> +                                         _(\"Branch %s set up to track remote ref %s by rebasing.\") :\n> +                                         _(\"Branch %s set up to track remote ref %s.\"),\n> +                                         local, remote);\n> +                       else\n> +                               printf_ln(rebasing ?\n> +                                         _(\"Branch %s set up to track local ref %s by rebasing.\") :\n> +                                         _(\"Branch %s set up to track local ref %s.\"),\n> +                                         local, remote);\n> +               }\n>         }\n>  }\n>\n> --\n> 1.7.1\n"}]}