@@ -131,7 +131,7 @@ func main() {
131131 if err == nil {
132132 os .Exit (code )
133133 }
134- fmt .Fprintf (os .Stderr , "ERROR : unhandled pid1 error: %v\n " , err )
134+ fmt .Fprintf (os .Stderr , "FATAL : unhandled pid1 error: %v\n " , err )
135135 os .Exit (127 )
136136 }
137137
@@ -352,7 +352,7 @@ func main() {
352352 }
353353 var absRoot absPath
354354 if abs , err := absPath (* flRoot ).Canonical (); err != nil {
355- fmt .Fprintf (os .Stderr , "ERROR : can't absolutize --root: %v\n " , err )
355+ fmt .Fprintf (os .Stderr , "FATAL : can't absolutize --root: %v\n " , err )
356356 os .Exit (1 )
357357 } else {
358358 absRoot = abs
@@ -370,40 +370,40 @@ func main() {
370370 cmdRunner := cmd .NewRunner (log )
371371
372372 if * flRepo == "" {
373- handleConfigError (log , true , "ERROR : --repo must be specified" )
373+ fatalConfigError (log , true , "required flag : --repo must be specified" )
374374 }
375375
376376 switch {
377377 case * flDeprecatedBranch != "" && (* flDeprecatedRev == "" || * flDeprecatedRev == "HEAD" ):
378378 // Back-compat
379379 log .V (0 ).Info ("setting --ref from deprecated --branch" )
380380 * flRef = * flDeprecatedBranch
381- case * flDeprecatedRev != "" :
381+ case * flDeprecatedRev != "" && * flDeprecatedBranch == "" :
382382 // Back-compat
383383 log .V (0 ).Info ("setting --ref from deprecated --rev" )
384384 * flRef = * flDeprecatedRev
385385 case * flDeprecatedBranch != "" && * flDeprecatedRev != "" :
386- handleConfigError (log , true , "ERROR : can't set --ref from deprecated --branch and --rev" )
386+ fatalConfigError (log , true , "deprecated flag combo : can't set --ref from deprecated --branch and --rev (one or the other is OK) " )
387387 }
388388
389389 if * flRef == "" {
390- handleConfigError (log , true , "ERROR : --ref must be specified" )
390+ fatalConfigError (log , true , "required flag : --ref must be specified" )
391391 }
392392
393393 if * flDepth < 0 { // 0 means "no limit"
394- handleConfigError (log , true , "ERROR : --depth must be greater than or equal to 0" )
394+ fatalConfigError (log , true , "invalid flag : --depth must be greater than or equal to 0" )
395395 }
396396
397397 switch submodulesMode (* flSubmodules ) {
398398 case submodulesRecursive , submodulesShallow , submodulesOff :
399399 default :
400- handleConfigError (log , true , "ERROR : --submodules must be one of %q, %q, or %q" , submodulesRecursive , submodulesShallow , submodulesOff )
400+ fatalConfigError (log , true , "invalid flag : --submodules must be one of %q, %q, or %q" , submodulesRecursive , submodulesShallow , submodulesOff )
401401 }
402402
403403 switch * flGitGC {
404404 case gcAuto , gcAlways , gcAggressive , gcOff :
405405 default :
406- handleConfigError (log , true , "ERROR : --git-gc must be one of %q, %q, %q, or %q" , gcAuto , gcAlways , gcAggressive , gcOff )
406+ fatalConfigError (log , true , "invalid flag : --git-gc must be one of %q, %q, %q, or %q" , gcAuto , gcAlways , gcAggressive , gcOff )
407407 }
408408
409409 if * flDeprecatedDest != "" {
@@ -422,11 +422,11 @@ func main() {
422422 * flPeriod = time .Duration (int (* flDeprecatedWait * 1000 )) * time .Millisecond
423423 }
424424 if * flPeriod < 10 * time .Millisecond {
425- handleConfigError (log , true , "ERROR : --period must be at least 10ms" )
425+ fatalConfigError (log , true , "invalid flag : --period must be at least 10ms" )
426426 }
427427
428428 if * flDeprecatedChmod != 0 {
429- handleConfigError (log , true , "ERROR : --change-permissions is no longer supported" )
429+ fatalConfigError (log , true , "deprecated flag : --change-permissions is no longer supported" )
430430 }
431431
432432 var syncSig syscall.Signal
@@ -443,7 +443,7 @@ func main() {
443443 }
444444 }
445445 if syncSig == 0 {
446- handleConfigError (log , true , "ERROR : --sync-on-signal must be a valid signal name or number" )
446+ fatalConfigError (log , true , "invalid flag : --sync-on-signal must be a valid signal name or number" )
447447 }
448448 }
449449
@@ -453,7 +453,7 @@ func main() {
453453 * flSyncTimeout = time .Duration (* flDeprecatedTimeout ) * time .Second
454454 }
455455 if * flSyncTimeout < 10 * time .Millisecond {
456- handleConfigError (log , true , "ERROR : --sync-timeout must be at least 10ms" )
456+ fatalConfigError (log , true , "invalid flag : --sync-timeout must be at least 10ms" )
457457 }
458458
459459 if * flDeprecatedMaxSyncFailures != 0 {
@@ -469,10 +469,10 @@ func main() {
469469 }
470470 if * flExechookCommand != "" {
471471 if * flExechookTimeout < time .Second {
472- handleConfigError (log , true , "ERROR : --exechook-timeout must be at least 1s" )
472+ fatalConfigError (log , true , "invalid flag : --exechook-timeout must be at least 1s" )
473473 }
474474 if * flExechookBackoff < time .Second {
475- handleConfigError (log , true , "ERROR : --exechook-backoff must be at least 1s" )
475+ fatalConfigError (log , true , "invalid flag : --exechook-backoff must be at least 1s" )
476476 }
477477 }
478478
@@ -482,60 +482,60 @@ func main() {
482482 * flWebhookStatusSuccess = 0
483483 }
484484 if * flWebhookStatusSuccess < 0 {
485- handleConfigError (log , true , "ERROR : --webhook-success-status must be a valid HTTP code or 0" )
485+ fatalConfigError (log , true , "invalid flag : --webhook-success-status must be a valid HTTP code or 0" )
486486 }
487487 if * flWebhookTimeout < time .Second {
488- handleConfigError (log , true , "ERROR : --webhook-timeout must be at least 1s" )
488+ fatalConfigError (log , true , "invalid flag : --webhook-timeout must be at least 1s" )
489489 }
490490 if * flWebhookBackoff < time .Second {
491- handleConfigError (log , true , "ERROR : --webhook-backoff must be at least 1s" )
491+ fatalConfigError (log , true , "invalid flag : --webhook-backoff must be at least 1s" )
492492 }
493493 }
494494
495495 if * flUsername != "" {
496496 if * flPassword == "" && * flPasswordFile == "" {
497- handleConfigError (log , true , "ERROR : --password or --password-file must be specified when --username is specified" )
497+ fatalConfigError (log , true , "required flag : --password or --password-file must be specified when --username is specified" )
498498 }
499499 if * flPassword != "" && * flPasswordFile != "" {
500- handleConfigError (log , true , "ERROR : only one of --password and --password-file may be specified" )
500+ fatalConfigError (log , true , "invalid flag : only one of --password and --password-file may be specified" )
501501 }
502502 if u , err := url .Parse (* flRepo ); err == nil { // it may not even parse as a URL, that's OK
503503 if u .User != nil {
504- handleConfigError (log , true , "ERROR : credentials may not be specified in --repo when --username is specified" )
504+ fatalConfigError (log , true , "invalid flag : credentials may not be specified in --repo when --username is specified" )
505505 }
506506 }
507507 } else {
508508 if * flPassword != "" {
509- handleConfigError (log , true , "ERROR : --password may only be specified when --username is specified" )
509+ fatalConfigError (log , true , "invalid flag : --password may only be specified when --username is specified" )
510510 }
511511 if * flPasswordFile != "" {
512- handleConfigError (log , true , "ERROR : --password-file may only be specified when --username is specified" )
512+ fatalConfigError (log , true , "invalid flag : --password-file may only be specified when --username is specified" )
513513 }
514514 }
515515
516516 if len (* flCredentials ) > 0 {
517517 for _ , cred := range * flCredentials {
518518 if cred .URL == "" {
519- handleConfigError (log , true , "ERROR : --credential URL must be specified" )
519+ fatalConfigError (log , true , "invalid flag : --credential URL must be specified" )
520520 }
521521 if cred .Username == "" {
522- handleConfigError (log , true , "ERROR : --credential username must be specified" )
522+ fatalConfigError (log , true , "invalid flag : --credential username must be specified" )
523523 }
524524 if cred .Password == "" && cred .PasswordFile == "" {
525- handleConfigError (log , true , "ERROR : --credential password or password-file must be set " )
525+ fatalConfigError (log , true , "invalid flag : --credential password or password-file must be specified " )
526526 }
527527 if cred .Password != "" && cred .PasswordFile != "" {
528- handleConfigError (log , true , "ERROR : only one of --credential password and password-file may be specified" )
528+ fatalConfigError (log , true , "invalid flag : only one of --credential password and password-file may be specified" )
529529 }
530530 }
531531 }
532532
533533 if * flHTTPBind == "" {
534534 if * flHTTPMetrics {
535- handleConfigError (log , true , "ERROR : --http-bind must be specified when --http-metrics is set" )
535+ fatalConfigError (log , true , "required flag : --http-bind must be specified when --http-metrics is set" )
536536 }
537537 if * flHTTPprof {
538- handleConfigError (log , true , "ERROR : --http-bind must be specified when --http-pprof is set" )
538+ fatalConfigError (log , true , "required flag : --http-bind must be specified when --http-pprof is set" )
539539 }
540540 }
541541
@@ -552,7 +552,7 @@ func main() {
552552 "flags" , logSafeFlags (* flVerbose ))
553553
554554 if _ , err := exec .LookPath (* flGitCmd ); err != nil {
555- log .Error (err , "ERROR : git executable not found" , "git" , * flGitCmd )
555+ log .Error (err , "FATAL : git executable not found" , "git" , * flGitCmd )
556556 os .Exit (1 )
557557 }
558558
@@ -568,13 +568,13 @@ func main() {
568568 // very early so that we can normalize the path even when there are
569569 // symlinks in play.
570570 if err := os .MkdirAll (absRoot .String (), defaultDirMode ); err != nil {
571- log .Error (err , "ERROR : can't make root dir" , "path" , absRoot )
571+ log .Error (err , "FATAL : can't make root dir" , "path" , absRoot )
572572 os .Exit (1 )
573573 }
574574 // Get rid of symlinks in the root path to avoid getting confused about
575575 // them later. The path must exist for EvalSymlinks to work.
576576 if delinked , err := filepath .EvalSymlinks (absRoot .String ()); err != nil {
577- log .Error (err , "ERROR : can't normalize root path" , "path" , absRoot )
577+ log .Error (err , "FATAL : can't normalize root path" , "path" , absRoot )
578578 os .Exit (1 )
579579 } else {
580580 absRoot = absPath (delinked )
@@ -617,7 +617,7 @@ func main() {
617617
618618 if * flAddUser {
619619 if err := addUser (); err != nil {
620- log .Error (err , "ERROR : can't add user" )
620+ log .Error (err , "FATAL : can't add user" )
621621 os .Exit (1 )
622622 }
623623 }
@@ -653,7 +653,7 @@ func main() {
653653
654654 // Don't pollute the user's .gitconfig if this is being run directly.
655655 if f , err := os .CreateTemp ("" , "git-sync.gitconfig.*" ); err != nil {
656- log .Error (err , "ERROR : can't create gitconfig file" )
656+ log .Error (err , "FATAL : can't create gitconfig file" )
657657 os .Exit (1 )
658658 } else {
659659 gitConfig := f .Name ()
@@ -1062,10 +1062,10 @@ func sleepForever() {
10621062 os .Exit (0 )
10631063}
10641064
1065- // handleConfigError prints the error to the standard error, prints the usage
1065+ // fatalConfigError prints the error to the standard error, prints the usage
10661066// if the `printUsage` flag is true, exports the error to the error file and
10671067// exits the process with the exit code.
1068- func handleConfigError (log * logging.Logger , printUsage bool , format string , a ... interface {}) {
1068+ func fatalConfigError (log * logging.Logger , printUsage bool , format string , a ... interface {}) {
10691069 s := fmt .Sprintf (format , a ... )
10701070 fmt .Fprintln (os .Stderr , s )
10711071 if printUsage {
0 commit comments