git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-jump: pass "merge" arguments to ls-files
@ 2021-11-09 16:35 Jeff King
  2021-11-09 16:46 ` Taylor Blau
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2021-11-09 16:35 UTC (permalink / raw)
  To: git

We currently throw away any arguments given to "git jump merge". We
should instead pass them along to ls-files, since they're likely to be
pathspecs. This matches the behavior of "git jump diff", etc.

Signed-off-by: Jeff King <peff@peff.net>
---
Just a little wart I noticed while doing a really tricky merge today.

 contrib/git-jump/README   | 3 +++
 contrib/git-jump/git-jump | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/contrib/git-jump/README b/contrib/git-jump/README
index 2f618a7f97..8bcace29d2 100644
--- a/contrib/git-jump/README
+++ b/contrib/git-jump/README
@@ -65,6 +65,9 @@ git jump diff --cached
 # jump to merge conflicts
 git jump merge
 
+# documentation conflicts are hard; skip past them for now
+git jump merge :^Documentation
+
 # jump to all instances of foo_bar
 git jump grep foo_bar
 
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 931b0fe3a9..92dbd4cde1 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -39,7 +39,7 @@ mode_diff() {
 }
 
 mode_merge() {
-	git ls-files -u |
+	git ls-files -u "$@" |
 	perl -pe 's/^.*?\t//' |
 	sort -u |
 	while IFS= read fn; do
-- 
2.34.0.rc1.634.g85d556ea55

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

* Re: [PATCH] git-jump: pass "merge" arguments to ls-files
  2021-11-09 16:35 [PATCH] git-jump: pass "merge" arguments to ls-files Jeff King
@ 2021-11-09 16:46 ` Taylor Blau
  2021-11-09 17:27   ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Taylor Blau @ 2021-11-09 16:46 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Tue, Nov 09, 2021 at 11:35:47AM -0500, Jeff King wrote:
> We currently throw away any arguments given to "git jump merge". We
> should instead pass them along to ls-files, since they're likely to be
> pathspecs. This matches the behavior of "git jump diff", etc.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> Just a little wart I noticed while doing a really tricky merge today.

This is hilarious to me, because I wrote the exact same patch to skip
some conflicts while resolving what I can only assume is the same merge.

> diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
> index 931b0fe3a9..92dbd4cde1 100755
> --- a/contrib/git-jump/git-jump
> +++ b/contrib/git-jump/git-jump
> @@ -39,7 +39,7 @@ mode_diff() {
>  }
>
>  mode_merge() {
> -	git ls-files -u |
> +	git ls-files -u "$@" |

It's kind of unfortunate (maybe not?) that a caller could now run:

    git jump merge --no-unmerged

and get the same results albeit *much* slower. We could limit ourselves
to only accepting pathspecs (by writing `git ls-files -u -- "$@"`), but
that feels overly restrictive. We could also say `"$@" -u`, but that
breaks if the caller writes `--` or `--end-of-options`.

So I think that what you and I both wrote is least bad, but it does make
me cringe a little bit at being able to pass `--no-unmerged` to `git
jump merge`.

Anyway, I know that it's late in the -rc cycle, but I'd be happy to see
something like this get picked up once Junio tags 2.34 and we have
stabilized a little bit.

Thanks,
Taylor

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

* Re: [PATCH] git-jump: pass "merge" arguments to ls-files
  2021-11-09 16:46 ` Taylor Blau
@ 2021-11-09 17:27   ` Jeff King
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2021-11-09 17:27 UTC (permalink / raw)
  To: Taylor Blau; +Cc: git

On Tue, Nov 09, 2021 at 11:46:26AM -0500, Taylor Blau wrote:

> On Tue, Nov 09, 2021 at 11:35:47AM -0500, Jeff King wrote:
> > We currently throw away any arguments given to "git jump merge". We
> > should instead pass them along to ls-files, since they're likely to be
> > pathspecs. This matches the behavior of "git jump diff", etc.
> >
> > Signed-off-by: Jeff King <peff@peff.net>
> > ---
> > Just a little wart I noticed while doing a really tricky merge today.
> 
> This is hilarious to me, because I wrote the exact same patch to skip
> some conflicts while resolving what I can only assume is the same merge.

It's possible. :)

> >  mode_merge() {
> > -	git ls-files -u |
> > +	git ls-files -u "$@" |
> 
> It's kind of unfortunate (maybe not?) that a caller could now run:
> 
>     git jump merge --no-unmerged
> 
> and get the same results albeit *much* slower. We could limit ourselves
> to only accepting pathspecs (by writing `git ls-files -u -- "$@"`), but
> that feels overly restrictive. We could also say `"$@" -u`, but that
> breaks if the caller writes `--` or `--end-of-options`.

Yeah. With "git jump diff" and "git jump grep", it's an explicit feature
that we allow extra arguments. That's less likely here, though you could
perhaps do something clever with --recurse-submodules, etc. And while
you could royally screw things up with "--no-unmerged", I think this is
a case of "if it hurts, don't do it".

> Anyway, I know that it's late in the -rc cycle, but I'd be happy to see
> something like this get picked up once Junio tags 2.34 and we have
> stabilized a little bit.

Yeah, obviously no rush at all on this.

-Peff

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

end of thread, other threads:[~2021-11-09 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-09 16:35 [PATCH] git-jump: pass "merge" arguments to ls-files Jeff King
2021-11-09 16:46 ` Taylor Blau
2021-11-09 17:27   ` Jeff King

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).