git_xmerge_config(): prefer error() to die()
When parsing merge config, a few code paths die on error. It's preferable for us to call error() here, because the resulting error message from the config parsing code contains much more detail. For example, before: fatal: unknown style 'bogus' given for 'merge.conflictstyle' and after: error: unknown style 'bogus' given for 'merge.conflictstyle' fatal: bad config variable 'merge.conflictstyle' in file '.git/config' at line 7 Since we're touching these lines, I also marked them for translation. There's no reason they shouldn't behave like most other config-parsing errors. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Dec 7, 2023 at 02:24 UTC
22e27413eee9ff3bcbd3c7e8f3a8d1a40650e1b2
1 file changed
+4
-3
xdiff-interface.c
+4
-3
@@ -1,4 +1,5 @@
1
#include "git-compat-util.h"
2
+#include "gettext.h"
3
#include "config.h"
4
#include "hex.h"
5
#include "object-store-ll.h"
@@ -313,7 +314,7 @@ int git_xmerge_config(const char *var, const char *value,
314
{
315
if (!strcmp(var, "merge.conflictstyle")) {
316
if (!value)
316
- die("'%s' is not a boolean", var);
317
+ return error(_("'%s' is not a boolean"), var);
318
if (!strcmp(value, "diff3"))
319
git_xmerge_style = XDL_MERGE_DIFF3;
320
else if (!strcmp(value, "zdiff3"))
@@ -325,8 +326,8 @@ int git_xmerge_config(const char *var, const char *value,
326
* git-completion.bash when you add new merge config
327
*/
328
else
328
- die("unknown style '%s' given for '%s'",
329
- value, var);
329
+ return error(_("unknown style '%s' given for '%s'"),
330
+ value, var);
331
return 0;
332
}
333
return git_default_config(var, value, ctx, cb);