diff options
author | Paul Okstad <pokstad@gitlab.com> | 2021-01-21 19:32:10 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2021-02-12 11:02:17 +0300 |
commit | 74bf77bd057c09e6de971cbbb60205e0e76bfe31 (patch) | |
tree | 23e400f529ad854739c2ea512bad37b6b7abc50c | |
parent | 68d292f5e2659ec21739fa7a22c314e72f011ac7 (diff) |
Fixes resolve conflict for new file conflict
This small fix ensures that conflicts between commits for new files will
not return an error. To accomplish this, we provide the same path for
our side of the conflict in place of the missing ancestor so that the
Go implementation of ResolveConflicts emulates the existing Ruby
functionality.
-rw-r--r-- | cmd/gitaly-git2go/resolve_conflicts.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cmd/gitaly-git2go/resolve_conflicts.go b/cmd/gitaly-git2go/resolve_conflicts.go index b84311c1c..4e4b69ddb 100644 --- a/cmd/gitaly-git2go/resolve_conflicts.go +++ b/cmd/gitaly-git2go/resolve_conflicts.go @@ -102,8 +102,6 @@ func (cmd resolveSubcommand) Run(_ context.Context, r io.Reader, w io.Writer) er } switch { - case c.Ancestor == nil: - return fmt.Errorf("missing ancestor-part of merge file input for new path %q", r.NewPath) case c.Our == nil: return fmt.Errorf("missing our-part of merge file input for new path %q", r.NewPath) case c.Their == nil: @@ -115,11 +113,16 @@ func (cmd resolveSubcommand) Run(_ context.Context, r io.Reader, w io.Writer) er return fmt.Errorf("merge file result for %q: %w", r.NewPath, err) } + ancestorPath := c.Our.Path + if c.Ancestor != nil { + ancestorPath = c.Ancestor.Path + } + conflictFile, err := conflict.Parse( bytes.NewReader(mfr.Contents), c.Our.Path, c.Their.Path, - c.Ancestor.Path, + ancestorPath, ) if err != nil { return fmt.Errorf("parse conflict for %q: %w", c.Ancestor.Path, err) @@ -205,6 +208,10 @@ func mergeFileResult(odb *git.Odb, c git.IndexConflict) (*git.MergeFileResult, e {name: "our", entry: c.Our, mfi: &ourMFI}, {name: "their", entry: c.Their, mfi: &theirMFI}, } { + if part.entry == nil { + continue + } + blob, err := odb.Read(part.entry.Id) if err != nil { return nil, err |