Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/gitrepo/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (w *WorkRepo) Apply(

g := *w.Git
g.Env = append(append([]string(nil), g.Env...), w.env()...)
// git am's hints on resolving a conflict by hand don't belong in
// reports.
noConflictHints := "advice.mergeConflict=false"
noWorkDirHints := "advice.amWorkDir=false"
var shas []string
for i, m := range mboxes {
w.Git.log().Info(fmt.Sprintf("Applying email %d of %d with git am.",
Expand All @@ -182,7 +186,8 @@ func (w *WorkRepo) Apply(
if err != nil {
return shas, -1, "", err
}
if _, err := g.Run(ctx, "am", "-q", "-3", "--no-gpg-sign", file); err != nil {
if _, err := g.Run(ctx, "-c", noConflictHints, "-c", noWorkDirHints,
"am", "-q", "-3", "--no-gpg-sign", file); err != nil {
var gerr *Error
if !errors.As(err, &gerr) {
return shas, -1, "", err
Expand Down
16 changes: 16 additions & 0 deletions internal/gitrepo/work_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ func TestApplyFailure(t *testing.T) {
}
}

// The output of a failed git am goes into reports, so it must not have
// git's hints about resolving the conflict by hand.
func TestApplyFailureHasNoHints(t *testing.T) {
upstream, test, patches := setup(t)
ctx := context.Background()
w := newWork(t, test)
base, _ := w.Resolve(ctx, upstream, "main")
_, failed, out, err := w.Apply(ctx, base, patches[2:])
if err != nil || failed != 0 {
t.Fatalf("failed=%d out=%q err=%v", failed, out, err)
}
if strings.Contains(out, "hint:") {
t.Errorf("git am output has hints:\n%s", out)
}
}

// git am applies a patch whose change is already there without a
// commit, and without an error.
func TestApplyAlreadyApplied(t *testing.T) {
Expand Down