Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit b329dac

Browse files
committed
send PACK only if non-delete command present
According to: https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt > The packfile MUST NOT be sent if the only command used is 'delete'.
1 parent 832752f commit b329dac

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

remote.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ func pushHashes(
10361036
) (*packp.ReportStatus, error) {
10371037

10381038
rd, wr := io.Pipe()
1039-
req.Packfile = rd
1039+
10401040
config, err := s.Config()
10411041
if err != nil {
10421042
return nil, err
@@ -1047,15 +1047,20 @@ func pushHashes(
10471047
// to the channel.
10481048
done := make(chan error, 1)
10491049

1050-
go func() {
1051-
e := packfile.NewEncoder(wr, s, useRefDeltas)
1052-
if _, err := e.Encode(hs, config.Pack.Window); err != nil {
1053-
done <- wr.CloseWithError(err)
1054-
return
1055-
}
1050+
if len(hs) != 0 {
1051+
req.Packfile = rd
1052+
go func() {
1053+
e := packfile.NewEncoder(wr, s, useRefDeltas)
1054+
if _, err := e.Encode(hs, config.Pack.Window); err != nil {
1055+
done <- wr.CloseWithError(err)
1056+
return
1057+
}
10561058

1057-
done <- wr.Close()
1058-
}()
1059+
done <- wr.Close()
1060+
}()
1061+
} else {
1062+
close(done)
1063+
}
10591064

10601065
rs, err := sess.ReceivePack(ctx, req)
10611066
if err != nil {

0 commit comments

Comments
 (0)