Skip to content

Commit

Permalink
Merge branch 'pw/branch-config-message' into jch
Browse files Browse the repository at this point in the history
Among the many attempts to microproject #8, this seemed to be the
most "done" among the table based ones; I however tend to think
that the original with minimum refactoring would be easier to read.

* pw/branch-config-message:
  install_branch_config(): simplify verbose messages logic

# Conflicts:
# 	branch.c
  • Loading branch information
gitster committed Mar 20, 2014
2 parents a947259 + d7ea789 commit bc7979a
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
const char *shortname = skip_prefix(remote, "refs/heads/");
struct strbuf key = STRBUF_INIT;
int rebasing = should_setup_rebase(origin);
const char *message[][2][2] = { { {
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_("Branch %s set up to track local branch %s by rebasing."),
N_("Branch %s set up to track local branch %s."),
} }, { {
N_("Branch %s set up to track remote ref %s by rebasing."),
N_("Branch %s set up to track remote ref %s."),
}, {
N_("Branch %s set up to track local ref %s by rebasing."),
N_("Branch %s set up to track local ref %s.")
} } };

if (shortname
&& !strcmp(local, shortname)
Expand All @@ -76,31 +89,11 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
}
strbuf_release(&key);

if (flag & BRANCH_CONFIG_VERBOSE) {
if (shortname && 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 (shortname && !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 (!shortname && 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 (!shortname && !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 %p and %p",
shortname, origin);
}
if (flag & BRANCH_CONFIG_VERBOSE)
printf_ln(_(message[!shortname][!origin][!rebasing]),
local,
shortname ? shortname : remote,
origin);
}

/*
Expand Down

0 comments on commit bc7979a

Please sign in to comment.