{"thread":{"id":"52501","subject":"[PATCH 1/2] contrib/git-jump: extract function diff_to_quickfix","startedAt":"2019-12-21T11:39:21Z","lastAt":"2019-12-22T12:47:09Z","messageCount":4,"participants":["Beat Bolli","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"388707","messageId":"20191221113846.169538-1-dev+git@drbeat.li","threadId":"52501","inReplyTo":null,"subject":"[PATCH 1/2] contrib/git-jump: extract function diff_to_quickfix","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2019-12-21T11:38:45Z","receivedAt":"2019-12-21T11:39:21Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"In preparation for a new mode that will also jump to diff hunks, extract\nthe function that generates the quickfix list from a diff.\n\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\n contrib/git-jump/git-jump | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n mode change 100755 => 100644 contrib/git-jump/git-jump\n\ndiff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump\nold mode 100755\nnew mode 100644\nindex 931b0fe3a9..776fa90f7f\n--- a/contrib/git-jump/git-jump\n+++ b/contrib/git-jump/git-jump\n@@ -24,7 +24,10 @@ open_editor() {\n }\n \n mode_diff() {\n-\tgit diff --no-prefix --relative \"$@\" |\n+\tgit diff --no-prefix --relative \"$@\" | diff_to_quickfix\n+}\n+\n+diff_to_quickfix() {\n \tperl -ne '\n \tif (m{^\\+\\+\\+ (.*)}) { $file = $1; next }\n \tdefined($file) or next;\n-- \n2.21.0.1020.gf2820cf01a\n\n"},{"id":"388708","messageId":"20191221113846.169538-2-dev+git@drbeat.li","threadId":"52501","inReplyTo":"20191221113846.169538-1-dev+git@drbeat.li","subject":"[PATCH 2/2] contrib/git-jump: add mode commit","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2019-12-21T11:38:46Z","receivedAt":"2019-12-21T11:39:22Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"After committing, I often want to return to the place of the latest\nchange to continue my work. Add the new mode \"commit\" which does exactly\nthis.\n\nOptional arguments are given to the \"git show\" call. So it's possible to\njump to changes of other commits than HEAD.\n\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\n contrib/git-jump/git-jump | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump\nindex 776fa90f7f..e7192073c6 100644\n--- a/contrib/git-jump/git-jump\n+++ b/contrib/git-jump/git-jump\n@@ -9,6 +9,9 @@ The <mode> parameter is one of:\n \n diff: elements are diff hunks. Arguments are given to diff.\n \n+commit: element are the hunks of a commit (default HEAD). Arguments are\n+        given to git show.\n+\n merge: elements are merge conflicts. Arguments are ignored.\n \n grep: elements are grep hits. Arguments are given to git grep or, if\n@@ -27,6 +30,10 @@ mode_diff() {\n \tgit diff --no-prefix --relative \"$@\" | diff_to_quickfix\n }\n \n+mode_commit() {\n+\tgit show --no-prefix --relative \"$@\" | diff_to_quickfix\n+}\n+\n diff_to_quickfix() {\n \tperl -ne '\n \tif (m{^\\+\\+\\+ (.*)}) { $file = $1; next }\n-- \n2.21.0.1020.gf2820cf01a\n\n"},{"id":"388716","messageId":"20191221192348.GA3339249@coredump.intra.peff.net","threadId":"52501","inReplyTo":"20191221113846.169538-2-dev+git@drbeat.li","subject":"Re: [PATCH 2/2] contrib/git-jump: add mode commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-12-21T19:23:48Z","receivedAt":"2019-12-21T19:23:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Dec 21, 2019 at 12:38:46PM +0100, Beat Bolli wrote:\n\n> After committing, I often want to return to the place of the latest\n> change to continue my work. Add the new mode \"commit\" which does exactly\n> this.\n\nThat's one of my primary uses for git-jump, too. But you can already do\nthat by jumping to the diff of HEAD^. Which has the additional advantage\nthat it's a diff against the working tree. So if you did a partial\ncommit, the diff will include any leftover changes.\n\nSo I'm not opposed to this patch per se, given that it's not very many\nlines. But I'm not sure I see much advantage over \"git jump diff HEAD^\".\nIt's slightly less typing, but I already alias \"git jump diff\" since\nit's so long.\n\n> Optional arguments are given to the \"git show\" call. So it's possible to\n> jump to changes of other commits than HEAD.\n\nThis can also be done with \"git jump diff $commit^ $commit\". However,\nI've found that jumping based on older diffs is mostly useless, because\nthe line numbers at $commit and those in the working tree don't always\nmatch up (and inherently you're always jumping in the working tree\ncopy).\n\n-Peff\n"},{"id":"388794","messageId":"94d850de-cb73-e124-bced-4dc3f6b970a6@drbeat.li","threadId":"52501","inReplyTo":"20191221192348.GA3339249@coredump.intra.peff.net","subject":"Re: [PATCH 2/2] contrib/git-jump: add mode commit","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2019-12-22T12:47:00Z","receivedAt":"2019-12-22T12:47:09Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"On 21.12.19 20:23, Jeff King wrote:\n> On Sat, Dec 21, 2019 at 12:38:46PM +0100, Beat Bolli wrote:\n> \n>> After committing, I often want to return to the place of the latest\n>> change to continue my work. Add the new mode \"commit\" which does exactly\n>> this.\n> \n> That's one of my primary uses for git-jump, too. But you can already do\n> that by jumping to the diff of HEAD^. Which has the additional advantage\n> that it's a diff against the working tree. So if you did a partial\n> commit, the diff will include any leftover changes.\n> \n> So I'm not opposed to this patch per se, given that it's not very many\n> lines. But I'm not sure I see much advantage over \"git jump diff HEAD^\".\n> It's slightly less typing, but I already alias \"git jump diff\" since\n> it's so long.\n> \n>> Optional arguments are given to the \"git show\" call. So it's possible to\n>> jump to changes of other commits than HEAD.\n> \n> This can also be done with \"git jump diff $commit^ $commit\". However,\n> I've found that jumping based on older diffs is mostly useless, because\n> the line numbers at $commit and those in the working tree don't always\n> match up (and inherently you're always jumping in the working tree\n> copy).\n\nThanks, I didn't realize that git diff could just as well be used to\ngenerate the diff of an arbitrary commit. I have added this new shortcut\nto my bash aliases:\n\n    gjc() { git jump diff ${1:-HEAD}^ ${1:-HEAD}; }\n\n\nCheers, Beat\n"}]}