git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Beat Bolli <dev+git@drbeat.li>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Beat Bolli <dev+git@drbeat.li>
Subject: [PATCH 2/2] contrib/git-jump: add mode commit
Date: Sat, 21 Dec 2019 12:38:46 +0100	[thread overview]
Message-ID: <20191221113846.169538-2-dev+git@drbeat.li> (raw)
In-Reply-To: <20191221113846.169538-1-dev+git@drbeat.li>

After committing, I often want to return to the place of the latest
change to continue my work. Add the new mode "commit" which does exactly
this.

Optional arguments are given to the "git show" call. So it's possible to
jump to changes of other commits than HEAD.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/git-jump/git-jump | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 776fa90f7f..e7192073c6 100644
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -9,6 +9,9 @@ The <mode> parameter is one of:
 
 diff: elements are diff hunks. Arguments are given to diff.
 
+commit: element are the hunks of a commit (default HEAD). Arguments are
+        given to git show.
+
 merge: elements are merge conflicts. Arguments are ignored.
 
 grep: elements are grep hits. Arguments are given to git grep or, if
@@ -27,6 +30,10 @@ mode_diff() {
 	git diff --no-prefix --relative "$@" | diff_to_quickfix
 }
 
+mode_commit() {
+	git show --no-prefix --relative "$@" | diff_to_quickfix
+}
+
 diff_to_quickfix() {
 	perl -ne '
 	if (m{^\+\+\+ (.*)}) { $file = $1; next }
-- 
2.21.0.1020.gf2820cf01a


  reply	other threads:[~2019-12-21 11:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21 11:38 [PATCH 1/2] contrib/git-jump: extract function diff_to_quickfix Beat Bolli
2019-12-21 11:38 ` Beat Bolli [this message]
2019-12-21 19:23   ` [PATCH 2/2] contrib/git-jump: add mode commit Jeff King
2019-12-22 12:47     ` Beat Bolli
2019-12-22 12:47       ` Beat Bolli

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

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

  git send-email \
    --in-reply-to=20191221113846.169538-2-dev+git@drbeat.li \
    --to=dev+git@drbeat.li \
    --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.
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 NNTP newsgroup(s).