@@ -58,40 +58,74 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
5858 int i ;
5959 const char * * msgs = opts -> msgs ;
6060 const char * msg ;
61- const char * cmd2 = strcmp (cmd , "checkout" ) ? cmd : "switch branches" ;
6261
63- if (advice_commit_before_merge )
64- msg = "Your local changes to the following files would be overwritten by %s:\n%%s"
65- "Please, commit your changes or stash them before you can %s." ;
62+ if (!strcmp (cmd , "checkout" ))
63+ msg = advice_commit_before_merge
64+ ? _ ("Your local changes to the following files would be overwritten by checkout:\n%%s"
65+ "Please commit your changes or stash them before you can switch branches." )
66+ : _ ("Your local changes to the following files would be overwritten by checkout:\n%%s" );
67+ else if (!strcmp (cmd , "merge" ))
68+ msg = advice_commit_before_merge
69+ ? _ ("Your local changes to the following files would be overwritten by merge:\n%%s"
70+ "Please commit your changes or stash them before you can merge." )
71+ : _ ("Your local changes to the following files would be overwritten by merge:\n%%s" );
6672 else
67- msg = "Your local changes to the following files would be overwritten by %s:\n%%s" ;
73+ msg = advice_commit_before_merge
74+ ? _ ("Your local changes to the following files would be overwritten by %s:\n%%s"
75+ "Please commit your changes or stash them before you can %s." )
76+ : _ ("Your local changes to the following files would be overwritten by %s:\n%%s" );
6877 msgs [ERROR_WOULD_OVERWRITE ] = msgs [ERROR_NOT_UPTODATE_FILE ] =
69- xstrfmt (msg , cmd , cmd2 );
78+ xstrfmt (msg , cmd , cmd );
7079
7180 msgs [ERROR_NOT_UPTODATE_DIR ] =
72- "Updating the following directories would lose untracked files in it:\n%s" ;
73-
74- if (advice_commit_before_merge )
75- msg = "The following untracked working tree files would be %s by %s:\n%%s"
76- "Please move or remove them before you can %s." ;
81+ _ ("Updating the following directories would lose untracked files in it:\n%s" );
82+
83+ if (!strcmp (cmd , "checkout" ))
84+ msg = advice_commit_before_merge
85+ ? _ ("The following untracked working tree files would be removed by checkout:\n%%s"
86+ "Please move or remove them before you can switch branches." )
87+ : _ ("The following untracked working tree files would be removed by checkout:\n%%s" );
88+ else if (!strcmp (cmd , "merge" ))
89+ msg = advice_commit_before_merge
90+ ? _ ("The following untracked working tree files would be removed by merge:\n%%s"
91+ "Please move or remove them before you can merge." )
92+ : _ ("The following untracked working tree files would be removed by merge:\n%%s" );
7793 else
78- msg = "The following untracked working tree files would be %s by %s:\n%%s" ;
79-
80- msgs [ERROR_WOULD_LOSE_UNTRACKED_REMOVED ] = xstrfmt (msg , "removed" , cmd , cmd2 );
81- msgs [ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN ] = xstrfmt (msg , "overwritten" , cmd , cmd2 );
94+ msg = advice_commit_before_merge
95+ ? _ ("The following untracked working tree files would be removed by %s:\n%%s"
96+ "Please move or remove them before you can %s." )
97+ : _ ("The following untracked working tree files would be removed by %s:\n%%s" );
98+ msgs [ERROR_WOULD_LOSE_UNTRACKED_REMOVED ] = xstrfmt (msg , cmd , cmd );
99+
100+ if (!strcmp (cmd , "checkout" ))
101+ msg = advice_commit_before_merge
102+ ? _ ("The following untracked working tree files would be overwritten by checkout:\n%%s"
103+ "Please move or remove them before you can switch branches." )
104+ : _ ("The following untracked working tree files would be overwritten by checkout:\n%%s" );
105+ else if (!strcmp (cmd , "merge" ))
106+ msg = advice_commit_before_merge
107+ ? _ ("The following untracked working tree files would be overwritten by merge:\n%%s"
108+ "Please move or remove them before you can merge." )
109+ : _ ("The following untracked working tree files would be overwritten by merge:\n%%s" );
110+ else
111+ msg = advice_commit_before_merge
112+ ? _ ("The following untracked working tree files would be overwritten by %s:\n%%s"
113+ "Please move or remove them before you can %s." )
114+ : _ ("The following untracked working tree files would be overwritten by %s:\n%%s" );
115+ msgs [ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN ] = xstrfmt (msg , cmd , cmd );
82116
83117 /*
84118 * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we
85119 * cannot easily display it as a list.
86120 */
87- msgs [ERROR_BIND_OVERLAP ] = "Entry '%s' overlaps with '%s'. Cannot bind." ;
121+ msgs [ERROR_BIND_OVERLAP ] = _ ( "Entry '%s' overlaps with '%s'. Cannot bind." ) ;
88122
89123 msgs [ERROR_SPARSE_NOT_UPTODATE_FILE ] =
90- "Cannot update sparse checkout: the following entries are not up-to-date:\n%s" ;
124+ _ ( "Cannot update sparse checkout: the following entries are not up-to-date:\n%s" ) ;
91125 msgs [ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN ] =
92- "The following Working tree files would be overwritten by sparse checkout update:\n%s" ;
126+ _ ( "The following Working tree files would be overwritten by sparse checkout update:\n%s" ) ;
93127 msgs [ERROR_WOULD_LOSE_ORPHANED_REMOVED ] =
94- "The following Working tree files would be removed by sparse checkout update:\n%s" ;
128+ _ ( "The following Working tree files would be removed by sparse checkout update:\n%s" ) ;
95129
96130 opts -> show_all_errors = 1 ;
97131 /* rejected paths may not have a static buffer */
@@ -168,7 +202,7 @@ static void display_error_msgs(struct unpack_trees_options *o)
168202 string_list_clear (rejects , 0 );
169203 }
170204 if (something_displayed )
171- fprintf (stderr , "Aborting\n" );
205+ fprintf (stderr , _ ( "Aborting\n" ) );
172206}
173207
174208/*
0 commit comments