commands,git: teach NegotiateCapabilities() to to return 'supcaps'

This commit is contained in:
Taylor Blau 2017-08-02 13:20:30 -06:00
parent 330e899466
commit fd73a4dd89
2 changed files with 8 additions and 6 deletions

@ -39,7 +39,9 @@ func filterCommand(cmd *cobra.Command, args []string) {
if err := s.Init(); err != nil {
ExitWithError(err)
}
if err := s.NegotiateCapabilities(); err != nil {
_, err := s.NegotiateCapabilities()
if err != nil {
ExitWithError(err)
}

@ -98,25 +98,25 @@ func (o *FilterProcessScanner) Init() error {
// capabilities given to LFS by the parent, an error will be returned. If there
// was an error reading or writing capabilities between the two, an error will
// be returned.
func (o *FilterProcessScanner) NegotiateCapabilities() error {
func (o *FilterProcessScanner) NegotiateCapabilities() ([]string, error) {
reqCaps := []string{"capability=clean", "capability=smudge"}
supCaps, err := o.pl.readPacketList()
if err != nil {
return fmt.Errorf("reading filter-process capabilities failed with %s", err)
return nil, fmt.Errorf("reading filter-process capabilities failed with %s", err)
}
for _, reqCap := range reqCaps {
if !isStringInSlice(supCaps, reqCap) {
return fmt.Errorf("filter '%s' not supported (your Git supports: %s)", reqCap, supCaps)
return nil, fmt.Errorf("filter '%s' not supported (your Git supports: %s)", reqCap, supCaps)
}
}
err = o.pl.writePacketList(reqCaps)
if err != nil {
return fmt.Errorf("writing filter-process capabilities failed with %s", err)
return nil, fmt.Errorf("writing filter-process capabilities failed with %s", err)
}
return nil
return supCaps, nil
}
// Request represents a single command sent to LFS from the parent Git process.