The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1f091ad283e9e9815f568d6fdf2b58d1e75f02b3

commit 1f091ad283e9e9815f568d6fdf2b58d1e75f02b3
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-10 14:44:09 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-07-10 14:44:09 +0000

    git-mfc: Filter pending and dangling commits by committer
    
    Previously we searched commits based on the author email address, but
    this isn't really right: if I commit something from a contributor, I'm
    still responsible for MFCing it, so really we should be filtering on the
    committer.
    
    Add a new --committer option to filter results by committer email
    address, defaulting to the user.email value in the git config.
    
    Keep the --author option, but don't filter by author unless the option
    is explicitly specified.
    
    Reported by:    des
    Reviewed by:    des
    Differential Revision:  https://reviews.freebsd.org/D58126
---
 tools/tools/git/git-mfc   | 49 +++++++++++++++++++++++++++++------------------
 tools/tools/git/git-mfc.1 | 13 +++++++++++--
 2 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/tools/tools/git/git-mfc b/tools/tools/git/git-mfc
index c3ff474add3e..513a7f150e3c 100755
--- a/tools/tools/git/git-mfc
+++ b/tools/tools/git/git-mfc
@@ -31,6 +31,11 @@ def commit_summary(commit):
     return f'{commit.hexsha} ("{commit.summary}")'
 
 
+def commit_match(commit, author, committer):
+    return (author is None or author in commit.author.email) and \
+           (committer is None or committer in commit.committer.email)
+
+
 def origin_branch():
     """
     Determine the default origin branch by parsing sys/conf/newvers.sh.
@@ -245,7 +250,7 @@ def mfc_origins(repo, commit, warn=False):
     return origins
 
 
-def dangling(repo, upstream, author=None):
+def dangling(repo, upstream, author=None, committer=None):
     """
     Find commits in the current branch which have been cherry-picked from
     upstream but are missing fixup commits.
@@ -258,7 +263,7 @@ def dangling(repo, upstream, author=None):
         refs = mfc_origins(repo, commit, warn=True)
         for ref in refs:
             picked.append(ref.hexsha)
-            if author is None or author in commit.author.email:
+            if commit_match(ref, author, committer):
                 mine.append(ref.hexsha)
     # Create a mapping of all upstream commits to their fixups,
     # tracking reverts as we go.
@@ -301,7 +306,7 @@ def mfc_after(commit):
     return None
 
 
-def pending(repo, upstream, author=None, baking=False):
+def pending(repo, upstream, author=None, committer=None, baking=False):
     """
     Find commits in the upstream branch that have an "MFC after:" tag, whose
     waiting period has elapsed, and which have not been cherry-picked to the
@@ -339,8 +344,7 @@ def pending(repo, upstream, author=None, baking=False):
             # Not yet eligible for MFC.
             continue
 
-        if author is not None and author not in commit.author.email:
-            # Don't report commits that don't match the requested author.
+        if not commit_match(commit, author, committer):
             continue
 
         committed = datetime.datetime.fromtimestamp(
@@ -388,7 +392,7 @@ def main():
     )
     parser.add_argument(
         '-a', '--author', type=str, default=None,
-        help='Filter --pending/--dangling results by author (default: current 
user)',
+        help='Filter --pending/--dangling results by author (default: ignore 
author)',
     )
     parser.add_argument(
         '--all', action='store_true',
@@ -399,6 +403,10 @@ def main():
         help='With --pending, also show commits whose MFC-after period '
              'has not yet elapsed',
     )
+    parser.add_argument(
+        '-c', '--committer', type=str, default=None,
+        help='Filter --pending/--dangling results by committer (default: 
current user)',
+    )
     parser.add_argument(
         '--dangling', action='store_true',
         help='Find cherry-picked commits in the current branch that are '
@@ -455,24 +463,27 @@ def main():
     if not args.n:
         repo.remotes[remote].fetch(origin)
 
-    show_all = getattr(args, 'all')
-    if show_all:
-        author = None
-    elif args.author:
-        author = args.author
-    elif args.dangling or args.pending:
-        author = repo.config_reader().get_value('user', 'email', default=None)
-        if author is None:
-            err(1, "could not determine user email; use -a or --all")
-    else:
-        author = None
+    # Do we want to filter commits by author or committer?  By default, use
+    # the current git user's email to match the committer field.
+    author = committer = None
+    if not getattr(args, 'all'):
+        user_email = repo.config_reader().get_value('user', 'email', 
default=None)
+        if args.author:
+            author = args.author
+
+        if args.committer:
+            committer = args.committer
+        else:
+            committer = user_email
+            if committer is None:
+                err(1, "could not determine user email; use -c or --all")
 
     if args.dangling:
-        missing = dangling(repo, upstream, author=author)
+        missing = dangling(repo, upstream, author=author, committer=committer)
         for fixup, commit in missing:
             print(f'{commit_summary(fixup)} fixes {commit_summary(commit)}')
     elif args.pending:
-        results = pending(repo, upstream, author=author,
+        results = pending(repo, upstream, author=author, committer=committer,
                           baking=args.baking)
         for commit, ready_date, ready in results:
             date_str = ready_date.strftime('%Y-%m-%d')
diff --git a/tools/tools/git/git-mfc.1 b/tools/tools/git/git-mfc.1
index acd27ef3cbcb..a730eae7ee6b 100644
--- a/tools/tools/git/git-mfc.1
+++ b/tools/tools/git/git-mfc.1
@@ -19,6 +19,7 @@
 .Nm
 .Fl -pending
 .Op Fl a Ar author
+.Op Fl c Ar committer
 .Op Fl -all
 .Op Fl -baking
 .Op Fl -origin Ar branch
@@ -26,6 +27,7 @@
 .Nm
 .Fl -dangling
 .Op Fl a Ar author
+.Op Fl c Ar committer
 .Op Fl -all
 .Op Fl -origin Ar branch
 .Op Fl r Ar remote
@@ -84,7 +86,7 @@ scans the origin branch for commits with
 tags whose waiting period has elapsed and which have not already been
 cherry-picked to the current branch.
 Commits that have been reverted upstream are excluded.
-By default, only commits authored by the current user
+By default, only commits committed by the current user
 .Pq as determined by Xr git-config 1
 are shown.
 .It
@@ -96,7 +98,7 @@ Instead,
 finds commits in the current branch that have been cherry-picked from the
 origin branch but are missing associated fixup commits.
 Fixup commits that have been reverted upstream are excluded.
-By default, only cherry-picks authored by the current user
+By default, only cherry-picks committed by the current user
 .Pq as determined by Xr git-config 1
 are considered.
 .El
@@ -109,6 +111,13 @@ With
 or
 .Fl -dangling ,
 filter results to commits whose author email contains the given string.
+By default, the author field of commits is ignored.
+.It Fl c Ar committer , Fl -committer Ar committer
+With
+.Fl -pending
+or
+.Fl -dangling ,
+filter results to commits whose committer email contains the given string.
 By default, the value of
 .Va user.email
 from

Reply via email to