@@ -360,7 +360,27 @@ func SetGitUser(name, email string) error {
360
360
return ConfigSet ("user.email" , email )
361
361
}
362
362
363
- // ConfigGet returns the value of a given git configuration key.
363
+ // ConfigGetLocal returns the value of a given git configuration key
364
+ // using the local git configuration only.
365
+ // The returned key is always a string.
366
+ // (git config --local --get)
367
+ func ConfigGetLocal (key string ) (string , error ) {
368
+ fn := fmt .Sprintf ("ConfigGet(%s)" , key )
369
+ cmd := Command ("config" , "--local" , "--get" , key )
370
+ stdout , stderr , err := cmd .OutputError ()
371
+ if err != nil {
372
+ gerr := giterror {UError : string (stderr ), Origin : fn }
373
+ log .Write ("Error during config get" )
374
+ logstd (stdout , stderr )
375
+ return "" , gerr
376
+ }
377
+ value := string (stdout )
378
+ value = strings .TrimSpace (value )
379
+ return value , nil
380
+ }
381
+
382
+ // ConfigGet returns the value of a given git configuration key
383
+ // using the default git configuration.
364
384
// The returned key is always a string.
365
385
// (git config --get)
366
386
func ConfigGet (key string ) (string , error ) {
@@ -544,7 +564,7 @@ func Checkwd() error {
544
564
return NotRepository
545
565
}
546
566
547
- annexver , err := ConfigGet ("annex.version" )
567
+ annexver , err := ConfigGetLocal ("annex.version" )
548
568
if err != nil {
549
569
// Annex version config key missing: Annex not initialised
550
570
return NotAnnex
0 commit comments