apply: remove lego in i18n string in gitdiff_verify_name
It marks the string "...inconsistent %s filename..." where %s is either "old" or "new" from caller. Make it two strings "...inconsistent new filename..." and "...inconsistent old filename...". Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 6, 2012 at 20:13 UTC
4c5197d10f01f1dce817af05fd0837bce84708b7
1 file changed
+11
-4
builtin/apply.c
+11
-4
@@ -919,7 +919,10 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
919
* their names against any previous information, just
920
* to make sure..
921
*/
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)
926
{
927
if (!orig_name && !isnull)
928
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,
937
die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), name, linenr);
938
another = find_name(line, NULL, p_value, TERM_TAB);
939
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);
943
free(another);
944
return orig_name;
945
}
@@ -949,7 +954,8 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
954
static int gitdiff_oldname(const char *line, struct patch *patch)
955
{
956
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);
959
if (orig != patch->old_name)
960
free(orig);
961
return 0;
@@ -958,7 +964,8 @@ static int gitdiff_oldname(const char *line, struct patch *patch)
964
static int gitdiff_newname(const char *line, struct patch *patch)
965
{
966
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);
969
if (orig != patch->new_name)
970
free(orig);
971
return 0;