This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Action stamps
- From: Jason Merrill <jason at redhat dot com>
- To: esr at thyrsus dot com
- Cc: "Dominique d'HumiÃres" <dominiq at lps dot ens dot fr>, GCC Development <gcc at gcc dot gnu dot org>, jakub at redhat dot com
- Date: Tue, 1 Sep 2015 11:31:02 -0400
- Subject: Re: Action stamps
- Authentication-results: sourceware.org; auth=none
- References: <805B52F4-1E7B-41D4-93AD-C7C913E604DC at lps dot ens dot fr> <55E5454A dot 3060509 at redhat dot com> <20150901092141 dot GA29491 at thyrsus dot com>
On 09/01/2015 05:21 AM, Eric S. Raymond wrote:
Jason Merrill <jason@redhat.com>:
Given git aliases:
stamp = show -s --format='%cI!%ce'
scommit = "!f(){ d=${1%%!*}; a=${1##*!}; arg=\"--until=$d -1\"; if [ $a != $1 ]; then arg=\"$arg --committer=$a\"; fi; shift; git rev-list $arg ${1:+\"$@\"}; }; f"
smaster = "!f(){ git scommit \"$1\" trunk --first-parent; }; f"
shs = "!f(){ git show $(git smaster $1); }; f"
slog = "!f(){ s=$1; shift; git log $(git smaster $s) $*; }; f"
sco = "!f(){ git checkout $(git smaster $1); }; f"
and an action stamp 2015-08-20T20:55:15Z!jason, then
git sco 2015-08-20T20:55:15Z\!jason
will check out the (most recent) commit with that stamp. It also works with
just the timestamp.
This is a corner of git of which I knew not. How does one set this sort of
alias? I Google...
Will git config --global alias.stamp = show -s --format='%cI!%ce
and analogous command lines work?
As Jonathan says, I was editing them directly into the [alias] section
of my ~/.gitconfig .
I think I understand what most of these are doing, but...you would be doing
a service to the world if you wrote a little shellscript that set these up,
with short explanatory comments reveraling what each is to be used for, like
this:
# sco - check out most recent commit with specified action stamp
I'd add that to the reposurgeon distribution in a heartbeat.
Here's an improved version:
# git stamp <commit-ish> - print a reposurgeon-style action stamp
stamp = show -s --format='%cI!%ce'
# git scommit <stamp> <rev-list-args> - list the most recent commit that matches <stamp>.
# Must also specify a branch to search or --all.
scommit = "!f(){ d=${1%%!*}; a=${1##*!}; arg=\"--until=$d -1\"; if [ $a != $1 ]; then arg=\"$arg --committer=$a\"; fi; shift; git rev-list $arg ${1:+\"$@\"}; }; f"
# git scommits <stamp> <rev-list-args> - as above, but list all matching commits.
scommits = "!f(){ d=${1%%!*}; a=${1##*!}; arg=\"--until=$d --after $d\"; if [ $a != $1 ]; then arg=\"$arg --committer=$a\"; fi; shift; git rev-list $arg ${1:+\"$@\"}; }; f"
# git smaster <stamp> - list the most recent commit on master that matches <stamp>.
smaster = "!f(){ git scommit \"$1\" master --first-parent; }; f"
smasters = "!f(){ git scommits \"$1\" master --first-parent; }; f"
# git shs <stamp> - show the commits on master that match <stamp>.
shs = "!f(){ stamp=$(git smasters $1); shift; git show ${stamp:?not found} $*; }; f"
# git slog <stamp> <log-args> - start git log at <stamp> on master
slog = "!f(){ stamp=$(git smaster $1); shift; git log ${stamp:?not found} $*; }; f"
# git sco <stamp> - check out the most recent commit on master that matches <stamp>.
sco = "!f(){ stamp=$(git smaster $1); shift; git checkout ${stamp:?not found} $*; }; f"
Jason