Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: add option to search for header or body #1710

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 7, 2024

  1. log: add option to search for header or body

    Summary:
    This change adds a new option to `git log` that allows users to search
    for commits that match either the author or the commit message. This is
    useful for finding commits that were either authored or co-authored by a
    specific person.
    
    Currently, the best way to find a commit either authored or co-authored
    by a specific person is to use
    
    ```sh
    $ echo \
        $(git log --author=Torvalds --pretty="%cd,%H\n" --date=iso-strict) \
        $(git log --grep="Co-authored-by: .*Torvalds" --pretty="%cd,%H\n" --date=iso-strict) \
    | sort -n --reverse \
    | awk -F, '{print $2}' \
    | tr '\n' '\t' \
    | xargs git show --stat --stdin
    ```
    
    This is a bit of a pain, so this change adds a new option to `git log`.
    Now finding either authors or co-authors is as simple as
    
    ```sh
    $ git log --author=Torvalds --grep=Torvalds --match-header-or-grep
    ```
    
    Test plan:
    1. create commit authored by A and co-authored-by B
    2. create commit authored by B
    3. run
    ```sh
    $ git log --author=B --grep="Co-authored-by: B" --match-header-or-grep
    ```
    4. expect to see both commits
    
    Signed-off-by: Max 👨🏽‍💻 Coplan <[email protected]>
    vegerot committed Apr 7, 2024
    Configuration menu
    Copy the full SHA
    c7f14e5 View commit details
    Browse the repository at this point in the history