use git rev-list --stdin
instead of passing each remote ref
This commit is contained in:
parent
7b8cdca7c7
commit
d2d650fde1
@ -267,7 +267,7 @@ func ScanIndex() ([]*WrappedPointer, error) {
|
|||||||
|
|
||||||
// Get additional arguments needed to limit 'git rev-list' to just the changes in revTo
|
// Get additional arguments needed to limit 'git rev-list' to just the changes in revTo
|
||||||
// that are also not on remoteName.
|
// that are also not on remoteName.
|
||||||
func revListArgsRefVsRemote(refTo, remoteName string) []string {
|
func revListArgsRefVsRemote(refTo, remoteName string) ([]string, bool) {
|
||||||
// We need to check that the locally cached versions of remote refs are still
|
// We need to check that the locally cached versions of remote refs are still
|
||||||
// present on the remote before we use them as a 'from' point. If the
|
// present on the remote before we use them as a 'from' point. If the
|
||||||
// server implements garbage collection and a remote branch had been deleted
|
// server implements garbage collection and a remote branch had been deleted
|
||||||
@ -297,18 +297,18 @@ func revListArgsRefVsRemote(refTo, remoteName string) []string {
|
|||||||
|
|
||||||
if len(missingRefs) > 0 {
|
if len(missingRefs) > 0 {
|
||||||
// Use only the non-missing refs as 'from' points
|
// Use only the non-missing refs as 'from' points
|
||||||
ret := []string{refTo, "--not"}
|
commits := make([]string, 1, len(cachedRemoteRefs) + 1)
|
||||||
|
commits[0] = refTo
|
||||||
for _, cachedRef := range cachedRemoteRefs {
|
for _, cachedRef := range cachedRemoteRefs {
|
||||||
if !missingRefs.Contains(cachedRef.Name) {
|
if !missingRefs.Contains(cachedRef.Name) {
|
||||||
ret = append(ret, fmt.Sprintf("refs/remotes/%v/%v", remoteName, cachedRef.Name))
|
commits = append(commits, "^"+cachedRef.Sha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return commits
|
||||||
} else {
|
} else {
|
||||||
// Safe to use cached
|
// Safe to use cached
|
||||||
return []string{refTo, "--not", "--remotes=" + remoteName}
|
return []string{refTo, "--not", "--remotes=" + remoteName}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// revListShas uses git rev-list to return the list of object sha1s
|
// revListShas uses git rev-list to return the list of object sha1s
|
||||||
@ -316,6 +316,7 @@ func revListArgsRefVsRemote(refTo, remoteName string) []string {
|
|||||||
// channel from which sha1 strings can be read.
|
// channel from which sha1 strings can be read.
|
||||||
func revListShas(refLeft, refRight string, opt *ScanRefsOptions) (*StringChannelWrapper, error) {
|
func revListShas(refLeft, refRight string, opt *ScanRefsOptions) (*StringChannelWrapper, error) {
|
||||||
refArgs := []string{"rev-list", "--objects"}
|
refArgs := []string{"rev-list", "--objects"}
|
||||||
|
var stdin []string
|
||||||
switch opt.ScanMode {
|
switch opt.ScanMode {
|
||||||
case ScanRefsMode:
|
case ScanRefsMode:
|
||||||
if opt.SkipDeletedBlobs {
|
if opt.SkipDeletedBlobs {
|
||||||
@ -331,7 +332,12 @@ func revListShas(refLeft, refRight string, opt *ScanRefsOptions) (*StringChannel
|
|||||||
case ScanAllMode:
|
case ScanAllMode:
|
||||||
refArgs = append(refArgs, "--all")
|
refArgs = append(refArgs, "--all")
|
||||||
case ScanLeftToRemoteMode:
|
case ScanLeftToRemoteMode:
|
||||||
refArgs = append(refArgs, revListArgsRefVsRemote(refLeft, opt.RemoteName)...)
|
commits, useStdin := revListArgsRefVsRemote(refLeft, opt.RemoteName)
|
||||||
|
if !useStdin {
|
||||||
|
refArgs = append(refArgs, commits...)
|
||||||
|
} else {
|
||||||
|
stdin = commits
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("scanner: unknown scan type: " + strconv.Itoa(int(opt.ScanMode)))
|
return nil, errors.New("scanner: unknown scan type: " + strconv.Itoa(int(opt.ScanMode)))
|
||||||
}
|
}
|
||||||
@ -346,6 +352,10 @@ func revListShas(refLeft, refRight string, opt *ScanRefsOptions) (*StringChannel
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(stdin) > 0 {
|
||||||
|
cmd.Stdin.Write([]byte(strings.Join(stdin, "\n")))
|
||||||
|
}
|
||||||
|
|
||||||
cmd.Stdin.Close()
|
cmd.Stdin.Close()
|
||||||
|
|
||||||
revs := make(chan string, chanBufSize)
|
revs := make(chan string, chanBufSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user