git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] contrib/git-jump: add mode commit

From
Beat Bolli <dev+git@drbeat.li>
Date
Dec 21, 2019, 11:38 UTC
Message-ID
<20191221113846.169538-2-dev+git@drbeat.li>
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
Previous: Beat BolliNext: Jeff King
Message 2 of 4 in “contrib/git-jump: extract function diff_to_quickfix”
  1. 1/2 contrib/git-jump: extract function diff_to_quickfixBeat Bolli, Dec 21, 2019
  2. 2/2 contrib/git-jump: add mode commitBeat Bolli, Dec 21, 2019
  3. Jeff KingDec 21, 2019
  4. Beat BolliDec 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.