Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit d7c03ca

Browse files
committed
Merge branch 'ab/i18n'
Fix some constructs that build messages meant for i18n by concatenating pieces of strings. By Ævar Arnfjörð Bjarmason * ab/i18n: git-commit: remove lego in i18n messages git-commit: remove lego in i18n messages git-branch: remove lego in i18n messages
2 parents 73ff8cf + 4064e66 commit d7c03ca

File tree

2 files changed

+44
-45
lines changed

2 files changed

+44
-45
lines changed

builtin/branch.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,22 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
152152
struct commit *rev, *head_rev = NULL;
153153
unsigned char sha1[20];
154154
char *name = NULL;
155-
const char *fmt, *remote;
155+
const char *fmt;
156156
int i;
157157
int ret = 0;
158+
int remote_branch = 0;
158159
struct strbuf bname = STRBUF_INIT;
159160

160161
switch (kinds) {
161162
case REF_REMOTE_BRANCH:
162163
fmt = "refs/remotes/%s";
163-
/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
164-
remote = _("remote ");
164+
/* For subsequent UI messages */
165+
remote_branch = 1;
166+
165167
force = 1;
166168
break;
167169
case REF_LOCAL_BRANCH:
168170
fmt = "refs/heads/%s";
169-
remote = "";
170171
break;
171172
default:
172173
die(_("cannot use -a with -d"));
@@ -190,8 +191,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
190191

191192
name = xstrdup(mkpath(fmt, bname.buf));
192193
if (read_ref(name, sha1)) {
193-
error(_("%sbranch '%s' not found."),
194-
remote, bname.buf);
194+
error(remote_branch
195+
? _("remote branch '%s' not found.")
196+
: _("branch '%s' not found."), bname.buf);
195197
ret = 1;
196198
continue;
197199
}
@@ -212,14 +214,18 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
212214
}
213215

214216
if (delete_ref(name, sha1, 0)) {
215-
error(_("Error deleting %sbranch '%s'"), remote,
217+
error(remote_branch
218+
? _("Error deleting remote branch '%s'")
219+
: _("Error deleting branch '%s'"),
216220
bname.buf);
217221
ret = 1;
218222
} else {
219223
struct strbuf buf = STRBUF_INIT;
220224
if (!quiet)
221-
printf(_("Deleted %sbranch %s (was %s).\n"),
222-
remote, bname.buf,
225+
printf(remote_branch
226+
? _("Deleted remote branch %s (was %s).\n")
227+
: _("Deleted branch %s (was %s).\n"),
228+
bname.buf,
223229
find_unique_abbrev(sha1, DEFAULT_ABBREV));
224230
strbuf_addf(&buf, "branch.%s", bname.buf);
225231
if (git_config_rename_section(buf.buf, NULL) < 0)

builtin/commit.c

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,6 @@ static void determine_whence(struct wt_status *s)
194194
s->whence = whence;
195195
}
196196

197-
static const char *whence_s(void)
198-
{
199-
const char *s = "";
200-
201-
switch (whence) {
202-
case FROM_COMMIT:
203-
break;
204-
case FROM_MERGE:
205-
s = _("merge");
206-
break;
207-
case FROM_CHERRY_PICK:
208-
s = _("cherry-pick");
209-
break;
210-
}
211-
212-
return s;
213-
}
214-
215197
static void rollback_index_files(void)
216198
{
217199
switch (commit_style) {
@@ -453,8 +435,12 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
453435
*/
454436
commit_style = COMMIT_PARTIAL;
455437

456-
if (whence != FROM_COMMIT)
457-
die(_("cannot do a partial commit during a %s."), whence_s());
438+
if (whence != FROM_COMMIT) {
439+
if (whence == FROM_MERGE)
440+
die(_("cannot do a partial commit during a merge."));
441+
else if (whence == FROM_CHERRY_PICK)
442+
die(_("cannot do a partial commit during a cherry-pick."));
443+
}
458444

459445
memset(&partial, 0, sizeof(partial));
460446
partial.strdup_strings = 1;
@@ -796,28 +782,31 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
796782
char *ai_tmp, *ci_tmp;
797783
if (whence != FROM_COMMIT)
798784
status_printf_ln(s, GIT_COLOR_NORMAL,
799-
_("\n"
800-
"It looks like you may be committing a %s.\n"
801-
"If this is not correct, please remove the file\n"
802-
" %s\n"
803-
"and try again.\n"
804-
""),
805-
whence_s(),
785+
whence == FROM_MERGE
786+
? _("\n"
787+
"It looks like you may be committing a merge.\n"
788+
"If this is not correct, please remove the file\n"
789+
" %s\n"
790+
"and try again.\n")
791+
: _("\n"
792+
"It looks like you may be committing a cherry-pick.\n"
793+
"If this is not correct, please remove the file\n"
794+
" %s\n"
795+
"and try again.\n"),
806796
git_path(whence == FROM_MERGE
807797
? "MERGE_HEAD"
808798
: "CHERRY_PICK_HEAD"));
809799

810800
fprintf(s->fp, "\n");
811-
status_printf(s, GIT_COLOR_NORMAL,
812-
_("Please enter the commit message for your changes."));
813801
if (cleanup_mode == CLEANUP_ALL)
814-
status_printf_more(s, GIT_COLOR_NORMAL,
815-
_(" Lines starting\n"
816-
"with '#' will be ignored, and an empty"
802+
status_printf(s, GIT_COLOR_NORMAL,
803+
_("Please enter the commit message for your changes."
804+
" Lines starting\nwith '#' will be ignored, and an empty"
817805
" message aborts the commit.\n"));
818806
else /* CLEANUP_SPACE, that is. */
819-
status_printf_more(s, GIT_COLOR_NORMAL,
820-
_(" Lines starting\n"
807+
status_printf(s, GIT_COLOR_NORMAL,
808+
_("Please enter the commit message for your changes."
809+
" Lines starting\n"
821810
"with '#' will be kept; you may remove them"
822811
" yourself if you want to.\n"
823812
"An empty message aborts the commit.\n"));
@@ -1072,8 +1061,12 @@ static int parse_and_validate_options(int argc, const char *argv[],
10721061
/* Sanity check options */
10731062
if (amend && !current_head)
10741063
die(_("You have nothing to amend."));
1075-
if (amend && whence != FROM_COMMIT)
1076-
die(_("You are in the middle of a %s -- cannot amend."), whence_s());
1064+
if (amend && whence != FROM_COMMIT) {
1065+
if (whence == FROM_MERGE)
1066+
die(_("You are in the middle of a merge -- cannot amend."));
1067+
else if (whence == FROM_CHERRY_PICK)
1068+
die(_("You are in the middle of a cherry-pick -- cannot amend."));
1069+
}
10771070
if (fixup_message && squash_message)
10781071
die(_("Options --squash and --fixup cannot be used together"));
10791072
if (use_message)

0 commit comments

Comments
 (0)