All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] mergetools/kdiff3: do not use --auto when diffing
@ 2013-05-09  9:13 David Aguilar
  2013-05-09  9:13 ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: David Aguilar @ 2013-05-09  9:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, John Keeping, Charles Bailey, Theodore Ts'o

The `kdiff3 --auto` help message is, "No GUI if all conflicts are auto-
solvable."  This flag was carried over from the original mergetool
commands.  diff_cmd() is for two-way comparisons only so remove the
superfluous flag.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
This one is not RFC; just a trivial fix.

 mergetools/kdiff3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mergetools/kdiff3 b/mergetools/kdiff3
index 28fead4..a30034f 100644
--- a/mergetools/kdiff3
+++ b/mergetools/kdiff3
@@ -1,5 +1,5 @@
 diff_cmd () {
-	"$merge_tool_path" --auto \
+	"$merge_tool_path" \
 		--L1 "$MERGED (A)" --L2 "$MERGED (B)" \
 		"$LOCAL" "$REMOTE" >/dev/null 2>&1
 }
-- 
1.8.3.rc1.38.g0f1704c

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

* [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09  9:13 [PATCH 1/3] mergetools/kdiff3: do not use --auto when diffing David Aguilar
@ 2013-05-09  9:13 ` David Aguilar
  2013-05-09  9:13   ` [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8 David Aguilar
  2013-05-09 16:10   ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges Junio C Hamano
  0 siblings, 2 replies; 11+ messages in thread
From: David Aguilar @ 2013-05-09  9:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, John Keeping, Charles Bailey, Theodore Ts'o

By default, "git mergetool" passes the `--auto` flag to `kdiff3` when
merging a file.  The `--auto` flag tells `kdiff3` to skip showing the
GUI and automatically save the merged result when it is able to
trivially resolve a merge.

Some users prefer to eyeball the merged result using mergetool and the
use of `--auto` prevents them from doing so.  Add a configuration
variable to allow opting-out of the auto-merge feature.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
Marked "RFC" because I am kinda against adding more configuration
variables.  Someone ran into this and I did personally find the
behavior a bit surprising.  Alternatively, we *could* change the
default behavior, but I am not convinced that doing so is a good idea
either, hence this patch.  Other then the "kinda against",
it does make the behavior less surprising.

 Documentation/merge-config.txt |  9 +++++++++
 mergetools/kdiff3              | 20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
index d78d6d8..3bd5f21 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -59,6 +59,15 @@ merge.tool::
 
 include::mergetools-merge.txt[]
 
+mergetool.kdiff3.manualMerge::
+	Tell Git that not to use `kdiff3`'s auto-merge feature.
+	By default, "git mergetool" passes the `--auto` flag to `kdiff3`
+	when merging a file.  The `--auto` flag tells `kdiff3` to skip
+	showing the GUI and automatically save the merged result when it
+	is able to trivially resolve a merge.  The `--auto` flag will
+	not be used when this variable is set to `true`.  False by
+	default.
+
 merge.verbosity::
 	Controls the amount of output shown by the recursive merge
 	strategy.  Level 0 outputs nothing except a final error
diff --git a/mergetools/kdiff3 b/mergetools/kdiff3
index a30034f..d0acda9 100644
--- a/mergetools/kdiff3
+++ b/mergetools/kdiff3
@@ -1,3 +1,18 @@
+kdiff3_initialized=
+kdiff3_args=--auto
+
+kdiff3_init () {
+	if test -n "$kdiff3_initialized"
+	then
+		return
+	fi
+	if test "$(git config --bool mergetool.kdiff3.manualMerge)" = true
+	then
+		kdiff3_args=
+	fi
+	kdiff3_initialized=true
+}
+
 diff_cmd () {
 	"$merge_tool_path" \
 		--L1 "$MERGED (A)" --L2 "$MERGED (B)" \
@@ -5,16 +20,17 @@ diff_cmd () {
 }
 
 merge_cmd () {
+	kdiff3_init
 	if $base_present
 	then
-		"$merge_tool_path" --auto \
+		"$merge_tool_path" $kdiff3_args \
 			--L1 "$MERGED (Base)" \
 			--L2 "$MERGED (Local)" \
 			--L3 "$MERGED (Remote)" \
 			-o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
 		>/dev/null 2>&1
 	else
-		"$merge_tool_path" --auto \
+		"$merge_tool_path" $kdiff3_args \
 			--L1 "$MERGED (Local)" \
 			--L2 "$MERGED (Remote)" \
 			-o "$MERGED" "$LOCAL" "$REMOTE" \
-- 
1.8.3.rc1.38.g0f1704c

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

* [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8
  2013-05-09  9:13 ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges David Aguilar
@ 2013-05-09  9:13   ` David Aguilar
  2013-05-09 15:14     ` John Keeping
  2013-05-09 16:10   ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: David Aguilar @ 2013-05-09  9:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, John Keeping, Charles Bailey, Theodore Ts'o

Mac OS X Mountain Lion prints warnings when building git:

	warning: 'SHA1_Init' is deprecated
	(declared at /usr/include/openssl/sha.h:121)

Silence the warnings by disabling OpenSSH in favor of BLK_SHA1.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
I know I can create config.mak, but do we prefer to have the default
settings be warning-free?  I do not see any other platforms that tweak
NO_OPENSSL themselves, hence "RFC".  Is there a better way to do this?
Are there any Darwin/PPC users that would be harmed by this patch?

 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 0f931a2..3bb9ac2 100644
--- a/Makefile
+++ b/Makefile
@@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)
 		endif
 	endif
 	PTHREAD_LIBS =
+	NO_OPENSSL = YesPlease
 endif
 
 ifndef CC_LD_DYNPATH
-- 
1.8.3.rc1.38.g0f1704c

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

* Re: [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8
  2013-05-09  9:13   ` [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8 David Aguilar
@ 2013-05-09 15:14     ` John Keeping
  2013-05-09 23:21       ` David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: John Keeping @ 2013-05-09 15:14 UTC (permalink / raw)
  To: David Aguilar; +Cc: git, Junio C Hamano, Charles Bailey, Theodore Ts'o

On Thu, May 09, 2013 at 02:13:30AM -0700, David Aguilar wrote:
> Mac OS X Mountain Lion prints warnings when building git:
> 
> 	warning: 'SHA1_Init' is deprecated
> 	(declared at /usr/include/openssl/sha.h:121)
> 
> Silence the warnings by disabling OpenSSH in favor of BLK_SHA1.
> 
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
> I know I can create config.mak, but do we prefer to have the default
> settings be warning-free?  I do not see any other platforms that tweak
> NO_OPENSSL themselves, hence "RFC".  Is there a better way to do this?
> Are there any Darwin/PPC users that would be harmed by this patch?

Disabling OpenSSL also has the effect of disabling SSL support in
git-imap-send.  Does enabling BLK_SHA1 instead also remove the warnings?

Alternatively, it seems that the recommended update is to use Apple's
CommonCrypto library, as in this patch:
https://gist.github.com/anonymous/4466305

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09  9:13 ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges David Aguilar
  2013-05-09  9:13   ` [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8 David Aguilar
@ 2013-05-09 16:10   ` Junio C Hamano
  2013-05-09 17:23     ` John Keeping
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2013-05-09 16:10 UTC (permalink / raw)
  To: David Aguilar; +Cc: git, John Keeping, Charles Bailey, Theodore Ts'o

David Aguilar <davvid@gmail.com> writes:

> Marked "RFC" because I am kinda against adding more configuration
> variables.

Just like "git merge" has -X<option> escape hatch to allow us to
pass backend-specific options, perhaps you can add a mechanism to
"git mergetool" to let the user pass --no-auto from the command
line?

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09 16:10   ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges Junio C Hamano
@ 2013-05-09 17:23     ` John Keeping
  2013-05-09 19:15       ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: John Keeping @ 2013-05-09 17:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Aguilar, git, Charles Bailey, Theodore Ts'o

On Thu, May 09, 2013 at 09:10:51AM -0700, Junio C Hamano wrote:
> David Aguilar <davvid@gmail.com> writes:
> 
> > Marked "RFC" because I am kinda against adding more configuration
> > variables.
> 
> Just like "git merge" has -X<option> escape hatch to allow us to
> pass backend-specific options, perhaps you can add a mechanism to
> "git mergetool" to let the user pass --no-auto from the command
> line?

We already have "mergetool.<tool>.cmd" which allows a completely custom
command line to be specified.  IIUC this can be used to override the
built-in command for tool names that already exist.

I'm not sure an extra -X<option> buys us much on top of this, but
perhaps it would be useful for one-off usage.

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09 17:23     ` John Keeping
@ 2013-05-09 19:15       ` Junio C Hamano
  2013-05-09 22:17         ` David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2013-05-09 19:15 UTC (permalink / raw)
  To: John Keeping; +Cc: David Aguilar, git, Charles Bailey, Theodore Ts'o

John Keeping <john@keeping.me.uk> writes:

> On Thu, May 09, 2013 at 09:10:51AM -0700, Junio C Hamano wrote:
>> David Aguilar <davvid@gmail.com> writes:
>> 
>> > Marked "RFC" because I am kinda against adding more configuration
>> > variables.
>> 
>> Just like "git merge" has -X<option> escape hatch to allow us to
>> pass backend-specific options, perhaps you can add a mechanism to
>> "git mergetool" to let the user pass --no-auto from the command
>> line?
>
> We already have "mergetool.<tool>.cmd" which allows a completely custom
> command line to be specified.

Then probably it is a good idea to drop this patch and replace it
with a documentation patch to suggest those who do not want --auto
to use that mechanism?

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09 19:15       ` Junio C Hamano
@ 2013-05-09 22:17         ` David Aguilar
  2013-05-10  5:41           ` Charles Bailey
  0 siblings, 1 reply; 11+ messages in thread
From: David Aguilar @ 2013-05-09 22:17 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: John Keeping, Git Mailing List, Charles Bailey, Theodore Ts'o

On Thu, May 9, 2013 at 12:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
> John Keeping <john@keeping.me.uk> writes:
>
>> On Thu, May 09, 2013 at 09:10:51AM -0700, Junio C Hamano wrote:
>>> David Aguilar <davvid@gmail.com> writes:
>>>
>>> > Marked "RFC" because I am kinda against adding more configuration
>>> > variables.
>>>
>>> Just like "git merge" has -X<option> escape hatch to allow us to
>>> pass backend-specific options, perhaps you can add a mechanism to
>>> "git mergetool" to let the user pass --no-auto from the command
>>> line?
>>
>> We already have "mergetool.<tool>.cmd" which allows a completely custom
>> command line to be specified.
>
> Then probably it is a good idea to drop this patch and replace it
> with a documentation patch to suggest those who do not want --auto
> to use that mechanism?

Generally, "mergetool.<tool>.cmd" is not general enough since we've
always special cased the base vs. no-base code paths and we run
different commands depending on whether a base is available.

It might make sense to extend that mechanism to allow
"mergetool.<tool>.merge2cmd" for the no-base form and allow .cmd to
remain as-is for the full 3-arg base form, but IMO that's an even
worse solution for the end user as they now need to configure two
separate variables and know all the intimate details about how to
configure it.  OTOH, a boolean git configuration flag is much easier
and simpler for the user.

The -X--no-auto idea could work, but I was hoping for a "set once and
forget" fix I could hand to a user, which would remove the need for
such a feature.

Here's the background behind why I wrote this patch -- yesterday
someone at work asked, "does git mergetool not work with stash?"  This
caught me by surprise, "yes, of course it does", I replied, but they
showed me a case where the behavior was confusing.

They had done "git stash && git pull --rebase && git stash pop".  That
last pop created a merge conflict in one file.

They then ran "git mergetool" to resolve the merge but they never saw
the GUI and their changes were automatically staged.  From a user's
POV this is unintuitive and confusing behavior because they were
expecting to run kdiff3, but instead it silently staged the file with
kdiff3's auto-merged result.

We could drop --auto altogether, which maybe is a better course of
action since it makes the behavior predictable and un-surprising, but
I do not know if anyone has come to rely on kdiff3's "auto-merge"
feature (hence the extended Cc: list).

Because I do not know exactly why "kdiff3" thinks these are "trivial
merges" it can resolve while "git stash pop" disagrees and cannot
trivially merge them, I seems that dropping "--auto" really may be the
better choice all around.  In general, git tries to be extremely
careful and defers to the user in the face of ambiguity.  Dropping
--auto would make sense from that POV since kdiff3 is preventing the
user from inspecting the result.

In other words, if there are no strong reasons to keep --auto then I
would not be opposed to changing the default.  OTOH if there are users
that want it and some that don't, then the config variable is helpful,
and maybe it can be flipped the other way:  call it
"mergetool.kdiff3.autoMerge", keep it False today, and maybe change
the default to True with Git 2.0.

But I would really prefer no configuration and the most intuitive and
least-surprising behavior.  I think I've convinced myself that
dropping --auto altogether could accomplish this, but I do not want to
pull the rug out from under existing users, *if they exist*.  If
everyone in this discussion is in the camp of, "I didn't even know it
worked that way" then changing the behavior is not so big a deal and
we can do without extra variables.

Would it be acceptable for me to rework this patch to drop --auto altogether?
--
David

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

* Re: [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8
  2013-05-09 15:14     ` John Keeping
@ 2013-05-09 23:21       ` David Aguilar
  0 siblings, 0 replies; 11+ messages in thread
From: David Aguilar @ 2013-05-09 23:21 UTC (permalink / raw)
  To: John Keeping
  Cc: Git Mailing List, Junio C Hamano, Charles Bailey, Theodore Ts'o

On Thu, May 9, 2013 at 8:14 AM, John Keeping <john@keeping.me.uk> wrote:
> On Thu, May 09, 2013 at 02:13:30AM -0700, David Aguilar wrote:
>> Mac OS X Mountain Lion prints warnings when building git:
>>
>>       warning: 'SHA1_Init' is deprecated
>>       (declared at /usr/include/openssl/sha.h:121)
>>
>> Silence the warnings by disabling OpenSSH in favor of BLK_SHA1.
>>
>> Signed-off-by: David Aguilar <davvid@gmail.com>
>> ---
>> I know I can create config.mak, but do we prefer to have the default
>> settings be warning-free?  I do not see any other platforms that tweak
>> NO_OPENSSL themselves, hence "RFC".  Is there a better way to do this?
>> Are there any Darwin/PPC users that would be harmed by this patch?
>
> Disabling OpenSSL also has the effect of disabling SSL support in
> git-imap-send.  Does enabling BLK_SHA1 instead also remove the warnings?

Thanks.  Yes, setting BLK_SHA1 does eliminate the warnings.

I'll re-roll this patch and send it independently.
It's unrelated to the mergetool stuff so apologies for the wide
initial Cc: list.

> Alternatively, it seems that the recommended update is to use Apple's
> CommonCrypto library, as in this patch:
> https://gist.github.com/anonymous/4466305

It seems like we'd want something like this in compat-util.h or
somewhere similar.  That'll be a bigger change so I'll try the
BLK_SHA1 approach first since it is minimally invasive.  This would be
nice to tackle once the dust has settled a bit.
--
David

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-09 22:17         ` David Aguilar
@ 2013-05-10  5:41           ` Charles Bailey
  2013-05-10 18:40             ` David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: Charles Bailey @ 2013-05-10  5:41 UTC (permalink / raw)
  To: David Aguilar
  Cc: Junio C Hamano, John Keeping, Git Mailing List, Theodore Ts'o

On Thu, May 09, 2013 at 03:17:30PM -0700, David Aguilar wrote:
> Generally, "mergetool.<tool>.cmd" is not general enough since we've
> always special cased the base vs. no-base code paths and we run
> different commands depending on whether a base is available.

Then this is a deficiency of the ".cmd" mechanism which should provide
an "if all else fails" way to do things, even if ugly. We could simply
add a BASELESS variable to the eval environment of the custom command.
(Do we always create an empty file for $BASE, now?)

> We could drop --auto altogether, which maybe is a better course of
> action since it makes the behavior predictable and un-surprising, but
> I do not know if anyone has come to rely on kdiff3's "auto-merge"
> feature (hence the extended Cc: list).

I disagree, I think that a mergetool should be allowed to be as
helpful as possible and if it can resolve the merge unaided then this
is no bad thing. I've worked with a number of people who were very
happy with the current kdiff3 behaviour. Nothing prevents you from
verifying the merge and fixing it up if it wasn't done perfectly by
the tool, although I haven't ever encountered this with git+kdiff3.

Charles.

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

* Re: [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges
  2013-05-10  5:41           ` Charles Bailey
@ 2013-05-10 18:40             ` David Aguilar
  0 siblings, 0 replies; 11+ messages in thread
From: David Aguilar @ 2013-05-10 18:40 UTC (permalink / raw)
  To: Charles Bailey
  Cc: Junio C Hamano, John Keeping, Git Mailing List, Theodore Ts'o

On Thu, May 9, 2013 at 10:41 PM, Charles Bailey <charles@hashpling.org> wrote:
> On Thu, May 09, 2013 at 03:17:30PM -0700, David Aguilar wrote:
>> Generally, "mergetool.<tool>.cmd" is not general enough since we've
>> always special cased the base vs. no-base code paths and we run
>> different commands depending on whether a base is available.
>
> Then this is a deficiency of the ".cmd" mechanism which should provide
> an "if all else fails" way to do things, even if ugly. We could simply
> add a BASELESS variable to the eval environment of the custom command.
> (Do we always create an empty file for $BASE, now?)
>
>> We could drop --auto altogether, which maybe is a better course of
>> action since it makes the behavior predictable and un-surprising, but
>> I do not know if anyone has come to rely on kdiff3's "auto-merge"
>> feature (hence the extended Cc: list).
>
> I disagree, I think that a mergetool should be allowed to be as
> helpful as possible and if it can resolve the merge unaided then this
> is no bad thing. I've worked with a number of people who were very
> happy with the current kdiff3 behaviour. Nothing prevents you from
> verifying the merge and fixing it up if it wasn't done perfectly by
> the tool, although I haven't ever encountered this with git+kdiff3.

That's the bit of info I was needing.

I can always tell the one person who ran into this that "that's how it
is" and explain why it's a good thing.

"one person" < "number of people" so it's an easy decision, and we
don't need to make the tool worse to cater to someone that's new to
git.

Thanks Charles,
--
David

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

end of thread, other threads:[~2013-05-10 18:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09  9:13 [PATCH 1/3] mergetools/kdiff3: do not use --auto when diffing David Aguilar
2013-05-09  9:13 ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges David Aguilar
2013-05-09  9:13   ` [RFC PATCH 3/3] Makefile: avoid deprecation warnings on OS X 10.8 David Aguilar
2013-05-09 15:14     ` John Keeping
2013-05-09 23:21       ` David Aguilar
2013-05-09 16:10   ` [RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges Junio C Hamano
2013-05-09 17:23     ` John Keeping
2013-05-09 19:15       ` Junio C Hamano
2013-05-09 22:17         ` David Aguilar
2013-05-10  5:41           ` Charles Bailey
2013-05-10 18:40             ` David Aguilar

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.