All of lore.kernel.org
 help / color / mirror / Atom feed
* compactionHeuristic=true is not used by interactive staging
@ 2016-06-14 14:22 Alex Prengère
  2016-06-14 21:42 ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Prengère @ 2016-06-14 14:22 UTC (permalink / raw)
  To: git

Hello,
I just did a fresh clone of git from Github and installed the version
2.9.0 on Fedora 22.

I tried the new compactionHeuristic = true, which is awesome.
The only thing that struck me was that this option was not used when
doing an interactive staging, meaning `git diff` and `git add -p` will
format patches differently. Perhaps this is intended and there is a
way to force interactive staging to use specific diff options, but I
did not find it in the doc.

Thanks,
Alex

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

* Re: compactionHeuristic=true is not used by interactive staging
  2016-06-14 14:22 compactionHeuristic=true is not used by interactive staging Alex Prengère
@ 2016-06-14 21:42 ` Jeff King
  2016-06-14 21:45   ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2016-06-14 21:42 UTC (permalink / raw)
  To: Alex Prengère; +Cc: git

On Tue, Jun 14, 2016 at 04:22:54PM +0200, Alex Prengère wrote:

> Hello,
> I just did a fresh clone of git from Github and installed the version
> 2.9.0 on Fedora 22.
> 
> I tried the new compactionHeuristic = true, which is awesome.
> The only thing that struck me was that this option was not used when
> doing an interactive staging, meaning `git diff` and `git add -p` will
> format patches differently. Perhaps this is intended and there is a
> way to force interactive staging to use specific diff options, but I
> did not find it in the doc.

That's because it's handled in the "UI config", and plumbing commands
are not affected (and "add -p" is built on plumbing commands). The same
is true of diff.algorithm, for instance.

To make this work, add--interactive would have to manually enable
particular options that it thinks it can handle (and in fact this is
done with diff.algorithm already). So we'd need a patch similar to
2cc0f53 (add--interactive: respect diff.algorithm, 2013-06-12).

Nobody noticed so far because originally the compaction heuristic was on
by default, and so just worked everywhere. But we backed off on that at
the last minute after finding a few cases where the diff looks worse.

-Peff

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

* Re: compactionHeuristic=true is not used by interactive staging
  2016-06-14 21:42 ` Jeff King
@ 2016-06-14 21:45   ` Junio C Hamano
  2016-06-15  6:24     ` Alex Prengère
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2016-06-14 21:45 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Prengère, git

Jeff King <peff@peff.net> writes:

> Nobody noticed so far because originally the compaction heuristic was on
> by default, and so just worked everywhere. But we backed off on that at
> the last minute after finding a few cases where the diff looks worse.

Yup, and that is why this is called "experimental" in the release
notes ;-)

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

* Re: compactionHeuristic=true is not used by interactive staging
  2016-06-14 21:45   ` Junio C Hamano
@ 2016-06-15  6:24     ` Alex Prengère
  2016-06-16 12:27       ` [PATCH] add--interactive: respect diff.compactionHeuristic Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Prengère @ 2016-06-15  6:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, git

I see, it makes sense ;-) Indeed it would seem logical to have all
commands showing diffs (diff, add -p, log -p, reset -p, etc..) respect
the diff options.

Thanks for your quick answer!

2016-06-14 23:45 GMT+02:00 Junio C Hamano <gitster@pobox.com>:
> Jeff King <peff@peff.net> writes:
>
>> Nobody noticed so far because originally the compaction heuristic was on
>> by default, and so just worked everywhere. But we backed off on that at
>> the last minute after finding a few cases where the diff looks worse.
>
> Yup, and that is why this is called "experimental" in the release
> notes ;-)

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

* [PATCH] add--interactive: respect diff.compactionHeuristic
  2016-06-15  6:24     ` Alex Prengère
@ 2016-06-16 12:27       ` Jeff King
  2016-06-16 16:50         ` Stefan Beller
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2016-06-16 12:27 UTC (permalink / raw)
  To: Alex Prengère; +Cc: Junio C Hamano, git

On Wed, Jun 15, 2016 at 08:24:47AM +0200, Alex Prengère wrote:

> I see, it makes sense ;-) Indeed it would seem logical to have all
> commands showing diffs (diff, add -p, log -p, reset -p, etc..) respect
> the diff options.

Here's a patch to do so, similar to what we do for diff.algorithm.

-- >8 --
Subject: add--interactive: respect diff.compactionHeuristic

We use plumbing to generate the diff, so it doesn't
automatically pick up UI config like compactionHeuristic.
Let's forward it on, since interactive adding is porcelain.

Note that we only need to handle the "true" case. There's no
point in passing --no-compaction-heuristic when the variable
is false, since nothing else could have turned it on.

Signed-off-by: Jeff King <peff@peff.net>
---
 git-add--interactive.perl | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 822f857..642cce1 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -45,6 +45,7 @@ my ($diff_new_color) =
 my $normal_color = $repo->get_color("", "reset");
 
 my $diff_algorithm = $repo->config('diff.algorithm');
+my $diff_compaction_heuristic = $repo->config_bool('diff.compactionheuristic');
 my $diff_filter = $repo->config('interactive.difffilter');
 
 my $use_readkey = 0;
@@ -749,6 +750,9 @@ sub parse_diff {
 	if (defined $diff_algorithm) {
 		splice @diff_cmd, 1, 0, "--diff-algorithm=${diff_algorithm}";
 	}
+	if ($diff_compaction_heuristic) {
+		splice @diff_cmd, 1, 0, "--compaction-heuristic";
+	}
 	if (defined $patch_mode_revision) {
 		push @diff_cmd, get_diff_reference($patch_mode_revision);
 	}
-- 
2.9.0.160.g4984cba


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

* Re: [PATCH] add--interactive: respect diff.compactionHeuristic
  2016-06-16 12:27       ` [PATCH] add--interactive: respect diff.compactionHeuristic Jeff King
@ 2016-06-16 16:50         ` Stefan Beller
  2016-06-16 23:40           ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2016-06-16 16:50 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Prengère, Junio C Hamano, git

On Thu, Jun 16, 2016 at 5:27 AM, Jeff King <peff@peff.net> wrote:
> On Wed, Jun 15, 2016 at 08:24:47AM +0200, Alex Prengère wrote:
>
>> I see, it makes sense ;-) Indeed it would seem logical to have all
>> commands showing diffs (diff, add -p, log -p, reset -p, etc..) respect
>> the diff options.
>
> Here's a patch to do so, similar to what we do for diff.algorithm.
>
> -- >8 --
> Subject: add--interactive: respect diff.compactionHeuristic
>
> We use plumbing to generate the diff, so it doesn't
> automatically pick up UI config like compactionHeuristic.
> Let's forward it on, since interactive adding is porcelain.
>
> Note that we only need to handle the "true" case. There's no
> point in passing --no-compaction-heuristic when the variable
> is false, since nothing else could have turned it on.

because we don't want to implement --[no-]compaction-heuristic
as a command line switch to git-add?
Fine with me.

Stepping back and looking how the compaction heuristic turned out,
I think this is what we did not want to see, i.e. the need to bring it in
every command, but rather enable and release it. But we backed off
of the default-on, and now people may ask for the  --no-compaction-heuristic
in interactive add eventually, when they run into a corner case.

For now:
Reviewed-by: Stefan Beller <sbeller@google.com>

Thanks,
Stefan



>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  git-add--interactive.perl | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 822f857..642cce1 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -45,6 +45,7 @@ my ($diff_new_color) =
>  my $normal_color = $repo->get_color("", "reset");
>
>  my $diff_algorithm = $repo->config('diff.algorithm');
> +my $diff_compaction_heuristic = $repo->config_bool('diff.compactionheuristic');
>  my $diff_filter = $repo->config('interactive.difffilter');
>
>  my $use_readkey = 0;
> @@ -749,6 +750,9 @@ sub parse_diff {
>         if (defined $diff_algorithm) {
>                 splice @diff_cmd, 1, 0, "--diff-algorithm=${diff_algorithm}";
>         }
> +       if ($diff_compaction_heuristic) {
> +               splice @diff_cmd, 1, 0, "--compaction-heuristic";
> +       }
>         if (defined $patch_mode_revision) {
>                 push @diff_cmd, get_diff_reference($patch_mode_revision);
>         }
> --
> 2.9.0.160.g4984cba
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] add--interactive: respect diff.compactionHeuristic
  2016-06-16 16:50         ` Stefan Beller
@ 2016-06-16 23:40           ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2016-06-16 23:40 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Alex Prengère, Junio C Hamano, git

On Thu, Jun 16, 2016 at 09:50:45AM -0700, Stefan Beller wrote:

> > -- >8 --
> > Subject: add--interactive: respect diff.compactionHeuristic
> >
> > We use plumbing to generate the diff, so it doesn't
> > automatically pick up UI config like compactionHeuristic.
> > Let's forward it on, since interactive adding is porcelain.
> >
> > Note that we only need to handle the "true" case. There's no
> > point in passing --no-compaction-heuristic when the variable
> > is false, since nothing else could have turned it on.
> 
> because we don't want to implement --[no-]compaction-heuristic
> as a command line switch to git-add?
> Fine with me.

We could, but I don't think it is worth the effort (and anyway, it would
override the config :) ).

> Stepping back and looking how the compaction heuristic turned out,
> I think this is what we did not want to see, i.e. the need to bring it in
> every command, but rather enable and release it. But we backed off
> of the default-on, and now people may ask for the  --no-compaction-heuristic
> in interactive add eventually, when they run into a corner case.

Yeah, I'm not excited to be plumbing it through, especially if we just
end up flipping it on by default. But perhaps people would still want to
be able to do the opposite (turning it off for a specific case via the
config). I dunno.

> For now:
> Reviewed-by: Stefan Beller <sbeller@google.com>

Thanks.

-Peff

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

end of thread, other threads:[~2016-06-16 23:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 14:22 compactionHeuristic=true is not used by interactive staging Alex Prengère
2016-06-14 21:42 ` Jeff King
2016-06-14 21:45   ` Junio C Hamano
2016-06-15  6:24     ` Alex Prengère
2016-06-16 12:27       ` [PATCH] add--interactive: respect diff.compactionHeuristic Jeff King
2016-06-16 16:50         ` Stefan Beller
2016-06-16 23:40           ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.