Merge pull request #4017 from shalashik/cherry-pick-panic
commands/command_filter_process: cherry-pick of several commits cause panic error
This commit is contained in:
commit
5f969e6a3e
@ -63,21 +63,10 @@ func filterCommand(cmd *cobra.Command, args []string) {
|
||||
ptrs := make(map[string]*lfs.Pointer)
|
||||
|
||||
var q *tq.TransferQueue
|
||||
closeOnce := new(sync.Once)
|
||||
available := make(chan *tq.Transfer)
|
||||
|
||||
if supportsDelay {
|
||||
q = tq.NewTransferQueue(
|
||||
tq.Download,
|
||||
getTransferManifestOperationRemote("download", cfg.Remote()),
|
||||
cfg.Remote(),
|
||||
tq.RemoteRef(currentRemoteRef()),
|
||||
)
|
||||
go infiniteTransferBuffer(q, available)
|
||||
}
|
||||
|
||||
var malformed []string
|
||||
var malformedOnWindows []string
|
||||
var closeOnce *sync.Once
|
||||
var available chan *tq.Transfer
|
||||
gitfilter := lfs.NewGitFilter(cfg)
|
||||
for s.Scan() {
|
||||
var n int64
|
||||
@ -99,6 +88,19 @@ func filterCommand(cmd *cobra.Command, args []string) {
|
||||
n = ptr.Size
|
||||
}
|
||||
case "smudge":
|
||||
if q == nil && supportsDelay {
|
||||
closeOnce = new(sync.Once)
|
||||
available = make(chan *tq.Transfer)
|
||||
|
||||
q = tq.NewTransferQueue(
|
||||
tq.Download,
|
||||
getTransferManifestOperationRemote("download", cfg.Remote()),
|
||||
cfg.Remote(),
|
||||
tq.RemoteRef(currentRemoteRef()),
|
||||
)
|
||||
go infiniteTransferBuffer(q, available)
|
||||
}
|
||||
|
||||
w = git.NewPktlineWriter(os.Stdout, smudgeFilterBufferCapacity)
|
||||
if req.Header["can-delay"] == "1" {
|
||||
var ptr *lfs.Pointer
|
||||
@ -124,8 +126,8 @@ func filterCommand(cmd *cobra.Command, args []string) {
|
||||
closeOnce.Do(func() {
|
||||
// The first time that Git sends us the
|
||||
// 'list_available_blobs' command, it is given
|
||||
// that no more smudge commands will be issued
|
||||
// with _new_ checkout entries.
|
||||
// that now it waiting until all delayed blobs
|
||||
// are available within this smudge filter call
|
||||
//
|
||||
// This means that, by the time that we're here,
|
||||
// we have seen all entries in the checkout, and
|
||||
@ -158,6 +160,12 @@ func filterCommand(cmd *cobra.Command, args []string) {
|
||||
// accept it later.
|
||||
paths = append(paths, fmt.Sprintf("pathname=%s", path))
|
||||
}
|
||||
// At this point all items have been completely processed,
|
||||
// so we explicitly close transfer queue. If Git issues
|
||||
// another `smudge` command the transfer queue will be
|
||||
// created from scratch. Transfer queue needs to be recreated
|
||||
// because it has been already partially closed by `q.Wait()`
|
||||
q = nil
|
||||
}
|
||||
err = s.WriteList(paths)
|
||||
default:
|
||||
|
36
t/t-cherry-pick-commits.sh
Normal file
36
t/t-cherry-pick-commits.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. "$(dirname "$0")/testlib.sh"
|
||||
|
||||
begin_test "cherry-pick two commits without lfs cache"
|
||||
(
|
||||
set -e
|
||||
|
||||
reponame="$(basename "$0" ".sh")-cherry-pick-commits"
|
||||
setup_remote_repo "$reponame"
|
||||
clone_repo "$reponame" cherrypickcommits
|
||||
|
||||
git lfs track "*.dat"
|
||||
git add .gitattributes
|
||||
git commit -m "initial commit"
|
||||
|
||||
git branch secondbranch
|
||||
|
||||
echo "smudge a" > a.dat
|
||||
git add a.dat
|
||||
git commit -m "add a.dat"
|
||||
commit1=$(git log -n1 --format="%H")
|
||||
|
||||
echo "smudge b" > b.dat
|
||||
git add b.dat
|
||||
git commit -m "add a.dat"
|
||||
commit2=$(git log -n1 --format="%H")
|
||||
|
||||
git push origin master
|
||||
|
||||
git checkout secondbranch
|
||||
rm -rf .git/lfs/objects
|
||||
|
||||
git cherry-pick $commit1 $commit2
|
||||
)
|
||||
end_test
|
Loading…
Reference in New Issue
Block a user