Skip to content

Commit 92b97fd

Browse files
committed
fix(remote): add predefined hash for empty repo
1 parent f56955b commit 92b97fd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

remote/remote.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,15 +597,21 @@ func buildPushRequest(updates map[string]RefUpdate) []byte {
597597

598598
first := true
599599
for _, update := range updates {
600+
// use zero hash for new branches
601+
oldHash := update.OldHash
602+
if oldHash == "" {
603+
oldHash = "0000000000000000000000000000000000000000"
604+
}
605+
600606
var line string
601607
if first {
602608
// Include capabilities on first command
603609
line = fmt.Sprintf("%s %s %s\x00report-status side-band-64k\n",
604-
update.OldHash, update.NewHash, update.RefName)
610+
oldHash, update.NewHash, update.RefName)
605611
first = false
606612
} else {
607613
line = fmt.Sprintf("%s %s %s\n",
608-
update.OldHash, update.NewHash, update.RefName)
614+
oldHash, update.NewHash, update.RefName)
609615
}
610616

611617
pktLine := fmt.Sprintf("%04x%s", len(line)+4, line)

0 commit comments

Comments
 (0)