[PATCH 06/20] patman: Allow setting a git directory when sending
Simon Glass
sjg at chromium.org
Thu May 8 09:28:30 CEST 2025
Support specifying the git-directory when creating and sending patches.
This will allow better testing of this functionality, since we can use a
test directory.
For count_commits_to_branch() support an end commit while we are here.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/patman/patchstream.py | 7 ++++---
tools/patman/send.py | 16 +++++++++-------
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 3ec06a6b5f5..5691ee4b3c1 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -754,7 +754,7 @@ def get_metadata_for_list(commit_range, git_dir=None, count=None,
pst.finalise()
return series
-def get_metadata(branch, start, count):
+def get_metadata(branch, start, count, git_dir=None):
"""Reads out patch series metadata from the commits
This does a 'git log' on the relevant commits and pulls out the tags we
@@ -769,8 +769,9 @@ def get_metadata(branch, start, count):
Series: Object containing information about the commits.
"""
top = f"{branch if branch else 'HEAD'}~{start}"
- series = get_metadata_for_list(top, None, count)
- series.base_commit = commit.Commit(gitutil.get_hash(f'{top}~{count}'))
+ series = get_metadata_for_list(top, git_dir, count)
+ series.base_commit = commit.Commit(
+ gitutil.get_hash(f'{top}~{count}', git_dir))
series.branch = branch or gitutil.get_branch()
series.top = top
return series
diff --git a/tools/patman/send.py b/tools/patman/send.py
index a2db3cff07f..7989fe32f92 100644
--- a/tools/patman/send.py
+++ b/tools/patman/send.py
@@ -112,7 +112,7 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
- keep_change_id=False, cwd=None):
+ keep_change_id=False, git_dir=None, cwd=None):
"""Figure out what patches to generate, then generate them
The patch files are written to the current directory, e.g. 0001_xxx.patch
@@ -123,11 +123,12 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
branch (str): Branch to create patches from (None = current)
count (int): Number of patches to produce, or -1 to produce patches for
the current branch back to the upstream commit
- start (int): Start partch to use (0=first / top of branch)
+ start (int): Start patch to use (0=first / top of branch)
end (int): End patch to use (0=last one in series, 1=one before that,
etc.)
ignore_binary (bool): Don't generate patches for binary files
keep_change_id (bool): Preserve the Change-Id tag.
+ git_dir (str): Path to git repository (None to use default)
cwd (str): Path to use for git operations (None to use current dir)
Returns:
@@ -139,7 +140,8 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
"""
if count == -1:
# Work out how many patches to send if we can
- count = (gitutil.count_commits_to_branch(branch) - start)
+ count = (gitutil.count_commits_to_branch(branch, git_dir=git_dir) -
+ start)
if not count:
str = 'No commits found to process - please use -c flag, or run:\n' \
@@ -148,9 +150,9 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
# Read the metadata from the commits
to_do = count - end
- series = patchstream.get_metadata(branch, start, to_do)
+ series = patchstream.get_metadata(branch, start, to_do, git_dir)
cover_fname, patch_files = gitutil.create_patches(
- branch, start, to_do, ignore_binary, series, signoff,
+ branch, start, to_do, ignore_binary, series, signoff, git_dir=git_dir,
cwd=cwd)
# Fix up the patch files to our liking, and insert the cover letter
@@ -161,7 +163,7 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
return series, cover_fname, patch_files
-def send(args, cwd=None):
+def send(args, git_dir=None, cwd=None):
"""Create, check and send patches by email
Args:
@@ -172,7 +174,7 @@ def send(args, cwd=None):
series, cover_fname, patch_files = prepare_patches(
col, args.branch, args.count, args.start, args.end,
args.ignore_binary, args.add_signoff,
- keep_change_id=args.keep_change_id, cwd=cwd)
+ keep_change_id=args.keep_change_id, git_dir=git_dir, cwd=cwd)
ok = check_patches(series, patch_files, args.check_patch,
args.verbose, args.check_patch_use_tree, cwd)
--
2.43.0
More information about the U-Boot
mailing list