i18n: apply: mark strings for translation
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
bb16d5dd30
commit
3638eb431b
174
builtin/apply.c
174
builtin/apply.c
@ -103,7 +103,7 @@ static void parse_whitespace_option(const char *option)
|
|||||||
ws_error_action = correct_ws_error;
|
ws_error_action = correct_ws_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
die("unrecognized whitespace option '%s'", option);
|
die(_("unrecognized whitespace option '%s'"), option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_ignorewhitespace_option(const char *option)
|
static void parse_ignorewhitespace_option(const char *option)
|
||||||
@ -118,7 +118,7 @@ static void parse_ignorewhitespace_option(const char *option)
|
|||||||
ws_ignore_action = ignore_ws_change;
|
ws_ignore_action = ignore_ws_change;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
die("unrecognized whitespace ignore option '%s'", option);
|
die(_("unrecognized whitespace ignore option '%s'"), option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_default_whitespace_mode(const char *whitespace_option)
|
static void set_default_whitespace_mode(const char *whitespace_option)
|
||||||
@ -770,7 +770,7 @@ static int has_epoch_timestamp(const char *nameline)
|
|||||||
if (!stamp) {
|
if (!stamp) {
|
||||||
stamp = xmalloc(sizeof(*stamp));
|
stamp = xmalloc(sizeof(*stamp));
|
||||||
if (regcomp(stamp, stamp_regexp, REG_EXTENDED)) {
|
if (regcomp(stamp, stamp_regexp, REG_EXTENDED)) {
|
||||||
warning("Cannot prepare timestamp regexp %s",
|
warning(_("Cannot prepare timestamp regexp %s"),
|
||||||
stamp_regexp);
|
stamp_regexp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -779,7 +779,7 @@ static int has_epoch_timestamp(const char *nameline)
|
|||||||
status = regexec(stamp, timestamp, ARRAY_SIZE(m), m, 0);
|
status = regexec(stamp, timestamp, ARRAY_SIZE(m), m, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
if (status != REG_NOMATCH)
|
if (status != REG_NOMATCH)
|
||||||
warning("regexec returned %d for input: %s",
|
warning(_("regexec returned %d for input: %s"),
|
||||||
status, timestamp);
|
status, timestamp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -857,7 +857,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!name)
|
if (!name)
|
||||||
die("unable to find filename in patch at line %d", linenr);
|
die(_("unable to find filename in patch at line %d"), linenr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gitdiff_hdrend(const char *line, struct patch *patch)
|
static int gitdiff_hdrend(const char *line, struct patch *patch)
|
||||||
@ -886,17 +886,17 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
|
|||||||
name = orig_name;
|
name = orig_name;
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
die("git apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
|
die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), name, linenr);
|
||||||
another = find_name(line, NULL, p_value, TERM_TAB);
|
another = find_name(line, NULL, p_value, TERM_TAB);
|
||||||
if (!another || memcmp(another, name, len + 1))
|
if (!another || memcmp(another, name, len + 1))
|
||||||
die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
|
die(_("git apply: bad git-diff - inconsistent %s filename on line %d"), oldnew, linenr);
|
||||||
free(another);
|
free(another);
|
||||||
return orig_name;
|
return orig_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* expect "/dev/null" */
|
/* expect "/dev/null" */
|
||||||
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
|
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
|
||||||
die("git apply: bad git-diff - expected /dev/null on line %d", linenr);
|
die(_("git apply: bad git-diff - expected /dev/null on line %d"), linenr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1327,7 +1327,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
warning("recount: unexpected line: %.*s",
|
warning(_("recount: unexpected line: %.*s"),
|
||||||
(int)linelen(line, size), line);
|
(int)linelen(line, size), line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1384,7 +1384,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
|
|||||||
struct fragment dummy;
|
struct fragment dummy;
|
||||||
if (parse_fragment_header(line, len, &dummy) < 0)
|
if (parse_fragment_header(line, len, &dummy) < 0)
|
||||||
continue;
|
continue;
|
||||||
die("patch fragment without header at line %d: %.*s",
|
die(_("patch fragment without header at line %d: %.*s"),
|
||||||
linenr, (int)len-1, line);
|
linenr, (int)len-1, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,8 +1401,12 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
|
|||||||
continue;
|
continue;
|
||||||
if (!patch->old_name && !patch->new_name) {
|
if (!patch->old_name && !patch->new_name) {
|
||||||
if (!patch->def_name)
|
if (!patch->def_name)
|
||||||
die("git diff header lacks filename information when removing "
|
die(Q_("git diff header lacks filename information when removing "
|
||||||
"%d leading pathname components (line %d)" , p_value, linenr);
|
"%d leading pathname component (line %d)",
|
||||||
|
"git diff header lacks filename information when removing "
|
||||||
|
"%d leading pathname components (line %d)",
|
||||||
|
p_value),
|
||||||
|
p_value, linenr);
|
||||||
patch->old_name = patch->new_name = patch->def_name;
|
patch->old_name = patch->new_name = patch->def_name;
|
||||||
}
|
}
|
||||||
if (!patch->is_delete && !patch->new_name)
|
if (!patch->is_delete && !patch->new_name)
|
||||||
@ -1556,9 +1560,9 @@ static int parse_fragment(char *line, unsigned long size,
|
|||||||
patch->lines_deleted += deleted;
|
patch->lines_deleted += deleted;
|
||||||
|
|
||||||
if (0 < patch->is_new && oldlines)
|
if (0 < patch->is_new && oldlines)
|
||||||
return error("new file depends on old contents");
|
return error(_("new file depends on old contents"));
|
||||||
if (0 < patch->is_delete && newlines)
|
if (0 < patch->is_delete && newlines)
|
||||||
return error("deleted file still has contents");
|
return error(_("deleted file still has contents"));
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1576,7 +1580,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
|
|||||||
fragment->linenr = linenr;
|
fragment->linenr = linenr;
|
||||||
len = parse_fragment(line, size, patch, fragment);
|
len = parse_fragment(line, size, patch, fragment);
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
die("corrupt patch at line %d", linenr);
|
die(_("corrupt patch at line %d"), linenr);
|
||||||
fragment->patch = line;
|
fragment->patch = line;
|
||||||
fragment->size = len;
|
fragment->size = len;
|
||||||
oldlines += fragment->oldlines;
|
oldlines += fragment->oldlines;
|
||||||
@ -1612,12 +1616,14 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
|
|||||||
patch->is_delete = 0;
|
patch->is_delete = 0;
|
||||||
|
|
||||||
if (0 < patch->is_new && oldlines)
|
if (0 < patch->is_new && oldlines)
|
||||||
die("new file %s depends on old contents", patch->new_name);
|
die(_("new file %s depends on old contents"), patch->new_name);
|
||||||
if (0 < patch->is_delete && newlines)
|
if (0 < patch->is_delete && newlines)
|
||||||
die("deleted file %s still has contents", patch->old_name);
|
die(_("deleted file %s still has contents"), patch->old_name);
|
||||||
if (!patch->is_delete && !newlines && context)
|
if (!patch->is_delete && !newlines && context)
|
||||||
fprintf(stderr, "** warning: file %s becomes empty but "
|
fprintf_ln(stderr,
|
||||||
"is not deleted\n", patch->new_name);
|
_("** warning: "
|
||||||
|
"file %s becomes empty but is not deleted"),
|
||||||
|
patch->new_name);
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
@ -1755,7 +1761,7 @@ static struct fragment *parse_binary_hunk(char **buf_p,
|
|||||||
corrupt:
|
corrupt:
|
||||||
free(data);
|
free(data);
|
||||||
*status_p = -1;
|
*status_p = -1;
|
||||||
error("corrupt binary patch at line %d: %.*s",
|
error(_("corrupt binary patch at line %d: %.*s"),
|
||||||
linenr-1, llen-1, buffer);
|
linenr-1, llen-1, buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1784,7 +1790,7 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
|
|||||||
forward = parse_binary_hunk(&buffer, &size, &status, &used);
|
forward = parse_binary_hunk(&buffer, &size, &status, &used);
|
||||||
if (!forward && !status)
|
if (!forward && !status)
|
||||||
/* there has to be one hunk (forward hunk) */
|
/* there has to be one hunk (forward hunk) */
|
||||||
return error("unrecognized binary patch at line %d", linenr-1);
|
return error(_("unrecognized binary patch at line %d"), linenr-1);
|
||||||
if (status)
|
if (status)
|
||||||
/* otherwise we already gave an error message */
|
/* otherwise we already gave an error message */
|
||||||
return status;
|
return status;
|
||||||
@ -1863,7 +1869,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
|
|||||||
*/
|
*/
|
||||||
if ((apply || check) &&
|
if ((apply || check) &&
|
||||||
(!patch->is_binary && !metadata_changes(patch)))
|
(!patch->is_binary && !metadata_changes(patch)))
|
||||||
die("patch with only garbage at line %d", linenr);
|
die(_("patch with only garbage at line %d"), linenr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset + hdrsize + patchsize;
|
return offset + hdrsize + patchsize;
|
||||||
@ -1953,11 +1959,11 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
|
|||||||
switch (st->st_mode & S_IFMT) {
|
switch (st->st_mode & S_IFMT) {
|
||||||
case S_IFLNK:
|
case S_IFLNK:
|
||||||
if (strbuf_readlink(buf, path, st->st_size) < 0)
|
if (strbuf_readlink(buf, path, st->st_size) < 0)
|
||||||
return error("unable to read symlink %s", path);
|
return error(_("unable to read symlink %s"), path);
|
||||||
return 0;
|
return 0;
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
|
if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
|
||||||
return error("unable to open or read %s", path);
|
return error(_("unable to open or read %s"), path);
|
||||||
convert_to_git(path, buf->buf, buf->len, buf, 0);
|
convert_to_git(path, buf->buf, buf->len, buf, 0);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
@ -2028,7 +2034,7 @@ static void update_pre_post_images(struct image *preimage,
|
|||||||
ctx++;
|
ctx++;
|
||||||
}
|
}
|
||||||
if (preimage->nr <= ctx)
|
if (preimage->nr <= ctx)
|
||||||
die("oops");
|
die(_("oops"));
|
||||||
|
|
||||||
/* and copy it in, while fixing the line length */
|
/* and copy it in, while fixing the line length */
|
||||||
len = preimage->line[ctx].len;
|
len = preimage->line[ctx].len;
|
||||||
@ -2540,7 +2546,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (apply_verbosely)
|
if (apply_verbosely)
|
||||||
error("invalid start of line: '%c'", first);
|
error(_("invalid start of line: '%c'"), first);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (added_blank_line) {
|
if (added_blank_line) {
|
||||||
@ -2657,9 +2663,11 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
|
|||||||
int offset = applied_pos - pos;
|
int offset = applied_pos - pos;
|
||||||
if (apply_in_reverse)
|
if (apply_in_reverse)
|
||||||
offset = 0 - offset;
|
offset = 0 - offset;
|
||||||
fprintf(stderr,
|
fprintf_ln(stderr,
|
||||||
"Hunk #%d succeeded at %d (offset %d lines).\n",
|
Q_("Hunk #%d succeeded at %d (offset %d line).",
|
||||||
nth_fragment, applied_pos + 1, offset);
|
"Hunk #%d succeeded at %d (offset %d lines).",
|
||||||
|
offset),
|
||||||
|
nth_fragment, applied_pos + 1, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2668,13 +2676,13 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
|
|||||||
*/
|
*/
|
||||||
if ((leading != frag->leading) ||
|
if ((leading != frag->leading) ||
|
||||||
(trailing != frag->trailing))
|
(trailing != frag->trailing))
|
||||||
fprintf(stderr, "Context reduced to (%ld/%ld)"
|
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
|
||||||
" to apply fragment at %d\n",
|
" to apply fragment at %d"),
|
||||||
leading, trailing, applied_pos+1);
|
leading, trailing, applied_pos+1);
|
||||||
update_image(img, applied_pos, &preimage, &postimage);
|
update_image(img, applied_pos, &preimage, &postimage);
|
||||||
} else {
|
} else {
|
||||||
if (apply_verbosely)
|
if (apply_verbosely)
|
||||||
error("while searching for:\n%.*s",
|
error(_("while searching for:\n%.*s"),
|
||||||
(int)(old - oldlines), oldlines);
|
(int)(old - oldlines), oldlines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2693,7 +2701,7 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)
|
|||||||
void *dst;
|
void *dst;
|
||||||
|
|
||||||
if (!fragment)
|
if (!fragment)
|
||||||
return error("missing binary patch data for '%s'",
|
return error(_("missing binary patch data for '%s'"),
|
||||||
patch->new_name ?
|
patch->new_name ?
|
||||||
patch->new_name :
|
patch->new_name :
|
||||||
patch->old_name);
|
patch->old_name);
|
||||||
@ -2790,13 +2798,13 @@ static int apply_binary(struct image *img, struct patch *patch)
|
|||||||
* in the patch->fragments->{patch,size}.
|
* in the patch->fragments->{patch,size}.
|
||||||
*/
|
*/
|
||||||
if (apply_binary_fragment(img, patch))
|
if (apply_binary_fragment(img, patch))
|
||||||
return error("binary patch does not apply to '%s'",
|
return error(_("binary patch does not apply to '%s'"),
|
||||||
name);
|
name);
|
||||||
|
|
||||||
/* verify that the result matches */
|
/* verify that the result matches */
|
||||||
hash_sha1_file(img->buf, img->len, blob_type, sha1);
|
hash_sha1_file(img->buf, img->len, blob_type, sha1);
|
||||||
if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
|
if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
|
||||||
return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)",
|
return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),
|
||||||
name, patch->new_sha1_prefix, sha1_to_hex(sha1));
|
name, patch->new_sha1_prefix, sha1_to_hex(sha1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2817,7 +2825,7 @@ static int apply_fragments(struct image *img, struct patch *patch)
|
|||||||
while (frag) {
|
while (frag) {
|
||||||
nth++;
|
nth++;
|
||||||
if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {
|
if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {
|
||||||
error("patch failed: %s:%ld", name, frag->oldpos);
|
error(_("patch failed: %s:%ld"), name, frag->oldpos);
|
||||||
if (!apply_with_reject)
|
if (!apply_with_reject)
|
||||||
return -1;
|
return -1;
|
||||||
frag->rejected = 1;
|
frag->rejected = 1;
|
||||||
@ -2932,14 +2940,14 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
|
|||||||
if (!(patch->is_copy || patch->is_rename) &&
|
if (!(patch->is_copy || patch->is_rename) &&
|
||||||
(tpatch = in_fn_table(patch->old_name)) != NULL && !to_be_deleted(tpatch)) {
|
(tpatch = in_fn_table(patch->old_name)) != NULL && !to_be_deleted(tpatch)) {
|
||||||
if (was_deleted(tpatch)) {
|
if (was_deleted(tpatch)) {
|
||||||
return error("patch %s has been renamed/deleted",
|
return error(_("patch %s has been renamed/deleted"),
|
||||||
patch->old_name);
|
patch->old_name);
|
||||||
}
|
}
|
||||||
/* We have a patched copy in memory use that */
|
/* We have a patched copy in memory use that */
|
||||||
strbuf_add(&buf, tpatch->result, tpatch->resultsize);
|
strbuf_add(&buf, tpatch->result, tpatch->resultsize);
|
||||||
} else if (cached) {
|
} else if (cached) {
|
||||||
if (read_file_or_gitlink(ce, &buf))
|
if (read_file_or_gitlink(ce, &buf))
|
||||||
return error("read of %s failed", patch->old_name);
|
return error(_("read of %s failed"), patch->old_name);
|
||||||
} else if (patch->old_name) {
|
} else if (patch->old_name) {
|
||||||
if (S_ISGITLINK(patch->old_mode)) {
|
if (S_ISGITLINK(patch->old_mode)) {
|
||||||
if (ce) {
|
if (ce) {
|
||||||
@ -2953,7 +2961,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (read_old_data(st, patch->old_name, &buf))
|
if (read_old_data(st, patch->old_name, &buf))
|
||||||
return error("read of %s failed", patch->old_name);
|
return error(_("read of %s failed"), patch->old_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2968,7 +2976,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
|
|||||||
free(image.line_allocated);
|
free(image.line_allocated);
|
||||||
|
|
||||||
if (0 < patch->is_delete && patch->resultsize)
|
if (0 < patch->is_delete && patch->resultsize)
|
||||||
return error("removal patch leaves file contents");
|
return error(_("removal patch leaves file contents"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2989,7 +2997,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
|
|||||||
if (has_symlink_leading_path(new_name, strlen(new_name)))
|
if (has_symlink_leading_path(new_name, strlen(new_name)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return error("%s: already exists in working directory", new_name);
|
return error(_("%s: already exists in working directory"), new_name);
|
||||||
}
|
}
|
||||||
else if ((errno != ENOENT) && (errno != ENOTDIR))
|
else if ((errno != ENOENT) && (errno != ENOTDIR))
|
||||||
return error("%s: %s", new_name, strerror(errno));
|
return error("%s: %s", new_name, strerror(errno));
|
||||||
@ -3027,12 +3035,12 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
|
|||||||
if (!(patch->is_copy || patch->is_rename) &&
|
if (!(patch->is_copy || patch->is_rename) &&
|
||||||
(tpatch = in_fn_table(old_name)) != NULL && !to_be_deleted(tpatch)) {
|
(tpatch = in_fn_table(old_name)) != NULL && !to_be_deleted(tpatch)) {
|
||||||
if (was_deleted(tpatch))
|
if (was_deleted(tpatch))
|
||||||
return error("%s: has been deleted/renamed", old_name);
|
return error(_("%s: has been deleted/renamed"), old_name);
|
||||||
st_mode = tpatch->new_mode;
|
st_mode = tpatch->new_mode;
|
||||||
} else if (!cached) {
|
} else if (!cached) {
|
||||||
stat_ret = lstat(old_name, st);
|
stat_ret = lstat(old_name, st);
|
||||||
if (stat_ret && errno != ENOENT)
|
if (stat_ret && errno != ENOENT)
|
||||||
return error("%s: %s", old_name, strerror(errno));
|
return error(_("%s: %s"), old_name, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_be_deleted(tpatch))
|
if (to_be_deleted(tpatch))
|
||||||
@ -3043,7 +3051,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
|
|||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
if (patch->is_new < 0)
|
if (patch->is_new < 0)
|
||||||
goto is_new;
|
goto is_new;
|
||||||
return error("%s: does not exist in index", old_name);
|
return error(_("%s: does not exist in index"), old_name);
|
||||||
}
|
}
|
||||||
*ce = active_cache[pos];
|
*ce = active_cache[pos];
|
||||||
if (stat_ret < 0) {
|
if (stat_ret < 0) {
|
||||||
@ -3057,13 +3065,13 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!cached && verify_index_match(*ce, st))
|
if (!cached && verify_index_match(*ce, st))
|
||||||
return error("%s: does not match index", old_name);
|
return error(_("%s: does not match index"), old_name);
|
||||||
if (cached)
|
if (cached)
|
||||||
st_mode = (*ce)->ce_mode;
|
st_mode = (*ce)->ce_mode;
|
||||||
} else if (stat_ret < 0) {
|
} else if (stat_ret < 0) {
|
||||||
if (patch->is_new < 0)
|
if (patch->is_new < 0)
|
||||||
goto is_new;
|
goto is_new;
|
||||||
return error("%s: %s", old_name, strerror(errno));
|
return error(_("%s: %s"), old_name, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cached && !tpatch)
|
if (!cached && !tpatch)
|
||||||
@ -3074,9 +3082,9 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
|
|||||||
if (!patch->old_mode)
|
if (!patch->old_mode)
|
||||||
patch->old_mode = st_mode;
|
patch->old_mode = st_mode;
|
||||||
if ((st_mode ^ patch->old_mode) & S_IFMT)
|
if ((st_mode ^ patch->old_mode) & S_IFMT)
|
||||||
return error("%s: wrong type", old_name);
|
return error(_("%s: wrong type"), old_name);
|
||||||
if (st_mode != patch->old_mode)
|
if (st_mode != patch->old_mode)
|
||||||
warning("%s has type %o, expected %o",
|
warning(_("%s has type %o, expected %o"),
|
||||||
old_name, st_mode, patch->old_mode);
|
old_name, st_mode, patch->old_mode);
|
||||||
if (!patch->new_mode && !patch->is_delete)
|
if (!patch->new_mode && !patch->is_delete)
|
||||||
patch->new_mode = st_mode;
|
patch->new_mode = st_mode;
|
||||||
@ -3126,7 +3134,7 @@ static int check_patch(struct patch *patch)
|
|||||||
if (check_index &&
|
if (check_index &&
|
||||||
cache_name_pos(new_name, strlen(new_name)) >= 0 &&
|
cache_name_pos(new_name, strlen(new_name)) >= 0 &&
|
||||||
!ok_if_exists)
|
!ok_if_exists)
|
||||||
return error("%s: already exists in index", new_name);
|
return error(_("%s: already exists in index"), new_name);
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
int err = check_to_create_blob(new_name, ok_if_exists);
|
int err = check_to_create_blob(new_name, ok_if_exists);
|
||||||
if (err)
|
if (err)
|
||||||
@ -3145,13 +3153,13 @@ static int check_patch(struct patch *patch)
|
|||||||
if (!patch->new_mode)
|
if (!patch->new_mode)
|
||||||
patch->new_mode = patch->old_mode;
|
patch->new_mode = patch->old_mode;
|
||||||
if ((patch->old_mode ^ patch->new_mode) & S_IFMT)
|
if ((patch->old_mode ^ patch->new_mode) & S_IFMT)
|
||||||
return error("new mode (%o) of %s does not match old mode (%o)%s%s",
|
return error(_("new mode (%o) of %s does not match old mode (%o)%s%s"),
|
||||||
patch->new_mode, new_name, patch->old_mode,
|
patch->new_mode, new_name, patch->old_mode,
|
||||||
same ? "" : " of ", same ? "" : old_name);
|
same ? "" : " of ", same ? "" : old_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apply_data(patch, &st, ce) < 0)
|
if (apply_data(patch, &st, ce) < 0)
|
||||||
return error("%s: patch does not apply", name);
|
return error(_("%s: patch does not apply"), name);
|
||||||
patch->rejected = 0;
|
patch->rejected = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3219,7 +3227,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
|
|||||||
|
|
||||||
ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
|
ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
|
||||||
if (!ce)
|
if (!ce)
|
||||||
die("make_cache_entry failed for path '%s'", name);
|
die(_("make_cache_entry failed for path '%s'"), name);
|
||||||
if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
|
if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
|
||||||
die ("Could not add %s to temporary index", name);
|
die ("Could not add %s to temporary index", name);
|
||||||
}
|
}
|
||||||
@ -3362,7 +3370,7 @@ static void remove_file(struct patch *patch, int rmdir_empty)
|
|||||||
{
|
{
|
||||||
if (update_index) {
|
if (update_index) {
|
||||||
if (remove_file_from_cache(patch->old_name) < 0)
|
if (remove_file_from_cache(patch->old_name) < 0)
|
||||||
die("unable to remove %s from index", patch->old_name);
|
die(_("unable to remove %s from index"), patch->old_name);
|
||||||
}
|
}
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
|
if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
|
||||||
@ -3389,19 +3397,19 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
|
|||||||
const char *s = buf;
|
const char *s = buf;
|
||||||
|
|
||||||
if (get_sha1_hex(s + strlen("Subproject commit "), ce->sha1))
|
if (get_sha1_hex(s + strlen("Subproject commit "), ce->sha1))
|
||||||
die("corrupt patch for subproject %s", path);
|
die(_("corrupt patch for subproject %s"), path);
|
||||||
} else {
|
} else {
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
if (lstat(path, &st) < 0)
|
if (lstat(path, &st) < 0)
|
||||||
die_errno("unable to stat newly created file '%s'",
|
die_errno(_("unable to stat newly created file '%s'"),
|
||||||
path);
|
path);
|
||||||
fill_stat_cache_info(ce, &st);
|
fill_stat_cache_info(ce, &st);
|
||||||
}
|
}
|
||||||
if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
|
if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
|
||||||
die("unable to create backing store for newly created file %s", path);
|
die(_("unable to create backing store for newly created file %s"), path);
|
||||||
}
|
}
|
||||||
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
|
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
|
||||||
die("unable to add cache entry for %s", path);
|
die(_("unable to add cache entry for %s"), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
|
static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
|
||||||
@ -3434,7 +3442,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
|
|||||||
strbuf_release(&nbuf);
|
strbuf_release(&nbuf);
|
||||||
|
|
||||||
if (close(fd) < 0)
|
if (close(fd) < 0)
|
||||||
die_errno("closing file '%s'", path);
|
die_errno(_("closing file '%s'"), path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3483,7 +3491,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
|
|||||||
++nr;
|
++nr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
die_errno("unable to write file '%s' mode %o", path, mode);
|
die_errno(_("unable to write file '%s' mode %o"), path, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_file(struct patch *patch)
|
static void create_file(struct patch *patch)
|
||||||
@ -3546,7 +3554,7 @@ static int write_out_one_reject(struct patch *patch)
|
|||||||
* contents are marked "rejected" at the patch level.
|
* contents are marked "rejected" at the patch level.
|
||||||
*/
|
*/
|
||||||
if (!patch->new_name)
|
if (!patch->new_name)
|
||||||
die("internal error");
|
die(_("internal error"));
|
||||||
|
|
||||||
/* Say this even without --verbose */
|
/* Say this even without --verbose */
|
||||||
say_patch_name(stderr, "Applying patch ", patch, " with");
|
say_patch_name(stderr, "Applying patch ", patch, " with");
|
||||||
@ -3555,7 +3563,7 @@ static int write_out_one_reject(struct patch *patch)
|
|||||||
cnt = strlen(patch->new_name);
|
cnt = strlen(patch->new_name);
|
||||||
if (ARRAY_SIZE(namebuf) <= cnt + 5) {
|
if (ARRAY_SIZE(namebuf) <= cnt + 5) {
|
||||||
cnt = ARRAY_SIZE(namebuf) - 5;
|
cnt = ARRAY_SIZE(namebuf) - 5;
|
||||||
warning("truncating .rej filename to %.*s.rej",
|
warning(_("truncating .rej filename to %.*s.rej"),
|
||||||
cnt - 1, patch->new_name);
|
cnt - 1, patch->new_name);
|
||||||
}
|
}
|
||||||
memcpy(namebuf, patch->new_name, cnt);
|
memcpy(namebuf, patch->new_name, cnt);
|
||||||
@ -3563,7 +3571,7 @@ static int write_out_one_reject(struct patch *patch)
|
|||||||
|
|
||||||
rej = fopen(namebuf, "w");
|
rej = fopen(namebuf, "w");
|
||||||
if (!rej)
|
if (!rej)
|
||||||
return error("cannot open %s: %s", namebuf, strerror(errno));
|
return error(_("cannot open %s: %s"), namebuf, strerror(errno));
|
||||||
|
|
||||||
/* Normal git tools never deal with .rej, so do not pretend
|
/* Normal git tools never deal with .rej, so do not pretend
|
||||||
* this is a git patch by saying --git nor give extended
|
* this is a git patch by saying --git nor give extended
|
||||||
@ -3576,10 +3584,10 @@ static int write_out_one_reject(struct patch *patch)
|
|||||||
frag;
|
frag;
|
||||||
cnt++, frag = frag->next) {
|
cnt++, frag = frag->next) {
|
||||||
if (!frag->rejected) {
|
if (!frag->rejected) {
|
||||||
fprintf(stderr, "Hunk #%d applied cleanly.\n", cnt);
|
fprintf_ln(stderr, _("Hunk #%d applied cleanly."), cnt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Rejected hunk #%d.\n", cnt);
|
fprintf_ln(stderr, _("Rejected hunk #%d."), cnt);
|
||||||
fprintf(rej, "%.*s", frag->size, frag->patch);
|
fprintf(rej, "%.*s", frag->size, frag->patch);
|
||||||
if (frag->patch[frag->size-1] != '\n')
|
if (frag->patch[frag->size-1] != '\n')
|
||||||
fputc('\n', rej);
|
fputc('\n', rej);
|
||||||
@ -3720,7 +3728,7 @@ static int apply_patch(int fd, const char *filename, int options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!list && !skipped_patch)
|
if (!list && !skipped_patch)
|
||||||
die("unrecognized input");
|
die(_("unrecognized input"));
|
||||||
|
|
||||||
if (whitespace_error && (ws_error_action == die_on_ws_error))
|
if (whitespace_error && (ws_error_action == die_on_ws_error))
|
||||||
apply = 0;
|
apply = 0;
|
||||||
@ -3731,7 +3739,7 @@ static int apply_patch(int fd, const char *filename, int options)
|
|||||||
|
|
||||||
if (check_index) {
|
if (check_index) {
|
||||||
if (read_cache() < 0)
|
if (read_cache() < 0)
|
||||||
die("unable to read index file");
|
die(_("unable to read index file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((check || apply) &&
|
if ((check || apply) &&
|
||||||
@ -3924,10 +3932,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
|
|||||||
if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
|
if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
|
||||||
apply = 0;
|
apply = 0;
|
||||||
if (check_index && is_not_gitdir)
|
if (check_index && is_not_gitdir)
|
||||||
die("--index outside a repository");
|
die(_("--index outside a repository"));
|
||||||
if (cached) {
|
if (cached) {
|
||||||
if (is_not_gitdir)
|
if (is_not_gitdir)
|
||||||
die("--cached outside a repository");
|
die(_("--cached outside a repository"));
|
||||||
check_index = 1;
|
check_index = 1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
@ -3943,7 +3951,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
|
|||||||
|
|
||||||
fd = open(arg, O_RDONLY);
|
fd = open(arg, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
die_errno("can't open patch '%s'", arg);
|
die_errno(_("can't open patch '%s'"), arg);
|
||||||
read_stdin = 0;
|
read_stdin = 0;
|
||||||
set_default_whitespace_mode(whitespace_option);
|
set_default_whitespace_mode(whitespace_option);
|
||||||
errs |= apply_patch(fd, arg, options);
|
errs |= apply_patch(fd, arg, options);
|
||||||
@ -3957,32 +3965,32 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
|
|||||||
squelch_whitespace_errors < whitespace_error) {
|
squelch_whitespace_errors < whitespace_error) {
|
||||||
int squelched =
|
int squelched =
|
||||||
whitespace_error - squelch_whitespace_errors;
|
whitespace_error - squelch_whitespace_errors;
|
||||||
warning("squelched %d "
|
warning(Q_("squelched %d whitespace error",
|
||||||
"whitespace error%s",
|
"squelched %d whitespace errors",
|
||||||
squelched,
|
squelched),
|
||||||
squelched == 1 ? "" : "s");
|
squelched);
|
||||||
}
|
}
|
||||||
if (ws_error_action == die_on_ws_error)
|
if (ws_error_action == die_on_ws_error)
|
||||||
die("%d line%s add%s whitespace errors.",
|
die(Q_("%d line adds whitespace errors.",
|
||||||
whitespace_error,
|
"%d lines add whitespace errors.",
|
||||||
whitespace_error == 1 ? "" : "s",
|
whitespace_error),
|
||||||
whitespace_error == 1 ? "s" : "");
|
whitespace_error);
|
||||||
if (applied_after_fixing_ws && apply)
|
if (applied_after_fixing_ws && apply)
|
||||||
warning("%d line%s applied after"
|
warning("%d line%s applied after"
|
||||||
" fixing whitespace errors.",
|
" fixing whitespace errors.",
|
||||||
applied_after_fixing_ws,
|
applied_after_fixing_ws,
|
||||||
applied_after_fixing_ws == 1 ? "" : "s");
|
applied_after_fixing_ws == 1 ? "" : "s");
|
||||||
else if (whitespace_error)
|
else if (whitespace_error)
|
||||||
warning("%d line%s add%s whitespace errors.",
|
warning(Q_("%d line adds whitespace errors.",
|
||||||
whitespace_error,
|
"%d lines add whitespace errors.",
|
||||||
whitespace_error == 1 ? "" : "s",
|
whitespace_error),
|
||||||
whitespace_error == 1 ? "s" : "");
|
whitespace_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_index) {
|
if (update_index) {
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_locked_index(&lock_file))
|
commit_locked_index(&lock_file))
|
||||||
die("Unable to write new index file");
|
die(_("Unable to write new index file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!errs;
|
return !!errs;
|
||||||
|
Loading…
Reference in New Issue
Block a user