@@ -345,18 +345,32 @@ int split_ident_line(struct ident_split *split, const char *line, int len)
345
345
return 0 ;
346
346
}
347
347
348
- static const char * env_hint =
349
- N_ ("\n"
350
- "*** Please tell me who you are.\n"
351
- "\n"
352
- "Run\n"
353
- "\n"
354
- " git config --global user.email \"[email protected] \"\n"
355
- " git config --global user.name \"Your Name\"\n"
356
- "\n"
357
- "to set your account\'s default identity.\n"
358
- "Omit --global to set the identity only in this repository.\n"
359
- "\n" );
348
+
349
+ static void ident_env_hint (enum want_ident whose_ident )
350
+ {
351
+ switch (whose_ident ) {
352
+ case WANT_AUTHOR_IDENT :
353
+ fputs (_ ("Author identity unknown\n" ), stderr );
354
+ break ;
355
+ case WANT_COMMITTER_IDENT :
356
+ fputs (_ ("Committer identity unknown\n" ), stderr );
357
+ break ;
358
+ default :
359
+ break ;
360
+ }
361
+
362
+ fputs (_ ("\n"
363
+ "*** Please tell me who you are.\n"
364
+ "\n"
365
+ "Run\n"
366
+ "\n"
367
+ " git config --global user.email \"[email protected] \"\n"
368
+ " git config --global user.name \"Your Name\"\n"
369
+ "\n"
370
+ "to set your account\'s default identity.\n"
371
+ "Omit --global to set the identity only in this repository.\n"
372
+ "\n" ), stderr );
373
+ }
360
374
361
375
const char * fmt_ident (const char * name , const char * email ,
362
376
enum want_ident whose_ident , const char * date_str , int flag )
@@ -375,12 +389,12 @@ const char *fmt_ident(const char *name, const char *email,
375
389
if (!email ) {
376
390
if (strict && ident_use_config_only
377
391
&& !(ident_config_given & IDENT_MAIL_GIVEN )) {
378
- fputs ( _ ( env_hint ), stderr );
392
+ ident_env_hint ( whose_ident );
379
393
die (_ ("no email was given and auto-detection is disabled" ));
380
394
}
381
395
email = ident_default_email ();
382
396
if (strict && default_email_is_bogus ) {
383
- fputs ( _ ( env_hint ), stderr );
397
+ ident_env_hint ( whose_ident );
384
398
die (_ ("unable to auto-detect email address (got '%s')" ), email );
385
399
}
386
400
}
@@ -397,21 +411,21 @@ const char *fmt_ident(const char *name, const char *email,
397
411
if (!name ) {
398
412
if (strict && ident_use_config_only
399
413
&& !(ident_config_given & IDENT_NAME_GIVEN )) {
400
- fputs ( _ ( env_hint ), stderr );
414
+ ident_env_hint ( whose_ident );
401
415
die (_ ("no name was given and auto-detection is disabled" ));
402
416
}
403
417
name = ident_default_name ();
404
418
using_default = 1 ;
405
419
if (strict && default_name_is_bogus ) {
406
- fputs ( _ ( env_hint ), stderr );
420
+ ident_env_hint ( whose_ident );
407
421
die (_ ("unable to auto-detect name (got '%s')" ), name );
408
422
}
409
423
}
410
424
if (!* name ) {
411
425
struct passwd * pw ;
412
426
if (strict ) {
413
427
if (using_default )
414
- fputs ( _ ( env_hint ), stderr );
428
+ ident_env_hint ( whose_ident );
415
429
die (_ ("empty ident name (for <%s>) not allowed" ), email );
416
430
}
417
431
pw = xgetpwuid_self (NULL );
0 commit comments