@@ -596,6 +596,24 @@ static int get_scalar_repos(const char *key, const char *value, void *data)
596
596
return 0 ;
597
597
}
598
598
599
+ static int remove_deleted_enlistment (struct strbuf * path )
600
+ {
601
+ int res = 0 ;
602
+ strbuf_realpath_forgiving (path , path -> buf , 1 );
603
+
604
+ if (run_git ("config" , "--global" ,
605
+ "--unset" , "--fixed-value" ,
606
+ "scalar.repo" , path -> buf , NULL ) < 0 )
607
+ res = -1 ;
608
+
609
+ if (run_git ("config" , "--global" ,
610
+ "--unset" , "--fixed-value" ,
611
+ "maintenance.repo" , path -> buf , NULL ) < 0 )
612
+ res = -1 ;
613
+
614
+ return res ;
615
+ }
616
+
599
617
static int cmd_reconfigure (int argc , const char * * argv )
600
618
{
601
619
int all = 0 ;
@@ -635,8 +653,22 @@ static int cmd_reconfigure(int argc, const char **argv)
635
653
strbuf_reset (& gitdir );
636
654
637
655
if (chdir (dir ) < 0 ) {
638
- warning_errno (_ ("could not switch to '%s'" ), dir );
639
- res = -1 ;
656
+ struct strbuf buf = STRBUF_INIT ;
657
+
658
+ if (errno != ENOENT ) {
659
+ warning_errno (_ ("could not switch to '%s'" ), dir );
660
+ res = -1 ;
661
+ continue ;
662
+ }
663
+
664
+ strbuf_addstr (& buf , dir );
665
+ if (remove_deleted_enlistment (& buf ))
666
+ res = error (_ ("could not remove stale "
667
+ "scalar.repo '%s'" ), dir );
668
+ else
669
+ warning (_ ("removing stale scalar.repo '%s'" ),
670
+ dir );
671
+ strbuf_release (& buf );
640
672
} else if (discover_git_directory (& commondir , & gitdir ) < 0 ) {
641
673
warning_errno (_ ("git repository gone in '%s'" ), dir );
642
674
res = -1 ;
@@ -722,24 +754,6 @@ static int cmd_run(int argc, const char **argv)
722
754
return 0 ;
723
755
}
724
756
725
- static int remove_deleted_enlistment (struct strbuf * path )
726
- {
727
- int res = 0 ;
728
- strbuf_realpath_forgiving (path , path -> buf , 1 );
729
-
730
- if (run_git ("config" , "--global" ,
731
- "--unset" , "--fixed-value" ,
732
- "scalar.repo" , path -> buf , NULL ) < 0 )
733
- res = -1 ;
734
-
735
- if (run_git ("config" , "--global" ,
736
- "--unset" , "--fixed-value" ,
737
- "maintenance.repo" , path -> buf , NULL ) < 0 )
738
- res = -1 ;
739
-
740
- return res ;
741
- }
742
-
743
757
static int cmd_unregister (int argc , const char * * argv )
744
758
{
745
759
struct option options [] = {
0 commit comments