Re: credential-store get: No such file or directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 2, 2021 at 7:27 PM Steven Penny wrote:
> fatal: cannot run git credential-store get: No such file or directory

I came up with a workaround. I wrote my own AskPass program using Go language.
Here it is:

package main

import (
   "bytes"
   "fmt"
   "net/url"
   "os"
)

func main() {
   cache, err := os.UserCacheDir()
   if err != nil {
      panic(err)
   }
   buf, err := os.ReadFile(cache + "/git/credentials")
   if err != nil {
      panic(err)
   }
   buf = bytes.TrimSpace(buf)
   addr, err := url.Parse(string(buf))
   if err != nil {
      panic(err)
   }
   if len(os.Args) != 2 {
      return
   }
   prompt := os.Args[1]
   if len(prompt) < 8 {
      return
   }
   switch prompt[:8] {
   case "Username":
      fmt.Fprintln(os.Stderr, "Username")
      fmt.Println(addr.User.Username())
   case "Password":
      fmt.Fprintln(os.Stderr, "Password")
      pass, ok := addr.User.Password()
      if ok {
         fmt.Println(pass)
      }
   }
}



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux