@@ -53,10 +53,15 @@ pub fn main() -> Result<()> {
53
53
let object_hash = args. object_hash ;
54
54
use git_repository as git;
55
55
let repository = args. repository ;
56
- let repository = move || {
56
+ enum Mode {
57
+ Strict ,
58
+ Lenient ,
59
+ }
60
+ let repository = move |mode : Mode | {
57
61
let mut mapping: git:: sec:: trust:: Mapping < git:: open:: Options > = Default :: default ( ) ;
58
- mapping. full = mapping. full . strict_config ( true ) ;
59
- mapping. reduced = mapping. reduced . strict_config ( true ) ;
62
+ let toggle = matches ! ( mode, Mode :: Strict ) ;
63
+ mapping. full = mapping. full . strict_config ( toggle) ;
64
+ mapping. reduced = mapping. reduced . strict_config ( toggle) ;
60
65
git:: ThreadSafeRepository :: discover_opts ( repository, Default :: default ( ) , mapping)
61
66
. map ( git:: Repository :: from)
62
67
. map ( |r| r. apply_environment ( ) )
@@ -88,7 +93,7 @@ pub fn main() -> Result<()> {
88
93
progress,
89
94
progress_keep_open,
90
95
None ,
91
- move |_progress, out, _err| core:: repository:: config:: list ( repository ( ) ?, filter, format, out) ,
96
+ move |_progress, out, _err| core:: repository:: config:: list ( repository ( Mode :: Lenient ) ?, filter, format, out) ,
92
97
)
93
98
. map ( |_| ( ) ) ,
94
99
Subcommands :: Free ( subcommands) => match subcommands {
@@ -505,7 +510,7 @@ pub fn main() -> Result<()> {
505
510
core:: repository:: verify:: PROGRESS_RANGE ,
506
511
move |progress, out, _err| {
507
512
core:: repository:: verify:: integrity (
508
- repository ( ) ?,
513
+ repository ( Mode :: Strict ) ?,
509
514
out,
510
515
progress,
511
516
& should_interrupt,
@@ -525,7 +530,9 @@ pub fn main() -> Result<()> {
525
530
progress,
526
531
progress_keep_open,
527
532
None ,
528
- move |_progress, out, _err| core:: repository:: revision:: previous_branches ( repository ( ) ?, out, format) ,
533
+ move |_progress, out, _err| {
534
+ core:: repository:: revision:: previous_branches ( repository ( Mode :: Lenient ) ?, out, format)
535
+ } ,
529
536
) ,
530
537
revision:: Subcommands :: Explain { spec } => prepare_and_run (
531
538
"revision-explain" ,
@@ -547,7 +554,7 @@ pub fn main() -> Result<()> {
547
554
None ,
548
555
move |_progress, out, _err| {
549
556
core:: repository:: revision:: resolve (
550
- repository ( ) ?,
557
+ repository ( Mode :: Strict ) ?,
551
558
specs,
552
559
out,
553
560
core:: repository:: revision:: resolve:: Options {
@@ -577,7 +584,7 @@ pub fn main() -> Result<()> {
577
584
None ,
578
585
move |_progress, out, err| {
579
586
core:: repository:: commit:: describe (
580
- repository ( ) ?,
587
+ repository ( Mode :: Strict ) ?,
581
588
rev_spec. as_deref ( ) ,
582
589
out,
583
590
err,
@@ -606,7 +613,14 @@ pub fn main() -> Result<()> {
606
613
progress_keep_open,
607
614
None ,
608
615
move |_progress, out, _err| {
609
- core:: repository:: tree:: entries ( repository ( ) ?, treeish. as_deref ( ) , recursive, extended, format, out)
616
+ core:: repository:: tree:: entries (
617
+ repository ( Mode :: Strict ) ?,
618
+ treeish. as_deref ( ) ,
619
+ recursive,
620
+ extended,
621
+ format,
622
+ out,
623
+ )
610
624
} ,
611
625
) ,
612
626
tree:: Subcommands :: Info { treeish, extended } => prepare_and_run (
@@ -616,7 +630,14 @@ pub fn main() -> Result<()> {
616
630
progress_keep_open,
617
631
None ,
618
632
move |_progress, out, err| {
619
- core:: repository:: tree:: info ( repository ( ) ?, treeish. as_deref ( ) , extended, format, out, err)
633
+ core:: repository:: tree:: info (
634
+ repository ( Mode :: Strict ) ?,
635
+ treeish. as_deref ( ) ,
636
+ extended,
637
+ format,
638
+ out,
639
+ err,
640
+ )
620
641
} ,
621
642
) ,
622
643
} ,
@@ -627,15 +648,15 @@ pub fn main() -> Result<()> {
627
648
progress,
628
649
progress_keep_open,
629
650
None ,
630
- move |_progress, out, _err| core:: repository:: odb:: entries ( repository ( ) ?, format, out) ,
651
+ move |_progress, out, _err| core:: repository:: odb:: entries ( repository ( Mode :: Strict ) ?, format, out) ,
631
652
) ,
632
653
odb:: Subcommands :: Info => prepare_and_run (
633
654
"odb-info" ,
634
655
verbose,
635
656
progress,
636
657
progress_keep_open,
637
658
None ,
638
- move |_progress, out, err| core:: repository:: odb:: info ( repository ( ) ?, format, out, err) ,
659
+ move |_progress, out, err| core:: repository:: odb:: info ( repository ( Mode :: Strict ) ?, format, out, err) ,
639
660
) ,
640
661
} ,
641
662
Subcommands :: Mailmap ( cmd) => match cmd {
@@ -645,7 +666,9 @@ pub fn main() -> Result<()> {
645
666
progress,
646
667
progress_keep_open,
647
668
None ,
648
- move |_progress, out, err| core:: repository:: mailmap:: entries ( repository ( ) ?, format, out, err) ,
669
+ move |_progress, out, err| {
670
+ core:: repository:: mailmap:: entries ( repository ( Mode :: Lenient ) ?, format, out, err)
671
+ } ,
649
672
) ,
650
673
} ,
651
674
Subcommands :: Exclude ( cmd) => match cmd {
@@ -662,7 +685,7 @@ pub fn main() -> Result<()> {
662
685
move |_progress, out, _err| {
663
686
use git:: bstr:: ByteSlice ;
664
687
core:: repository:: exclude:: query (
665
- repository ( ) ?,
688
+ repository ( Mode :: Strict ) ?,
666
689
if pathspecs. is_empty ( ) {
667
690
Box :: new (
668
691
stdin_or_bail ( ) ?
0 commit comments