diff --git a/bin/git-commits-since b/bin/git-commits-since index c07c53032..5cd53e785 100755 --- a/bin/git-commits-since +++ b/bin/git-commits-since @@ -1,6 +1,36 @@ #!/usr/bin/env bash -SINCE="last week" -test $# -ne 0 && SINCE=$* -echo "... commits since $SINCE" >&2 -git log --pretty='%an - %s' --after="@{$SINCE}" \ No newline at end of file +REF="" +SINCE="" + +while [[ $# -gt 0 ]]; do + case "$1" in + -r|--ref) + if [[ -z "$2" ]]; then + echo "error: option $1 requires an argument" >&2 + exit 1 + fi + REF="$2" + shift + shift + ;; + *) + # non-flag args accumulation, e.g. "last " + "week" -> "last week" + SINCE="${SINCE:+$SINCE }$1" + shift + ;; + esac +done + +if [[ -n "$REF" && -n "$SINCE" ]]; then + echo "error: '--ref ' and '' are mutually exclusive" >&2 + exit 1 +fi + +SINCE="${SINCE:-last week}" + +if [[ -n "$REF" ]]; then + git log --pretty='%h %an - %s' "$REF..HEAD" +else + git log --pretty='%h %an - %s' --after="@{$SINCE}" +fi diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index fa561efe0..d48cdb345 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -82,6 +82,10 @@ _git_contrib(){ COMPREPLY=($(compgen -W "$all" -- "$cur")) } +_git_commits_since(){ + __gitcomp "-r --ref" +} + _git_count(){ __gitcomp "--all" } diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 0ab03d265..128d269b9 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -171,6 +171,11 @@ _git-coauthor() { ':co-author-email[email address of co-author to add]:__gitex_author_emails' } +_git-commits-since() { + _arguments \ + '(-r --ref)'{-r,--ref}'[show commits since ref]' +} + _git-contrib() { _arguments \ ':author:__gitex_author_names' diff --git a/etc/git-extras.fish b/etc/git-extras.fish index 0de358f55..976cfca0c 100644 --- a/etc/git-extras.fish +++ b/etc/git-extras.fish @@ -131,6 +131,8 @@ function __fish_git_extra_coauthor_email end complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 2' -a '(__fish_git_extra_coauthor_name)' complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 3' -a '(__fish_git_extra_coauthor_email)' +# commits-since +complete -c git -f -n '__fish_git_using_command commits-since' -s r -l ref -d 'show commits since ref' # count complete -c git -f -n '__fish_git_using_command count' -l all -d 'detailed commit count' # create-branch diff --git a/man/git-commits-since.1 b/man/git-commits-since.1 index 93bd44336..94542a195 100644 --- a/man/git-commits-since.1 +++ b/man/git-commits-since.1 @@ -1,57 +1,52 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "GIT\-COMMITS\-SINCE" "1" "October 2017" "" "Git Extras" -. +.\" generated with Ronn-NG/v0.9.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 +.TH "GIT\-COMMITS\-SINCE" "1" "January 2026" "" "Git Extras" .SH "NAME" \fBgit\-commits\-since\fR \- Show commit logs since some date -. .SH "SYNOPSIS" -\fBgit\-commits\-since\fR [] -. +.TS +allbox; +\fBgit\-commits\-since\fR [\-r \-\-ref ] [] +.TE .SH "DESCRIPTION" -List of commits since the given \fIdate\fR\. -. +List of commits since the given \fIdate\fR or \fIref\fR\. .SH "OPTIONS" -. .P -Show commits more recent than \fIdate\fR\. By default, the command shows the commit logs since "last week"\. -. +Show commits more recent than \. By default, the command shows the commit logs since "last week"\. +.P +\-r, \-\-ref +.P +Show commits since the given ref (tag, branch, or commit)\. When specified, the command uses \fBref\.\.HEAD\fR instead of date\-based filtering\. .SH "EXAMPLES" It is really flexible and these are only 3 of the options, go ahead give it a try: -. .IP "" 4 -. .nf - $ git commits\-since yesterday -\.\.\. commits since yesterday -nickl\- \- Merge branch upstream master\. -nickl\- \- Rebase bolshakov with master -TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks -TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop -nickl\- \- Fix #127 git\-ignore won\'t add duplicates\. +aa084d9 TweeKane \- Add global gitignore to git\-ignore output +515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks +5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop +7398d10 nickl\- \- Fix #127 git\-ignore won\'t add duplicates\. $ git commits\-since 3 o clock pm -\.\.\. commits since 3 o clock pm -nickl\- \- Merge branch upstream master\. +aa084d9 TweeKane \- Add global gitignore to git\-ignore output $ git commits\-since 2 hour ago -\.\.\. commits since 2 hour ago -nickl\- \- Merge branch upstream master\. -TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks -TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop -. +aa084d9 TweeKane \- Add global gitignore to git\-ignore output +515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks +5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop + +$ git commits\-since \-\-ref 7\.4\.0 +6ed2643 John Bachir \- ability to specify command when hitting enter (#1223) +b9bd309 John Bachir \- Improve `git\-repl` prompt (#1224) +6f4cf0c johnpyp \- feat: `delete\-branch` multiple unique branch names completions (#1221) +\|\.\|\.\|\. +215382b 罗泽轩 \- Bump version to 7\.5\.0\-dev (#1207) .fi -. .IP "" 0 -. .SH "AUTHOR" Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> -. .SH "REPORTING BUGS" <\fIhttps://github\.com/tj/git\-extras/issues\fR> -. .SH "SEE ALSO" <\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-commits-since.html b/man/git-commits-since.html index e29d46976..fae22f782 100644 --- a/man/git-commits-since.html +++ b/man/git-commits-since.html @@ -1,8 +1,8 @@ - - + + git-commits-since(1) - Show commit logs since some date