Skip to content

Commit

Permalink
Fix segmentation violation on no commit diff pull
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaniwaki committed Jun 13, 2019
1 parent 81ef491 commit 528dede
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 7 additions & 1 deletion pkg/ghost/types/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func apply(ghost GhostBranch, we WorkingEnv, expectedSrcHead string) errors.GitG
return git.ApplyDiffBundleFile(we.SrcDir, path.Join(we.GhostDir, ghost.FileName()))
case DiffBranch:
return git.ApplyDiffPatchFile(we.SrcDir, path.Join(we.GhostDir, ghost.FileName()))

default:
return errors.Errorf("not supported on type = %+v", reflect.TypeOf(ghost))
}
Expand All @@ -208,6 +207,13 @@ func (bs CommitsBranch) Show(we WorkingEnv, writer io.Writer) errors.GitGhostErr

// Apply applies contents(diff or patch) of this ghost branch on passed working env
func (bs CommitsBranch) Apply(we WorkingEnv) errors.GitGhostError {
if bs.CommitHashFrom == bs.CommitHashTo {
log.WithFields(log.Fields{
"from": bs.CommitHashFrom,
"to": bs.CommitHashTo,
}).Warn("skipping apply ghost commits branch because from-hash and to-hash is the same.")
return nil
}
err := apply(bs, we, bs.CommitHashFrom)
if err != nil {
return err
Expand Down
13 changes: 6 additions & 7 deletions pkg/ghost/types/branchspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,12 @@ func (bs CommitsBranchSpec) PullBranch(we WorkingEnv) (GhostBranch, errors.GitGh
log.WithFields(log.Fields{
"from": branch.CommitHashFrom,
"to": branch.CommitHashTo,
}).Warn("skipping pull and apply ghost commits branch because from-hash and to-hash is the same.")
return nil, nil
}

err = pull(branch, we)
if err != nil {
return nil, err
}).Warn("skipping pull ghost commits branch because from-hash and to-hash is the same.")
} else {
err = pull(branch, we)
if err != nil {
return nil, err
}
}
return branch, nil
}
Expand Down

0 comments on commit 528dede

Please sign in to comment.