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

Commit 989f869

Browse files
committed
Merge branch 'nd/i18n-apply-lego'
By Nguyễn Thái Ngọc Duy * nd/i18n-apply-lego: apply: remove lego in i18n string in gitdiff_verify_name
2 parents f7858ad + 4c5197d commit 989f869

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

builtin/apply.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,10 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
919919
* their names against any previous information, just
920920
* to make sure..
921921
*/
922-
static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
922+
#define DIFF_OLD_NAME 0
923+
#define DIFF_NEW_NAME 1
924+
925+
static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, int side)
923926
{
924927
if (!orig_name && !isnull)
925928
return find_name(line, NULL, p_value, TERM_TAB);
@@ -934,7 +937,9 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
934937
die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), name, linenr);
935938
another = find_name(line, NULL, p_value, TERM_TAB);
936939
if (!another || memcmp(another, name, len + 1))
937-
die(_("git apply: bad git-diff - inconsistent %s filename on line %d"), oldnew, linenr);
940+
die((side == DIFF_NEW_NAME) ?
941+
_("git apply: bad git-diff - inconsistent new filename on line %d") :
942+
_("git apply: bad git-diff - inconsistent old filename on line %d"), linenr);
938943
free(another);
939944
return orig_name;
940945
}
@@ -949,7 +954,8 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
949954
static int gitdiff_oldname(const char *line, struct patch *patch)
950955
{
951956
char *orig = patch->old_name;
952-
patch->old_name = gitdiff_verify_name(line, patch->is_new, patch->old_name, "old");
957+
patch->old_name = gitdiff_verify_name(line, patch->is_new, patch->old_name,
958+
DIFF_OLD_NAME);
953959
if (orig != patch->old_name)
954960
free(orig);
955961
return 0;
@@ -958,7 +964,8 @@ static int gitdiff_oldname(const char *line, struct patch *patch)
958964
static int gitdiff_newname(const char *line, struct patch *patch)
959965
{
960966
char *orig = patch->new_name;
961-
patch->new_name = gitdiff_verify_name(line, patch->is_delete, patch->new_name, "new");
967+
patch->new_name = gitdiff_verify_name(line, patch->is_delete, patch->new_name,
968+
DIFF_NEW_NAME);
962969
if (orig != patch->new_name)
963970
free(orig);
964971
return 0;

0 commit comments

Comments
 (0)