This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Action stamps


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]