From: Yao Zhao <zhaox383@umn.edu>
To: git@vger.kernel.org
Cc: Yao Zhao <zhaox383@umn.edu>
Subject: [PATCH] SoC 2014 MicroProject No.8:change multiple if-else statement to table-driven approach
Date: Tue, 11 Mar 2014 22:47:29 -0500 [thread overview]
Message-ID: <1394596049-8767-1-git-send-email-zhaox383@umn.edu> (raw)
In-Reply-To: <zhaox383@umn.edu>
Signed-off-by: Yao Zhao <zhaox383@umn.edu>
---
branch.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/branch.c b/branch.c
index 723a36b..6432e27 100644
--- a/branch.c
+++ b/branch.c
@@ -53,7 +53,20 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
int remote_is_branch = starts_with(remote, "refs/heads/");
struct strbuf key = STRBUF_INIT;
int rebasing = should_setup_rebase(origin);
-
+ char** print_list = malloc(8 * sizeof(char*));
+ char* arg1=NULL;
+ char* arg2=NULL;
+ char* arg3=NULL;
+ int index=0;
+
+ print_list[7] = _("Branch %s set up to track remote branch %s from %s by rebasing.");
+ print_list[6] = _("Branch %s set up to track remote branch %s from %s.");
+ print_list[5] = _("Branch %s set up to track local branch %s by rebasing.");
+ print_list[4] = _("Branch %s set up to track local branch %s.");
+ print_list[3] = _("Branch %s set up to track remote ref %s by rebasing.");
+ print_list[2] = _("Branch %s set up to track remote ref %s.");
+ print_list[1] = _("Branch %s set up to track local ref %s by rebasing.");
+ print_list[0] = _("Branch %s set up to track local ref %s.");
if (remote_is_branch
&& !strcmp(local, shortname)
&& !origin) {
@@ -77,7 +90,44 @@ 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)
+ if(remote_is_branch)
+ index += 4;
+ if(origin)
+ index += 2;
+ if(rebasing)
+ index += 1;
+
+ if(index < 0 || index > 7)
+ {
+ die("BUG: impossible combination of %d and %p",
+ remote_is_branch, origin);
+ }
+
+ if(index <= 4) {
+ arg1 = local;
+ arg2 = remote;
+ }
+ else if(index > 6) {
+ arg1 = local;
+ arg2 = shortname;
+ arg3 = origin;
+ }
+ else {
+ arg1 = local;
+ arg2 = shortname;
+ }
+
+ if(!arg3) {
+ printf_ln(print_list[index],arg1,arg2);
+ }
+ else {
+ printf_ln(print_list[index],arg1,arg2,arg3);
+ }
+
+ free(print_list);
+
+
+/* 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."),
@@ -100,6 +150,7 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
else
die("BUG: impossible combination of %d and %p",
remote_is_branch, origin);
+*/
}
}
--
1.8.3.2
next reply other threads:[~2014-03-12 4:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 3:47 Yao Zhao [this message]
2014-03-12 9:21 ` [PATCH] SoC 2014 MicroProject No.8:change multiple if-else statement to table-driven approach Eric Sunshine
2014-03-13 20:20 ` [PATCH] GSoC Change multiple if-else statements to be table-driven Yao Zhao
2014-03-14 2:16 ` Eric Sunshine
2014-03-14 16:54 ` Junio C Hamano
2014-03-17 6:29 ` Eric Sunshine
2014-03-17 7:31 ` Junio C Hamano
2014-03-17 14:11 ` Michael Haggerty
2014-03-17 19:12 ` Junio C Hamano
2014-03-17 19:27 ` Eric Sunshine
2014-03-17 20:39 ` Quint Guvernator
2014-03-16 6:08 ` [PATCH/GSoC_v3] branch.c: turn nested if-else logic to table-driven Yao Zhao
2014-03-17 7:54 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394596049-8767-1-git-send-email-zhaox383@umn.edu \
--to=zhaox383@umn.edu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).