Skip to content

Commit 3ced493

Browse files
committed
Fix a crash when some commits are missing.
Fixes #3.
1 parent 31394d8 commit 3ced493

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

subtrac.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func (c *Cache) UpdateBranchRefs() error {
140140
commit, err := c.TracByRef(name)
141141
if err != nil {
142142
return err
143+
} else if commit == nil {
144+
c.infof("Warning: no submodule commits found for %v; skipping.\n", name)
143145
} else {
144146
branches = append(branches, b)
145147
commits = append(commits, commit)
@@ -149,10 +151,14 @@ func (c *Cache) UpdateBranchRefs() error {
149151
if err != nil {
150152
return err
151153
}
154+
if len(branches) != len(commits) {
155+
return fmt.Errorf("weird: branches=%d commits=%d", len(branches), len(commits))
156+
}
152157

153158
for i := range branches {
154159
newname := string(branches[i].Name()) + ".trac"
155-
hash := commits[i].Hash
160+
cc := commits[i]
161+
hash := cc.Hash
156162
c.infof("Updating %.10v -> %v\n", hash, newname)
157163

158164
refname := plumbing.ReferenceName(newname)

0 commit comments

Comments
 (0)