Skip to content

Support passing ref to git-commits-since#1228

Merged
hyperupcall merged 3 commits intotj:mainfrom
eskultety:commits-since-ref
Feb 3, 2026
Merged

Support passing ref to git-commits-since#1228
hyperupcall merged 3 commits intotj:mainfrom
eskultety:commits-since-ref

Conversation

@eskultety
Copy link
Contributor

The commits-since command only considers dates. It's useful to dump a list of commits based on a ref, i.e. a tag, branch, or even another commit. This patch introduces a new optional '--ref|-r' flag that toggles a ref-specific variant of 'git log'.

Docs for the respective module has been updated & regenerated as well.

git log --pretty='%an - %s' "$REF..HEAD"
else
git log --pretty='%an - %s' --after="@{$SINCE}"
fi No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix the editorconfig lint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


echo "... commits since ${REF:-$SINCE}" >&2

if [[ -n "$REF" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if "$REF" exist before using it

Copy link
Contributor Author

@eskultety eskultety Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the actual ref or the variable itself? IOW do you want me to first verify that git can resolve the ref before I use it with the log command? If so, that was a deliberate decision, because the error from git is quite clear, IOW if invalidtag is used as a tag ref then it's a user error and we should let the command fail explicitly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine.

echo "error: option $1 requires an argument" >&2
exit 1
fi
REF="$2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's report an error if both $SINCE and $REF given

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

This line provides little to no value to the end user since the input
is very clear. Additionally, from a maintainer's POV it pretty much
just pollutes the expected formatted output regardless of the fact that
we can avoid it by redirecting stderr and therefore feels redundant -->
drop it.

Signed-off-by: Erik Skultety <skultety.erik@gmail.com>
Having pretty formatting does aid human readability, but from a
maintainer's POV having a commit reference in the commit list to be
able to quickly inspect what a given commit from the list is about is
invaluable.

Signed-off-by: Erik Skultety <skultety.erik@gmail.com>
The commits-since command only considers dates. It's useful to dump a
list of commits based on a ref, i.e. a tag, branch, or even another
commit. This patch introduces a new optional '--ref|-r' flag that
toggles a ref-specific variant of 'git log'.

Docs for the respective module has been updated & regenerated as well.

Signed-off-by: Erik Skultety <skultety.erik@gmail.com>
@eskultety
Copy link
Contributor Author

I added 2 more stylistic commits since last revision as I was primarily testing the interest and seeking approval for the feature with my original proposal.
I noticed the PR guidelines after I had all the changes rebased and fixed up properly:

Make a new commit to resolve conversations instead of push -f.
To resolve merge conflicts, merge from the main branch instead of rebasing over main.

I hope it won't be necessary for this PR to be re-adjusted :)

@spacewander
Copy link
Collaborator

I added 2 more stylistic commits since last revision as I was primarily testing the interest and seeking approval for the feature with my original proposal. I noticed the PR guidelines after I had all the changes rebased and fixed up properly:

Make a new commit to resolve conversations instead of push -f.
To resolve merge conflicts, merge from the main branch instead of rebasing over main.

I hope it won't be necessary for this PR to be re-adjusted :)

It's OK. This PR is small so I can simply re-review it :)

Copy link
Collaborator

@hyperupcall hyperupcall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hyperupcall hyperupcall changed the title Enhance git-commits-since by allowing refs as well Allow passing ref to git-commits-since Feb 3, 2026
@hyperupcall hyperupcall changed the title Allow passing ref to git-commits-since Support passing ref to git-commits-since Feb 3, 2026
@hyperupcall hyperupcall merged commit 5367101 into tj:main Feb 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants