Git development
 help / color / mirror / Atom feed
* [PATCH 1/1] git jump: support show
@ 2024-08-14 20:07 Geoffrey Thomas
  2024-08-14 21:10 ` Eric Sunshine
  2024-08-15  0:42 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: Geoffrey Thomas @ 2024-08-14 20:07 UTC (permalink / raw)
  To: git; +Cc: Geoffrey Thomas

This makes it easy to go to the changes in the latest commit, or a
previous named commit, to fix a bug and commit a fixup, to respond to
code review feedback, etc.

Signed-off-by: Geoffrey Thomas <geofft@ldpreload.com>
---
 contrib/git-jump/git-jump | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 47e0c557e6..6cf16e0f32 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -41,8 +41,10 @@ open_editor() {
 	esac
 }
 
-mode_diff() {
-	git diff --no-prefix --relative "$@" |
+do_diff() {
+	cmd=$1
+	shift
+	git "$cmd" --no-prefix --relative "$@" |
 	perl -ne '
 	if (m{^\+\+\+ (.*)}) { $file = $1; next }
 	defined($file) or next;
@@ -56,6 +58,14 @@ mode_diff() {
 	'
 }
 
+mode_diff() {
+	do_diff diff "$@"
+}
+
+mode_show() {
+	do_diff show "$@"
+}
+
 mode_merge() {
 	git ls-files -u "$@" |
 	perl -pe 's/^.*?\t//' |

base-commit: 25673b1c476756ec0587fb0596ab3c22b96dc52a
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] git jump: support show
  2024-08-14 20:07 [PATCH 1/1] git jump: support show Geoffrey Thomas
@ 2024-08-14 21:10 ` Eric Sunshine
  2024-08-15  0:42 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2024-08-14 21:10 UTC (permalink / raw)
  To: Geoffrey Thomas; +Cc: git

On Wed, Aug 14, 2024 at 4:07 PM Geoffrey Thomas <geofft@ldpreload.com> wrote:
> This makes it easy to go to the changes in the latest commit, or a
> previous named commit, to fix a bug and commit a fixup, to respond to
> code review feedback, etc.
>
> Signed-off-by: Geoffrey Thomas <geofft@ldpreload.com>
> ---
> diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
> @@ -41,8 +41,10 @@ open_editor() {
> -mode_diff() {
> -       git diff --no-prefix --relative "$@" |
> +do_diff() {
> +       cmd=$1
> +       shift
> +       git "$cmd" --no-prefix --relative "$@" |
>         perl -ne '
>         if (m{^\+\+\+ (.*)}) { $file = $1; next }
>         defined($file) or next;
> @@ -56,6 +58,14 @@ mode_diff() {
> +mode_diff() {
> +       do_diff diff "$@"
> +}
> +
> +mode_show() {
> +       do_diff show "$@"
> +}
> +

I'm not a git-jump user (indeed, I've never even looked at it), but
should this change be accompanied by corresponding updates to the
documentation in the README and usage statement emitted by the usage()
function in git-jump script?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] git jump: support show
  2024-08-14 20:07 [PATCH 1/1] git jump: support show Geoffrey Thomas
  2024-08-14 21:10 ` Eric Sunshine
@ 2024-08-15  0:42 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2024-08-15  0:42 UTC (permalink / raw)
  To: Geoffrey Thomas; +Cc: git

On Wed, Aug 14, 2024 at 04:07:09PM -0400, Geoffrey Thomas wrote:

> This makes it easy to go to the changes in the latest commit, or a
> previous named commit, to fix a bug and commit a fixup, to respond to
> code review feedback, etc.

One trouble with this approach is that you're analyzing a diff whose
endpoint is something other than the current working tree. So the line
numbers in the diff do not necessarily correspond to what you're going
to open in the editor.

For something like the changes in the latest commit, I'd usually do "git
jump diff HEAD^", which I think is strictly better than a "show" on the
latest commit.

For looking at older commits that doesn't work, though. And if they're
not _too_ old, then you've got a reasonable chance of ending up
somewhere useful. So I'm not opposed to this patch. As Eric mentioned,
we'd probably want an update to the README. And I think it should
mention the caveat that the post-image of the diff you're viewing won't
necessarily match the working tree.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-15  0:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14 20:07 [PATCH 1/1] git jump: support show Geoffrey Thomas
2024-08-14 21:10 ` Eric Sunshine
2024-08-15  0:42 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox