i18n: git-merge basic messages
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Feb 22, 2011 at 23:41 UTC
bacec4784598ca35b9be7635cbb630ef59367b6b
3 files changed
+86
-68
builtin/merge.c
+62
-62
@@ -80,7 +80,7 @@ static int option_parse_message(const struct option *opt,
80
strbuf_addf(buf, "%s%s", buf->len ? "\n\n" : "", arg);
81
have_message = 1;
82
} else
83
- return error("switch `m' requires a value");
83
+ return error(_("switch `m' requires a value"));
84
return 0;
85
}
86
@@ -117,13 +117,13 @@ static struct strategy *get_strategy(const char *name)
117
exclude_cmds(&main_cmds, ¬_strategies);
118
}
119
if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
120
- fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
121
- fprintf(stderr, "Available strategies are:");
120
+ fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
121
+ fprintf(stderr, _("Available strategies are:"));
122
for (i = 0; i < main_cmds.cnt; i++)
123
fprintf(stderr, " %s", main_cmds.names[i]->name);
124
fprintf(stderr, ".\n");
125
if (other_cmds.cnt) {
126
- fprintf(stderr, "Available custom strategies are:");
126
+ fprintf(stderr, _("Available custom strategies are:"));
127
for (i = 0; i < other_cmds.cnt; i++)
128
fprintf(stderr, " %s", other_cmds.names[i]->name);
129
fprintf(stderr, ".\n");
@@ -224,17 +224,17 @@ static void save_state(void)
224
cp.git_cmd = 1;
225
226
if (start_command(&cp))
227
- die("could not run stash.");
227
+ die(_("could not run stash."));
228
len = strbuf_read(&buffer, cp.out, 1024);
229
close(cp.out);
230
231
if (finish_command(&cp) || len < 0)
232
- die("stash failed");
232
+ die(_("stash failed"));
233
else if (!len)
234
return;
235
strbuf_setlen(&buffer, buffer.len-1);
236
if (get_sha1(buffer.buf, stash))
237
- die("not a valid object: %s", buffer.buf);
237
+ die(_("not a valid object: %s"), buffer.buf);
238
}
239
240
static void read_empty(unsigned const char *sha1, int verbose)
@@ -252,7 +252,7 @@ static void read_empty(unsigned const char *sha1, int verbose)
252
args[i] = NULL;
253
254
if (run_command_v_opt(args, RUN_GIT_CMD))
255
- die("read-tree failed");
255
+ die(_("read-tree failed"));
256
}
257
258
static void reset_hard(unsigned const char *sha1, int verbose)
@@ -269,7 +269,7 @@ static void reset_hard(unsigned const char *sha1, int verbose)
269
args[i] = NULL;
270
271
if (run_command_v_opt(args, RUN_GIT_CMD))
272
- die("read-tree failed");
272
+ die(_("read-tree failed"));
273
}
274
275
static void restore_state(void)
@@ -298,7 +298,7 @@ static void restore_state(void)
298
static void finish_up_to_date(const char *msg)
299
{
300
if (verbosity >= 0)
301
- printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
301
+ printf("%s%s\n", squash ? _(" (nothing to squash)") : "", msg);
302
drop_save();
303
}
304
@@ -311,10 +311,10 @@ static void squash_message(void)
311
int fd;
312
struct pretty_print_context ctx = {0};
313
314
- printf("Squash commit -- not updating HEAD\n");
314
+ printf(_("Squash commit -- not updating HEAD\n"));
315
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
316
if (fd < 0)
317
- die_errno("Could not write to '%s'", git_path("SQUASH_MSG"));
317
+ die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG"));
318
319
init_revisions(&rev, NULL);
320
rev.ignore_merges = 1;
@@ -329,7 +329,7 @@ static void squash_message(void)
329
330
setup_revisions(0, NULL, &rev, NULL);
331
if (prepare_revision_walk(&rev))
332
- die("revision walk setup failed");
332
+ die(_("revision walk setup failed"));
333
334
ctx.abbrev = rev.abbrev;
335
ctx.date_mode = rev.date_mode;
@@ -342,9 +342,9 @@ static void squash_message(void)
342
pretty_print_commit(rev.commit_format, commit, &out, &ctx);
343
}
344
if (write(fd, out.buf, out.len) < 0)
345
- die_errno("Writing SQUASH_MSG");
345
+ die_errno(_("Writing SQUASH_MSG"));
346
if (close(fd))
347
- die_errno("Finishing SQUASH_MSG");
347
+ die_errno(_("Finishing SQUASH_MSG"));
348
strbuf_release(&out);
349
}
350
@@ -364,7 +364,7 @@ static void finish(const unsigned char *new_head, const char *msg)
364
squash_message();
365
} else {
366
if (verbosity >= 0 && !merge_msg.len)
367
- printf("No merge message -- not updating HEAD\n");
367
+ printf(_("No merge message -- not updating HEAD\n"));
368
else {
369
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
370
update_ref(reflog_message.buf, "HEAD",
@@ -386,7 +386,7 @@ static void finish(const unsigned char *new_head, const char *msg)
386
if (diff_use_color_default > 0)
387
DIFF_OPT_SET(&opts, COLOR_DIFF);
388
if (diff_setup_done(&opts) < 0)
389
- die("diff_setup_done failed");
389
+ die(_("diff_setup_done failed"));
390
diff_tree_sha1(head, new_head, "", &opts);
391
diffcore_std(&opts);
392
diff_flush(&opts);
@@ -415,7 +415,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
415
memset(branch_head, 0, sizeof(branch_head));
416
remote_head = peel_to_type(remote, 0, NULL, OBJ_COMMIT);
417
if (!remote_head)
418
- die("'%s' does not point to a commit", remote);
418
+ die(_("'%s' does not point to a commit"), remote);
419
420
if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
421
if (!prefixcmp(found_ref, "refs/heads/")) {
@@ -480,7 +480,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
480
481
fp = fopen(git_path("FETCH_HEAD"), "r");
482
if (!fp)
483
- die_errno("could not open '%s' for reading",
483
+ die_errno(_("could not open '%s' for reading"),
484
git_path("FETCH_HEAD"));
485
strbuf_getline(&line, fp, '\n');
486
fclose(fp);
@@ -510,7 +510,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
510
buf = xstrdup(v);
511
argc = split_cmdline(buf, &argv);
512
if (argc < 0)
513
- die("Bad branch.%s.mergeoptions string: %s", branch,
513
+ die(_("Bad branch.%s.mergeoptions string: %s"), branch,
514
split_cmdline_strerror(argc));
515
argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
516
memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
@@ -532,7 +532,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
532
int is_bool;
533
shortlog_len = git_config_bool_or_int(k, v, &is_bool);
534
if (!is_bool && shortlog_len < 0)
535
- return error("%s: negative length %s", k, v);
535
+ return error(_("%s: negative length %s"), k, v);
536
if (is_bool && shortlog_len)
537
shortlog_len = DEFAULT_MERGE_LOG_LEN;
538
return 0;
@@ -579,7 +579,7 @@ static int read_tree_trivial(unsigned char *common, unsigned char *head,
579
static void write_tree_trivial(unsigned char *sha1)
580
{
581
if (write_cache_as_tree(sha1, 0, NULL))
582
- die("git write-tree failed to write a tree");
582
+ die(_("git write-tree failed to write a tree"));
583
}
584
585
int try_merge_command(const char *strategy, size_t xopts_nr,
@@ -621,7 +621,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
621
free(args);
622
discard_cache();
623
if (read_cache() < 0)
624
- die("failed to read the cache");
624
+ die(_("failed to read the cache"));
625
resolve_undo_clear();
626
627
return ret;
@@ -638,7 +638,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
638
if (active_cache_changed &&
639
(write_cache(index_fd, active_cache, active_nr) ||
640
commit_locked_index(lock)))
641
- return error("Unable to write index.");
641
+ return error(_("Unable to write index."));
642
rollback_lock_file(lock);
643
644
if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
@@ -651,7 +651,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
651
struct commit_list *j;
652
653
if (remoteheads->next) {
654
- error("Not handling anything other than two heads merge.");
654
+ error(_("Not handling anything other than two heads merge."));
655
return 2;
656
}
657
@@ -663,7 +663,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
663
664
for (x = 0; x < xopts_nr; x++)
665
if (parse_merge_opt(&o, xopts[x]))
666
- die("Unknown option for merge-recursive: -X%s", xopts[x]);
666
+ die(_("Unknown option for merge-recursive: -X%s"), xopts[x]);
667
668
o.branch1 = head_arg;
669
o.branch2 = remoteheads->item->util;
@@ -677,7 +677,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
677
if (active_cache_changed &&
678
(write_cache(index_fd, active_cache, active_nr) ||
679
commit_locked_index(lock)))
680
- die ("unable to write %s", get_index_file());
680
+ die (_("unable to write %s"), get_index_file());
681
rollback_lock_file(lock);
682
return clean ? 0 : 1;
683
} else {
@@ -749,7 +749,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
749
return -1;
750
if (write_cache(fd, active_cache, active_nr) ||
751
commit_locked_index(lock_file))
752
- die("unable to write new index file");
752
+ die(_("unable to write new index file"));
753
return 0;
754
}
755
@@ -852,7 +852,7 @@ static int suggest_conflicts(int renormalizing)
852
853
fp = fopen(git_path("MERGE_MSG"), "a");
854
if (!fp)
855
- die_errno("Could not open '%s' for writing",
855
+ die_errno(_("Could not open '%s' for writing"),
856
git_path("MERGE_MSG"));
857
fprintf(fp, "\nConflicts:\n");
858
for (pos = 0; pos < active_nr; pos++) {
@@ -868,8 +868,8 @@ static int suggest_conflicts(int renormalizing)
868
}
869
fclose(fp);
870
rerere(allow_rerere_auto);
871
- printf("Automatic merge failed; "
872
- "fix conflicts and then commit the result.\n");
871
+ printf(_("Automatic merge failed; "
872
+ "fix conflicts and then commit the result.\n"));
873
return 1;
874
}
875
@@ -883,7 +883,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv)
883
return NULL;
884
second_token = lookup_commit_reference_gently(second_sha1, 0);
885
if (!second_token)
886
- die("'%s' is not a commit", argv[1]);
886
+ die(_("'%s' is not a commit"), argv[1]);
887
if (hashcmp(second_token->object.sha1, head))
888
return NULL;
889
}
@@ -951,7 +951,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
951
const char *nargv[] = {"reset", "--merge", NULL};
952
953
if (!file_exists(git_path("MERGE_HEAD")))
954
- die("There is no merge to abort (MERGE_HEAD missing).");
954
+ die(_("There is no merge to abort (MERGE_HEAD missing)."));
955
956
/* Invoke 'git reset --merge' */
957
return cmd_reset(nargc, nargv, prefix);
@@ -966,10 +966,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
966
* add/rm <file>', just 'git commit'.
967
*/
968
if (advice_resolve_conflict)
969
- die("You have not concluded your merge (MERGE_HEAD exists).\n"
970
- "Please, commit your changes before you can merge.");
969
+ die(_("You have not concluded your merge (MERGE_HEAD exists).\n"
970
+ "Please, commit your changes before you can merge."));
971
else
972
- die("You have not concluded your merge (MERGE_HEAD exists).");
972
+ die(_("You have not concluded your merge (MERGE_HEAD exists)."));
973
}
974
resolve_undo_clear();
975
@@ -978,12 +978,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
978
979
if (squash) {
980
if (!allow_fast_forward)
981
- die("You cannot combine --squash with --no-ff.");
981
+ die(_("You cannot combine --squash with --no-ff."));
982
option_commit = 0;
983
}
984
985
if (!allow_fast_forward && fast_forward_only)
986
- die("You cannot combine --no-ff with --ff-only.");
986
+ die(_("You cannot combine --no-ff with --ff-only."));
987
988
if (!argc)
989
usage_with_options(builtin_merge_usage,
@@ -1011,16 +1011,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1011
* We do the same for "git pull".
1012
*/
1013
if (argc != 1)
1014
- die("Can merge only exactly one commit into "
1015
- "empty head");
1014
+ die(_("Can merge only exactly one commit into "
1015
+ "empty head"));
1016
if (squash)
1017
- die("Squash commit into empty head not supported yet");
1017
+ die(_("Squash commit into empty head not supported yet"));
1018
if (!allow_fast_forward)
1019
- die("Non-fast-forward commit does not make sense into "
1020
- "an empty head");
1019
+ die(_("Non-fast-forward commit does not make sense into "
1020
+ "an empty head"));
1021
remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
1022
if (!remote_head)
1023
- die("%s - not something we can merge", argv[0]);
1023
+ die(_("%s - not something we can merge"), argv[0]);
1024
update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
1025
DIE_ON_ERR);
1026
read_empty(remote_head->sha1, 0);
@@ -1066,7 +1066,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1066
1067
o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
1068
if (!o)
1069
- die("%s - not something we can merge", argv[i]);
1069
+ die(_("%s - not something we can merge"), argv[i]);
1070
commit = lookup_commit(o->sha1);
1071
commit->util = (void *)argv[i];
1072
remotes = &commit_list_insert(commit, remotes)->next;
@@ -1158,11 +1158,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1158
if (allow_trivial && !fast_forward_only) {
1159
/* See if it is really trivial. */
1160
git_committer_info(IDENT_ERROR_ON_NO_NAME);
1161
- printf("Trying really trivial in-index merge...\n");
1161
+ printf(_("Trying really trivial in-index merge...\n"));
1162
if (!read_tree_trivial(common->item->object.sha1,
1163
head, remoteheads->item->object.sha1))
1164
return merge_trivial();
1165
- printf("Nope.\n");
1165
+ printf(_("Nope.\n"));
1166
}
1167
} else {
1168
/*
@@ -1195,7 +1195,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1195
}
1196
1197
if (fast_forward_only)
1198
- die("Not possible to fast-forward, aborting.");
1198
+ die(_("Not possible to fast-forward, aborting."));
1199
1200
/* We are going to make a new commit. */
1201
git_committer_info(IDENT_ERROR_ON_NO_NAME);
@@ -1221,11 +1221,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1221
for (i = 0; i < use_strategies_nr; i++) {
1222
int ret;
1223
if (i) {
1224
- printf("Rewinding the tree to pristine...\n");
1224
+ printf(_("Rewinding the tree to pristine...\n"));
1225
restore_state();
1226
}
1227
if (use_strategies_nr != 1)
1228
- printf("Trying merge strategy %s...\n",
1228
+ printf(_("Trying merge strategy %s...\n"),
1229
use_strategies[i]->name);
1230
/*
1231
* Remember which strategy left the state in the working
@@ -1286,17 +1286,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1286
restore_state();
1287
if (use_strategies_nr > 1)
1288
fprintf(stderr,
1289
- "No merge strategy handled the merge.\n");
1289
+ _("No merge strategy handled the merge.\n"));
1290
else
1291
- fprintf(stderr, "Merge with strategy %s failed.\n",
1291
+ fprintf(stderr, _("Merge with strategy %s failed.\n"),
1292
use_strategies[0]->name);
1293
return 2;
1294
} else if (best_strategy == wt_strategy)
1295
; /* We already have its result in the working tree. */
1296
else {
1297
- printf("Rewinding the tree to pristine...\n");
1297
+ printf(_("Rewinding the tree to pristine...\n"));
1298
restore_state();
1299
- printf("Using the %s to prepare resolving by hand.\n",
1299
+ printf(_("Using the %s to prepare resolving by hand.\n"),
1300
best_strategy);
1301
try_merge_strategy(best_strategy, common, head_arg);
1302
}
@@ -1312,35 +1312,35 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1312
sha1_to_hex(j->item->object.sha1));
1313
fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
1314
if (fd < 0)
1315
- die_errno("Could not open '%s' for writing",
1315
+ die_errno(_("Could not open '%s' for writing"),
1316
git_path("MERGE_HEAD"));
1317
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
1318
- die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
1318
+ die_errno(_("Could not write to '%s'"), git_path("MERGE_HEAD"));
1319
close(fd);
1320
strbuf_addch(&merge_msg, '\n');
1321
fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
1322
if (fd < 0)
1323
- die_errno("Could not open '%s' for writing",
1323
+ die_errno(_("Could not open '%s' for writing"),
1324
git_path("MERGE_MSG"));
1325
if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
1326
merge_msg.len)
1327
- die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
1327
+ die_errno(_("Could not write to '%s'"), git_path("MERGE_MSG"));
1328
close(fd);
1329
fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
1330
if (fd < 0)
1331
- die_errno("Could not open '%s' for writing",
1331
+ die_errno(_("Could not open '%s' for writing"),
1332
git_path("MERGE_MODE"));
1333
strbuf_reset(&buf);
1334
if (!allow_fast_forward)
1335
strbuf_addf(&buf, "no-ff");
1336
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
1337
- die_errno("Could not write to '%s'", git_path("MERGE_MODE"));
1337
+ die_errno(_("Could not write to '%s'"), git_path("MERGE_MODE"));
1338
close(fd);
1339
}
1340
1341
if (merge_was_ok) {
1342
- fprintf(stderr, "Automatic merge went well; "
1343
- "stopped before committing as requested\n");
1342
+ fprintf(stderr, _("Automatic merge went well; "
1343
+ "stopped before committing as requested\n"));
1344
return 0;
1345
} else
1346
return suggest_conflicts(option_renormalize);
t/t7607-merge-overwrite.sh
+8
-2
@@ -150,8 +150,14 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
150
git rm -fr . &&
151
git checkout --orphan new &&
152
cp important c0.c &&
153
- test_must_fail git merge c0 2>out &&
154
- test_cmp out expect &&
153
+ test_must_fail git merge c0 2>out
154
+'
155
+
156
+test_expect_success C_LOCALE_OUTPUT 'will not overwrite untracked file on unborn branch: output' '
157
+ test_cmp out expect
158
+'
159
+
160
+test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' '
161
test_path_is_missing .git/MERGE_HEAD &&
162
test_cmp important c0.c
163
'
t/t7611-merge-abort.sh
+16
-4
@@ -46,8 +46,14 @@ test_expect_success 'setup' '
46
pre_merge_head="$(git rev-parse HEAD)"
47
48
test_expect_success 'fails without MERGE_HEAD (unstarted merge)' '
49
- test_must_fail git merge --abort 2>output &&
50
- grep -q MERGE_HEAD output &&
49
+ test_must_fail git merge --abort 2>output
50
+'
51
+
52
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (unstarted merge): fatal output' '
53
+ grep -q MERGE_HEAD output
54
+'
55
+
56
+test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' '
57
test ! -f .git/MERGE_HEAD &&
58
test "$pre_merge_head" = "$(git rev-parse HEAD)"
59
'
@@ -57,8 +63,14 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' '
63
test ! -f .git/MERGE_HEAD &&
64
# Merge successfully completed
65
post_merge_head="$(git rev-parse HEAD)" &&
60
- test_must_fail git merge --abort 2>output &&
61
- grep -q MERGE_HEAD output &&
66
+ test_must_fail git merge --abort 2>output
67
+'
68
+
69
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (completed merge): output' '
70
+ grep -q MERGE_HEAD output
71
+'
72
+
73
+test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' '
74
test ! -f .git/MERGE_HEAD &&
75
test "$post_merge_head" = "$(git rev-parse HEAD)"
76
'