[Concept,22/29] patman: Stash untracked files before reviewing

Message ID 20260501110040.1874719-23-sjg@u-boot.org
State New
Headers
Series patman: Review-flow improvements and shared helpers |

Commit Message

Simon Glass May 1, 2026, 11 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

When starting a review, 'git stash' does not include untracked files
by default. If the current branch has build artefacts or other
untracked files (e.g. rust files present on ci/master), those files
remain in the working tree when the review branch is checked out
and get picked up by the review process.

Pass include_untracked=True to gitutil.stash_save() so untracked
files are also stashed, and restored on 'git stash pop' when the
review finishes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/review.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Patch

diff --git a/tools/patman/review.py b/tools/patman/review.py
index 056333b5fe3..0508b01e5ec 100644
--- a/tools/patman/review.py
+++ b/tools/patman/review.py
@@ -1944,7 +1944,10 @@  def do_review(args, pwork, cser):
         ctx.repo_path = gitutil.get_top_level()
         orig_branch = gitutil.current_branch(ctx.repo_path)
         try:
-            stash_out = gitutil.stash_save(ctx.repo_path)
+            # Stash untracked files too, so build artefacts from the
+            # current branch don't leak into the review branch
+            stash_out = gitutil.stash_save(ctx.repo_path,
+                                           include_untracked=True)
             if 'No local changes' not in stash_out:
                 had_stash = True
         except command.CommandExc: