git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: peff@peff.net
Subject: [PATCH 1/1] contrib/git-jump/git-jump: support alias expansion
Date: Wed, 4 Sep 2019 13:55:03 -0400	[thread overview]
Message-ID: <473a7c7b241ad2d449d3bcb6daeb77a179c7e45f.1567619579.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1567619579.git.me@ttaylorr.com>

When a caller of 'git-jump' has, say, the alias 'di' assigned to 'diff',
it can be cumbersome to remember to type 'git jump diff' instead of the
shorthand '... di' that they are used to.

Let's teach 'git-jump' to expand these aliases before calling the
mode-specific subroutine. Do so by fetching the configuration value of
'alias.$1', defaulting to "$1" in the case that no alias is set.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 contrib/git-jump/README   | 4 ++++
 contrib/git-jump/git-jump | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/git-jump/README b/contrib/git-jump/README
index 2f618a7f97..9e59990ba0 100644
--- a/contrib/git-jump/README
+++ b/contrib/git-jump/README
@@ -74,6 +74,10 @@ git jump grep -i foo_bar
 
 # use the silver searcher for git jump grep
 git config jump.grepCmd "ag --column"
+
+# jump to changes via an alias of 'git diff', assuming you have set
+# `git config alias.diff di`
+git jump di
 --------------------------------------------------
 
 
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 931b0fe3a9..15e129b350 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -15,6 +15,8 @@ grep: elements are grep hits. Arguments are given to git grep or, if
       configured, to the command in `jump.grepCmd`.
 
 ws: elements are whitespace errors. Arguments are given to diff --check.
+
+Aliases of any of the above are expanded automatically.
 EOF
 }
 
@@ -68,7 +70,7 @@ if test $# -lt 1; then
 	usage >&2
 	exit 1
 fi
-mode=$1; shift
+mode="$(git config --default "$1" --get -- "alias.$1")"; shift
 
 trap 'rm -f "$tmp"' 0 1 2 3 15
 tmp=`mktemp -t git-jump.XXXXXX` || exit 1
-- 
2.22.0

  reply	other threads:[~2019-09-04 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 17:55 [PATCH 0/1] contrib/git-jump: support alias expansion Taylor Blau
2019-09-04 17:55 ` Taylor Blau [this message]
2019-09-04 20:51   ` [PATCH 1/1] contrib/git-jump/git-jump: " Taylor Blau
2019-09-05  6:04 ` [PATCH 0/1] contrib/git-jump: " Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=473a7c7b241ad2d449d3bcb6daeb77a179c7e45f.1567619579.git.me@ttaylorr.com \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).