From a3d04ad5be8ae967e60c6f1a4f193340174590c8 Mon Sep 17 00:00:00 2001 From: Rosemarie O'Riorden Date: Mon, 30 Nov 2026 15:39:24 -0500 Subject: [PATCH] gitrepo: Leave git am's hints out of apply failures. The output of a failed git am goes into the report sent to the submitter of the patch, where git's hints on resolving the conflict by hand, such as running "git am --continue", make no sense. Turn off both kinds of hints it prints, advice.mergeConflict and advice.amWorkDir. Signed-off-by: Rosemarie O'Riorden --- internal/gitrepo/work.go | 7 ++++++- internal/gitrepo/work_test.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/gitrepo/work.go b/internal/gitrepo/work.go index 1d1d3463..e2bf1827 100644 --- a/internal/gitrepo/work.go +++ b/internal/gitrepo/work.go @@ -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.", @@ -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 diff --git a/internal/gitrepo/work_test.go b/internal/gitrepo/work_test.go index 31b789f8..2267018f 100644 --- a/internal/gitrepo/work_test.go +++ b/internal/gitrepo/work_test.go @@ -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) {