Skip to content

Commit 5367101

Browse files
authored
Support passing ref to git-commits-since (#1228)
1 parent 6ed2643 commit 5367101

File tree

7 files changed

+134
-77
lines changed

7 files changed

+134
-77
lines changed

bin/git-commits-since

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
#!/usr/bin/env bash
22

3-
SINCE="last week"
4-
test $# -ne 0 && SINCE=$*
5-
echo "... commits since $SINCE" >&2
6-
git log --pretty='%an - %s' --after="@{$SINCE}"
3+
REF=""
4+
SINCE=""
5+
6+
while [[ $# -gt 0 ]]; do
7+
case "$1" in
8+
-r|--ref)
9+
if [[ -z "$2" ]]; then
10+
echo "error: option $1 requires an argument" >&2
11+
exit 1
12+
fi
13+
REF="$2"
14+
shift
15+
shift
16+
;;
17+
*)
18+
# non-flag args accumulation, e.g. "last " + "week" -> "last week"
19+
SINCE="${SINCE:+$SINCE }$1"
20+
shift
21+
;;
22+
esac
23+
done
24+
25+
if [[ -n "$REF" && -n "$SINCE" ]]; then
26+
echo "error: '--ref <ref>' and '<date>' are mutually exclusive" >&2
27+
exit 1
28+
fi
29+
30+
SINCE="${SINCE:-last week}"
31+
32+
if [[ -n "$REF" ]]; then
33+
git log --pretty='%h %an - %s' "$REF..HEAD"
34+
else
35+
git log --pretty='%h %an - %s' --after="@{$SINCE}"
36+
fi

etc/bash_completion.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ _git_contrib(){
8282
COMPREPLY=($(compgen -W "$all" -- "$cur"))
8383
}
8484

85+
_git_commits_since(){
86+
__gitcomp "-r --ref"
87+
}
88+
8589
_git_count(){
8690
__gitcomp "--all"
8791
}

etc/git-extras-completion.zsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ _git-coauthor() {
171171
':co-author-email[email address of co-author to add]:__gitex_author_emails'
172172
}
173173

174+
_git-commits-since() {
175+
_arguments \
176+
'(-r --ref)'{-r,--ref}'[show commits since ref]'
177+
}
178+
174179
_git-contrib() {
175180
_arguments \
176181
':author:__gitex_author_names'

etc/git-extras.fish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ function __fish_git_extra_coauthor_email
131131
end
132132
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 2' -a '(__fish_git_extra_coauthor_name)'
133133
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 3' -a '(__fish_git_extra_coauthor_email)'
134+
# commits-since
135+
complete -c git -f -n '__fish_git_using_command commits-since' -s r -l ref -d 'show commits since ref'
134136
# count
135137
complete -c git -f -n '__fish_git_using_command count' -l all -d 'detailed commit count'
136138
# create-branch

man/git-commits-since.1

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
1-
.\" generated with Ronn/v0.7.3
2-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
3-
.
4-
.TH "GIT\-COMMITS\-SINCE" "1" "October 2017" "" "Git Extras"
5-
.
1+
.\" generated with Ronn-NG/v0.9.1
2+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3+
.TH "GIT\-COMMITS\-SINCE" "1" "January 2026" "" "Git Extras"
64
.SH "NAME"
75
\fBgit\-commits\-since\fR \- Show commit logs since some date
8-
.
96
.SH "SYNOPSIS"
10-
\fBgit\-commits\-since\fR [<date>]
11-
.
7+
.TS
8+
allbox;
9+
\fBgit\-commits\-since\fR [\-r \-\-ref <ref>] [<date>]
10+
.TE
1211
.SH "DESCRIPTION"
13-
List of commits since the given \fIdate\fR\.
14-
.
12+
List of commits since the given \fIdate\fR or \fIref\fR\.
1513
.SH "OPTIONS"
1614
<date>
17-
.
1815
.P
19-
Show commits more recent than \fIdate\fR\. By default, the command shows the commit logs since "last week"\.
20-
.
16+
Show commits more recent than <date>\. By default, the command shows the commit logs since "last week"\.
17+
.P
18+
\-r, \-\-ref <ref>
19+
.P
20+
Show commits since the given ref (tag, branch, or commit)\. When specified, the command uses \fBref\.\.HEAD\fR instead of date\-based filtering\.
2121
.SH "EXAMPLES"
2222
It is really flexible and these are only 3 of the options, go ahead give it a try:
23-
.
2423
.IP "" 4
25-
.
2624
.nf
27-
2825
$ git commits\-since yesterday
29-
\.\.\. commits since yesterday
30-
nickl\- \- Merge branch upstream master\.
31-
nickl\- \- Rebase bolshakov with master
32-
TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
33-
TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
34-
nickl\- \- Fix #127 git\-ignore won\'t add duplicates\.
26+
aa084d9 TweeKane \- Add global gitignore to git\-ignore output
27+
515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
28+
5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
29+
7398d10 nickl\- \- Fix #127 git\-ignore won\'t add duplicates\.
3530

3631
$ git commits\-since 3 o clock pm
37-
\.\.\. commits since 3 o clock pm
38-
nickl\- \- Merge branch upstream master\.
32+
aa084d9 TweeKane \- Add global gitignore to git\-ignore output
3933

4034
$ git commits\-since 2 hour ago
41-
\.\.\. commits since 2 hour ago
42-
nickl\- \- Merge branch upstream master\.
43-
TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
44-
TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
45-
.
35+
aa084d9 TweeKane \- Add global gitignore to git\-ignore output
36+
515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
37+
5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
38+
39+
$ git commits\-since \-\-ref 7\.4\.0
40+
6ed2643 John Bachir \- ability to specify command when hitting enter (#1223)
41+
b9bd309 John Bachir \- Improve `git\-repl` prompt (#1224)
42+
6f4cf0c johnpyp \- feat: `delete\-branch` multiple unique branch names completions (#1221)
43+
\|\.\|\.\|\.
44+
215382b 罗泽轩 \- Bump version to 7\.5\.0\-dev (#1207)
4645
.fi
47-
.
4846
.IP "" 0
49-
.
5047
.SH "AUTHOR"
5148
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR>
52-
.
5349
.SH "REPORTING BUGS"
5450
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
55-
.
5651
.SH "SEE ALSO"
5752
<\fIhttps://github\.com/tj/git\-extras\fR>

man/git-commits-since.html

Lines changed: 39 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-commits-since.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,46 @@ git-commits-since(1) -- Show commit logs since some date
33

44
## SYNOPSIS
55

6-
`git-commits-since` [&lt;date&gt;]
6+
`git-commits-since` [-r|--ref &lt;ref&gt;] [&lt;date&gt;]
77

88
## DESCRIPTION
99

10-
List of commits since the given _date_.
10+
List of commits since the given _date_ or _ref_.
1111

1212
## OPTIONS
1313

1414
&lt;date&gt;
1515

16-
Show commits more recent than <date>. By default, the command shows the commit logs since "last week".
16+
Show commits more recent than &lt;date&gt;. By default, the command shows the commit logs since "last week".
17+
18+
-r, --ref &lt;ref&gt;
19+
20+
Show commits since the given ref (tag, branch, or commit). When specified, the command uses `ref..HEAD` instead of date-based filtering.
1721

1822
## EXAMPLES
1923

2024
It is really flexible and these are only 3 of the options, go ahead give it a try:
2125

2226
$ git commits-since yesterday
23-
... commits since yesterday
24-
nickl- - Merge branch upstream master.
25-
nickl- - Rebase bolshakov with master
26-
TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
27-
TJ Holowaychuk - Merge pull request #129 from nickl-/develop
28-
nickl- - Fix #127 git-ignore won't add duplicates.
27+
aa084d9 TweeKane - Add global gitignore to git-ignore output
28+
515e94a TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
29+
5f86b54 TJ Holowaychuk - Merge pull request #129 from nickl-/develop
30+
7398d10 nickl- - Fix #127 git-ignore won't add duplicates.
2931

3032
$ git commits-since 3 o clock pm
31-
... commits since 3 o clock pm
32-
nickl- - Merge branch upstream master.
33+
aa084d9 TweeKane - Add global gitignore to git-ignore output
3334

3435
$ git commits-since 2 hour ago
35-
... commits since 2 hour ago
36-
nickl- - Merge branch upstream master.
37-
TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
38-
TJ Holowaychuk - Merge pull request #129 from nickl-/develop
39-
36+
aa084d9 TweeKane - Add global gitignore to git-ignore output
37+
515e94a TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
38+
5f86b54 TJ Holowaychuk - Merge pull request #129 from nickl-/develop
39+
40+
$ git commits-since --ref 7.4.0
41+
6ed2643 John Bachir - ability to specify command when hitting enter (#1223)
42+
b9bd309 John Bachir - Improve `git-repl` prompt (#1224)
43+
6f4cf0c johnpyp - feat: `delete-branch` multiple unique branch names completions (#1221)
44+
...
45+
215382b 罗泽轩 - Bump version to 7.5.0-dev (#1207)
4046

4147
## AUTHOR
4248

0 commit comments

Comments
 (0)