All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow the user to change the temporary file name for mergetool
@ 2014-08-19 12:22 Robin Rosenberg
  2014-08-19 12:52 ` Stefan Näwe
  0 siblings, 1 reply; 12+ messages in thread
From: Robin Rosenberg @ 2014-08-19 12:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Robin Rosenberg

Using the original filename suffix for the temporary input files to
the merge tool confuses IDEs like Eclipse. This patch introduces
a configurtion option, mergetool.tmpsuffix, which get appended to
the temporary file name. That way the user can choose to use a
suffix like ".tmp", which does not cause confusion.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 Documentation/git-mergetool.txt |  7 +++++++
 git-mergetool.sh                | 10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..a586766 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
 causes `git mergetool` to automatically remove the backup as files
 are successfully merged.
 
+`git mergetool` may also create other temporary files for the
+different versions involved in the merge. By default these files have
+the same filename suffix as the file being merged. This may confuse
+other tools in use during a long merge operation. The user can set
+`mergtool.tmpsuffix` to be used as an extra suffix, which will be
+appened to the temporary filenamame to lessen that problem.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 9a046b7..d7cc76c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -214,6 +214,8 @@ checkout_staged_file () {
 }
 
 merge_file () {
+	tmpsuffix=$(git config mergetool.tmpsuffix || true)
+
 	MERGED="$1"
 
 	f=$(git ls-files -u -- "$MERGED")
@@ -229,10 +231,10 @@ merge_file () {
 	fi
 
 	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
-	BACKUP="./$MERGED.BACKUP.$ext"
-	LOCAL="./$MERGED.LOCAL.$ext"
-	REMOTE="./$MERGED.REMOTE.$ext"
-	BASE="./$MERGED.BASE.$ext"
+	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
+	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
+	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
+	BASE="./$MERGED.BASE.$ext$tmpsuffix"
 
 	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
 	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
-- 
2.1.0.rc2.6.g39c33ff.dirty

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

* Re: [PATCH] Allow the user to change the temporary file name for mergetool
  2014-08-19 12:22 [PATCH] Allow the user to change the temporary file name for mergetool Robin Rosenberg
@ 2014-08-19 12:52 ` Stefan Näwe
  2014-08-19 14:55   ` [PATCH v2] " Robin Rosenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Näwe @ 2014-08-19 12:52 UTC (permalink / raw)
  To: Robin Rosenberg, Junio C Hamano; +Cc: git

Am 19.08.2014 um 14:22 schrieb Robin Rosenberg:
> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.
> 
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
>  Documentation/git-mergetool.txt |  7 +++++++
>  git-mergetool.sh                | 10 ++++++----
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
> index e846c2e..a586766 100644
> --- a/Documentation/git-mergetool.txt
> +++ b/Documentation/git-mergetool.txt
> @@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
>  causes `git mergetool` to automatically remove the backup as files
>  are successfully merged.
>  
> +`git mergetool` may also create other temporary files for the
> +different versions involved in the merge. By default these files have
> +the same filename suffix as the file being merged. This may confuse
> +other tools in use during a long merge operation. The user can set
> +`mergtool.tmpsuffix` to be used as an extra suffix, which will be

s/mergtool/mergetool/

> +appened to the temporary filenamame to lessen that problem.

s/appened/appended/
s/filenamame/filename/

> +
>  GIT
>  ---
>  Part of the linkgit:git[1] suite
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 9a046b7..d7cc76c 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -214,6 +214,8 @@ checkout_staged_file () {
>  }
>  
>  merge_file () {
> +	tmpsuffix=$(git config mergetool.tmpsuffix || true)
> +
>  	MERGED="$1"
>  
>  	f=$(git ls-files -u -- "$MERGED")
> @@ -229,10 +231,10 @@ merge_file () {
>  	fi
>  
>  	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
> -	BACKUP="./$MERGED.BACKUP.$ext"
> -	LOCAL="./$MERGED.LOCAL.$ext"
> -	REMOTE="./$MERGED.REMOTE.$ext"
> -	BASE="./$MERGED.BASE.$ext"
> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"
>  
>  	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
>  	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
> 

Stefan
-- 
----------------------------------------------------------------
/dev/random says: Confusion not only reigns, it pours.
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" 
GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF

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

* [PATCH v2] Allow the user to change the temporary file name for mergetool
  2014-08-19 12:52 ` Stefan Näwe
@ 2014-08-19 14:55   ` Robin Rosenberg
  2014-08-19 17:02     ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Robin Rosenberg @ 2014-08-19 14:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Robin Rosenberg

Using the original filename suffix for the temporary input files to
the merge tool confuses IDEs like Eclipse. This patch introduces
a configurtion option, mergetool.tmpsuffix, which get appended to
the temporary file name. That way the user can choose to use a
suffix like ".tmp", which does not cause confusion.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 Documentation/git-mergetool.txt |  7 +++++++
 git-mergetool.sh                | 10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..80a0526 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
 causes `git mergetool` to automatically remove the backup as files
 are successfully merged.
 
+`git mergetool` may also create other temporary files for the
+different versions involved in the merge. By default these files have
+the same filename suffix as the file being merged. This may confuse
+other tools in use during a long merge operation. The user can set
+`mergetool.tmpsuffix` to be used as an extra suffix, which will be
+appened to the temporary filename to lessen that problem.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 9a046b7..d7cc76c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -214,6 +214,8 @@ checkout_staged_file () {
 }
 
 merge_file () {
+	tmpsuffix=$(git config mergetool.tmpsuffix || true)
+
 	MERGED="$1"
 
 	f=$(git ls-files -u -- "$MERGED")
@@ -229,10 +231,10 @@ merge_file () {
 	fi
 
 	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
-	BACKUP="./$MERGED.BACKUP.$ext"
-	LOCAL="./$MERGED.LOCAL.$ext"
-	REMOTE="./$MERGED.REMOTE.$ext"
-	BASE="./$MERGED.BASE.$ext"
+	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
+	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
+	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
+	BASE="./$MERGED.BASE.$ext$tmpsuffix"
 
 	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
 	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
-- 
2.1.0.rc2.6.g39c33ff.dirty

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

* Re: [PATCH v2] Allow the user to change the temporary file name for mergetool
  2014-08-19 14:55   ` [PATCH v2] " Robin Rosenberg
@ 2014-08-19 17:02     ` Junio C Hamano
  2014-08-19 17:15       ` [PATCH v3] " Robin Rosenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2014-08-19 17:02 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Robin Rosenberg <robin.rosenberg@dewire.com> writes:

> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.
>
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
>  Documentation/git-mergetool.txt |  7 +++++++
>  git-mergetool.sh                | 10 ++++++----
>  2 files changed, 13 insertions(+), 4 deletions(-)

No updates to Documentation/config.txt to describe the new variable?

>
> diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
> index e846c2e..80a0526 100644
> --- a/Documentation/git-mergetool.txt
> +++ b/Documentation/git-mergetool.txt
> @@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
>  causes `git mergetool` to automatically remove the backup as files
>  are successfully merged.
>  
> +`git mergetool` may also create other temporary files for the
> +different versions involved in the merge. By default these files have
> +the same filename suffix as the file being merged. This may confuse
> +other tools in use during a long merge operation. The user can set
> +`mergetool.tmpsuffix` to be used as an extra suffix, which will be
> +appened to the temporary filename to lessen that problem.
> +
>  GIT
>  ---
>  Part of the linkgit:git[1] suite
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 9a046b7..d7cc76c 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -214,6 +214,8 @@ checkout_staged_file () {
>  }
>  
>  merge_file () {
> +	tmpsuffix=$(git config mergetool.tmpsuffix || true)
> +
>  	MERGED="$1"
>  
>  	f=$(git ls-files -u -- "$MERGED")
> @@ -229,10 +231,10 @@ merge_file () {
>  	fi
>  
>  	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
> -	BACKUP="./$MERGED.BACKUP.$ext"
> -	LOCAL="./$MERGED.LOCAL.$ext"
> -	REMOTE="./$MERGED.REMOTE.$ext"
> -	BASE="./$MERGED.BASE.$ext"
> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"
>  
>  	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
>  	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')

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

* [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 17:02     ` Junio C Hamano
@ 2014-08-19 17:15       ` Robin Rosenberg
  2014-08-19 18:01         ` Junio C Hamano
                           ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Robin Rosenberg @ 2014-08-19 17:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Robin Rosenberg

Using the original filename suffix for the temporary input files to
the merge tool confuses IDEs like Eclipse. This patch introduces
a configurtion option, mergetool.tmpsuffix, which get appended to
the temporary file name. That way the user can choose to use a
suffix like ".tmp", which does not cause confusion.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 Documentation/config.txt        |  5 +++++
 Documentation/git-mergetool.txt |  7 +++++++
 git-mergetool.sh                | 10 ++++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c55c22a..0e15800 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1778,6 +1778,11 @@ notes.displayRef::
 	several times.  A warning will be issued for refs that do not
 	exist, but a glob that does not match any refs is silently
 	ignored.
+
+mergetool.tmpsuffix::
+	A string to append the names of the temporary files mergetool
+	creates in the worktree as input to a custom merge tool. The
+	primary use is to avoid confusion in IDEs during merge.
 +
 This setting can be overridden with the `GIT_NOTES_DISPLAY_REF`
 environment variable, which must be a colon separated list of refs or
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..80a0526 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
 causes `git mergetool` to automatically remove the backup as files
 are successfully merged.
 
+`git mergetool` may also create other temporary files for the
+different versions involved in the merge. By default these files have
+the same filename suffix as the file being merged. This may confuse
+other tools in use during a long merge operation. The user can set
+`mergetool.tmpsuffix` to be used as an extra suffix, which will be
+appened to the temporary filename to lessen that problem.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 9a046b7..d7cc76c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -214,6 +214,8 @@ checkout_staged_file () {
 }
 
 merge_file () {
+	tmpsuffix=$(git config mergetool.tmpsuffix || true)
+
 	MERGED="$1"
 
 	f=$(git ls-files -u -- "$MERGED")
@@ -229,10 +231,10 @@ merge_file () {
 	fi
 
 	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
-	BACKUP="./$MERGED.BACKUP.$ext"
-	LOCAL="./$MERGED.LOCAL.$ext"
-	REMOTE="./$MERGED.REMOTE.$ext"
-	BASE="./$MERGED.BASE.$ext"
+	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
+	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
+	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
+	BASE="./$MERGED.BASE.$ext$tmpsuffix"
 
 	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
 	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
-- 
2.1.0.rc2.6.g39c33ff.dirty

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

* Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 17:15       ` [PATCH v3] " Robin Rosenberg
@ 2014-08-19 18:01         ` Junio C Hamano
  2014-08-19 20:36         ` Johannes Sixt
  2014-08-20  7:22         ` [PATCH v3] " Stefan Näwe
  2 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2014-08-19 18:01 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Robin Rosenberg <robin.rosenberg@dewire.com> writes:

> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.
>
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
>  Documentation/config.txt        |  5 +++++
>  Documentation/git-mergetool.txt |  7 +++++++
>  git-mergetool.sh                | 10 ++++++----
>  3 files changed, 18 insertions(+), 4 deletions(-)

Thanks for a quick turn-around.

>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c55c22a..0e15800 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1778,6 +1778,11 @@ notes.displayRef::
>  	several times.  A warning will be issued for refs that do not
>  	exist, but a glob that does not match any refs is silently
>  	ignored.
> +
> +mergetool.tmpsuffix::
> +	A string to append the names of the temporary files mergetool
> +	creates in the worktree as input to a custom merge tool. The
> +	primary use is to avoid confusion in IDEs during merge.
>  +
>  This setting can be overridden with the `GIT_NOTES_DISPLAY_REF`
>  environment variable, which must be a colon separated list of refs or

I smell that the new paragraph is inserted at a wrong place.  What
does notes-display-ref environment have anything to do with this
variable?

Also, could you phrase this in a way to hint that the users are
likely to want to begin the value for this variable with a dot (or
some other special character)?  Your 'suffix like ".tmp"' in the
proposed log message does it very nicely [*1*], and I'd like to see the
same done for the end users who do not have access to our log
message but do have access to our documentation pages.

Same comment applies to the new paragraph in the documentation of
git-mergetool itself.

> diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
> index e846c2e..80a0526 100644
> --- a/Documentation/git-mergetool.txt
> +++ b/Documentation/git-mergetool.txt
> @@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
>  causes `git mergetool` to automatically remove the backup as files
>  are successfully merged.
>  
> +`git mergetool` may also create other temporary files for the
> +different versions involved in the merge. By default these files have
> +the same filename suffix as the file being merged. This may confuse
> +other tools in use during a long merge operation. The user can set
> +`mergetool.tmpsuffix` to be used as an extra suffix, which will be
> +appened to the temporary filename to lessen that problem.
> +

[Footnote]

*1* To anybody remotely intelligent (like me), it hints that a
temporary file would have a name like "hello.rbtmp" if it is set to
"tmp", to let them make a natural inference that they are better off
using something like ".tmp", "~tmp", "+tmp", etc.

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

* Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 17:15       ` [PATCH v3] " Robin Rosenberg
  2014-08-19 18:01         ` Junio C Hamano
@ 2014-08-19 20:36         ` Johannes Sixt
  2014-08-19 22:14           ` Junio C Hamano
  2014-08-20  7:22         ` [PATCH v3] " Stefan Näwe
  2 siblings, 1 reply; 12+ messages in thread
From: Johannes Sixt @ 2014-08-19 20:36 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Junio C Hamano, git

Am 19.08.2014 19:15, schrieb Robin Rosenberg:
> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.

I have a merge tool that does syntax highlighting based on the file
extension. Given this:

> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"

I guess I lose syntax highlighting if I were to use mergetool.tmpsuffix;
but then I don't use Eclipse. Could it be that this is really just a
band-aid for Eclipse users, not IDEs in general as you are hinting in
the Documentation of the new variable?

-- Hannes

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

* Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 20:36         ` Johannes Sixt
@ 2014-08-19 22:14           ` Junio C Hamano
  2014-08-20  7:24             ` Robin Rosenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2014-08-19 22:14 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Robin Rosenberg, git

Johannes Sixt <j6t@kdbg.org> writes:

> Am 19.08.2014 19:15, schrieb Robin Rosenberg:
>> Using the original filename suffix for the temporary input files to
>> the merge tool confuses IDEs like Eclipse. This patch introduces
>> a configurtion option, mergetool.tmpsuffix, which get appended to
>> the temporary file name. That way the user can choose to use a
>> suffix like ".tmp", which does not cause confusion.
>
> I have a merge tool that does syntax highlighting based on the file
> extension. Given this:
>
>> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
>> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
>> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
>> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"
>
> I guess I lose syntax highlighting if I were to use mergetool.tmpsuffix;
> but then I don't use Eclipse. Could it be that this is really just a
> band-aid for Eclipse users, not IDEs in general as you are hinting in
> the Documentation of the new variable?

The phrase "IDEs like Eclipse" in the proposed log message did not
tell me (which I think is a good thing) if IDEs that need "band-aid"
are majority or minority, but I agree that we should not hint that
IDEs in general would benefit by setting this variable.  A warning
on the syntax-aware editors may be necessary.

Thanks for a careful reading.

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

* Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 17:15       ` [PATCH v3] " Robin Rosenberg
  2014-08-19 18:01         ` Junio C Hamano
  2014-08-19 20:36         ` Johannes Sixt
@ 2014-08-20  7:22         ` Stefan Näwe
  2 siblings, 0 replies; 12+ messages in thread
From: Stefan Näwe @ 2014-08-20  7:22 UTC (permalink / raw)
  To: Robin Rosenberg, Junio C Hamano; +Cc: git

Am 19.08.2014 um 19:15 schrieb Robin Rosenberg:
> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.
> 
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
>  Documentation/config.txt        |  5 +++++
>  Documentation/git-mergetool.txt |  7 +++++++
>  git-mergetool.sh                | 10 ++++++----
>  3 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c55c22a..0e15800 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1778,6 +1778,11 @@ notes.displayRef::
>  	several times.  A warning will be issued for refs that do not
>  	exist, but a glob that does not match any refs is silently
>  	ignored.
> +
> +mergetool.tmpsuffix::
> +	A string to append the names of the temporary files mergetool
> +	creates in the worktree as input to a custom merge tool. The
> +	primary use is to avoid confusion in IDEs during merge.
>  +
>  This setting can be overridden with the `GIT_NOTES_DISPLAY_REF`
>  environment variable, which must be a colon separated list of refs or
> diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
> index e846c2e..80a0526 100644
> --- a/Documentation/git-mergetool.txt
> +++ b/Documentation/git-mergetool.txt
> @@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
>  causes `git mergetool` to automatically remove the backup as files
>  are successfully merged.
>  
> +`git mergetool` may also create other temporary files for the
> +different versions involved in the merge. By default these files have
> +the same filename suffix as the file being merged. This may confuse
> +other tools in use during a long merge operation. The user can set
> +`mergetool.tmpsuffix` to be used as an extra suffix, which will be
> +appened to the temporary filename to lessen that problem.

Still:

s/appened/appended/

> +
>  GIT
>  ---
>  Part of the linkgit:git[1] suite
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 9a046b7..d7cc76c 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -214,6 +214,8 @@ checkout_staged_file () {
>  }
>  
>  merge_file () {
> +	tmpsuffix=$(git config mergetool.tmpsuffix || true)
> +
>  	MERGED="$1"
>  
>  	f=$(git ls-files -u -- "$MERGED")
> @@ -229,10 +231,10 @@ merge_file () {
>  	fi
>  
>  	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
> -	BACKUP="./$MERGED.BACKUP.$ext"
> -	LOCAL="./$MERGED.LOCAL.$ext"
> -	REMOTE="./$MERGED.REMOTE.$ext"
> -	BASE="./$MERGED.BASE.$ext"
> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"
>  
>  	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
>  	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
> 

Stefan
-- 
----------------------------------------------------------------
/dev/random says: It's Ensign Flintstone, Jim... He's Fred!
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" 
GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF

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

* Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
  2014-08-19 22:14           ` Junio C Hamano
@ 2014-08-20  7:24             ` Robin Rosenberg
  2014-08-21  7:47               ` [PATCH v4] " Robin Rosenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Robin Rosenberg @ 2014-08-20  7:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, git



----- Ursprungligt meddelande -----
> Från: "Junio C Hamano" <gitster@pobox.com>
> Till: "Johannes Sixt" <j6t@kdbg.org>
> Kopia: "Robin Rosenberg" <robin.rosenberg@dewire.com>, git@vger.kernel.org
> Skickat: onsdag, 20 aug 2014 0:14:21
> Ämne: Re: [PATCH v3] Allow the user to change the temporary file name for mergetool
> 
> Johannes Sixt <j6t@kdbg.org> writes:
> 
> > Am 19.08.2014 19:15, schrieb Robin Rosenberg:
> >> Using the original filename suffix for the temporary input files to
> >> the merge tool confuses IDEs like Eclipse. This patch introduces
> >> a configurtion option, mergetool.tmpsuffix, which get appended to
> >> the temporary file name. That way the user can choose to use a
> >> suffix like ".tmp", which does not cause confusion.
> >
> > I have a merge tool that does syntax highlighting based on the file
> > extension. Given this:
> >
> >> +	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
> >> +	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
> >> +	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
> >> +	BASE="./$MERGED.BASE.$ext$tmpsuffix"
> >
> > I guess I lose syntax highlighting if I were to use mergetool.tmpsuffix;
> > but then I don't use Eclipse. Could it be that this is really just a
> > band-aid for Eclipse users, not IDEs in general as you are hinting in
> > the Documentation of the new variable?
> 
> The phrase "IDEs like Eclipse" in the proposed log message did not
> tell me (which I think is a good thing) if IDEs that need "band-aid"
> are majority or minority, but I agree that we should not hint that
> IDEs in general would benefit by setting this variable.  A warning
> on the syntax-aware editors may be necessary.

I'm not sure it's necessary since it is not a default. If you use the
setting you are probably well aware of why you use it, and the 
possible implications.

I have only had the problem with Eclipse, but I imagine any tool that
"owns" a directory and scans it for changes will find these temporary
files and do something unexpected based on the suffix. By setting the
suffix to something insert, like txt, tmp, dat or whatever you prevent
that tool from thinking too much.

In concrete terms, what happens is that Eclipse, in my case, find
temporary filenames with the suffix Foo.REMOTE.java and thinks that
is the one source file for Foo since it contains the source for Foo.

Sure you lose syntax highlighting, that's a trade-off. An alternative
solution would be to put these files somewhere else.

-- robin

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

* [PATCH v4] Allow the user to change the temporary file name for mergetool
  2014-08-20  7:24             ` Robin Rosenberg
@ 2014-08-21  7:47               ` Robin Rosenberg
  2014-08-21 20:04                 ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Robin Rosenberg @ 2014-08-21  7:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Robin Rosenberg

Using the original filename suffix for the temporary input files to
the merge tool confuses IDEs like Eclipse. This patch introduces
a configurtion option, mergetool.tmpsuffix, which get appended to
the temporary file name. That way the user can choose to use a
suffix like ".tmp", which does not cause confusion.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 Documentation/config.txt        |  5 +++++
 Documentation/git-mergetool.txt |  7 +++++++
 git-mergetool.sh                | 10 ++++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

Fixed a spelling error.

-- robin

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c55c22a..0e15800 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1778,6 +1778,11 @@ notes.displayRef::
 	several times.  A warning will be issued for refs that do not
 	exist, but a glob that does not match any refs is silently
 	ignored.
+
+mergetool.tmpsuffix::
+	A string to append the names of the temporary files mergetool
+	creates in the worktree as input to a custom merge tool. The
+	primary use is to avoid confusion in IDEs during merge.
 +
 This setting can be overridden with the `GIT_NOTES_DISPLAY_REF`
 environment variable, which must be a colon separated list of refs or
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..80a0526 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -89,6 +89,13 @@ Setting the `mergetool.keepBackup` configuration variable to `false`
 causes `git mergetool` to automatically remove the backup as files
 are successfully merged.
 
+`git mergetool` may also create other temporary files for the
+different versions involved in the merge. By default these files have
+the same filename suffix as the file being merged. This may confuse
+other tools in use during a long merge operation. The user can set
+`mergetool.tmpsuffix` to be used as an extra suffix, which will be
+appened to the temporary filename to lessen that problem.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 9a046b7..d7cc76c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -214,6 +214,8 @@ checkout_staged_file () {
 }
 
 merge_file () {
+	tmpsuffix=$(git config mergetool.tmpsuffix || true)
+
 	MERGED="$1"
 
 	f=$(git ls-files -u -- "$MERGED")
@@ -229,10 +231,10 @@ merge_file () {
 	fi
 
 	ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
-	BACKUP="./$MERGED.BACKUP.$ext"
-	LOCAL="./$MERGED.LOCAL.$ext"
-	REMOTE="./$MERGED.REMOTE.$ext"
-	BASE="./$MERGED.BASE.$ext"
+	BACKUP="./$MERGED.BACKUP.$ext$tmpsuffix"
+	LOCAL="./$MERGED.LOCAL.$ext$tmpsuffix"
+	REMOTE="./$MERGED.REMOTE.$ext$tmpsuffix"
+	BASE="./$MERGED.BASE.$ext$tmpsuffix"
 
 	base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
 	local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
-- 
2.1.0.rc2.6.g39c33ff.dirty

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

* Re: [PATCH v4] Allow the user to change the temporary file name for mergetool
  2014-08-21  7:47               ` [PATCH v4] " Robin Rosenberg
@ 2014-08-21 20:04                 ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2014-08-21 20:04 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Robin Rosenberg <robin.rosenberg@dewire.com> writes:

> Using the original filename suffix for the temporary input files to
> the merge tool confuses IDEs like Eclipse. This patch introduces
> a configurtion option, mergetool.tmpsuffix, which get appended to
> the temporary file name. That way the user can choose to use a
> suffix like ".tmp", which does not cause confusion.
>
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
>  Documentation/config.txt        |  5 +++++
>  Documentation/git-mergetool.txt |  7 +++++++
>  git-mergetool.sh                | 10 ++++++----
>  3 files changed, 18 insertions(+), 4 deletions(-)
>
> Fixed a spelling error.

> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index c55c22a..0e15800 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1778,6 +1778,11 @@ notes.displayRef::
>  	several times.  A warning will be issued for refs that do not
>  	exist, but a glob that does not match any refs is silently
>  	ignored.
> +
> +mergetool.tmpsuffix::
> +	A string to append the names of the temporary files mergetool
> +	creates in the worktree as input to a custom merge tool. The
> +	primary use is to avoid confusion in IDEs during merge.
>  +
>  This setting can be overridden with the `GIT_NOTES_DISPLAY_REF`
>  environment variable, which must be a colon separated list of refs or

Please read the surrounding text again and answer this question:

    What is "This setting" the continued paragraph of your paragraph
    that describes mergetool.tmpsuffix variable talks about?

Stated in another way, "match any refs is silently ignored." is the
end of the first paragraph for notes.displayRef.  "This setting can
be overridden" is the beginning of the second paragraph for the same
variable.

> +`git mergetool` may also create other temporary files for the
> +different versions involved in the merge. By default these files have
> +the same filename suffix as the file being merged. This may confuse
> +other tools in use during a long merge operation. The user can set

I would suggest these changes:

 - replace "being merged" with "being merged, so that editors and
   IDEs can use the suffix for syntax highlighting".

 - replace "this may confuse other tools" with "this may confuse
   some tools".  The same tool that takes advantage of the suffix to
   syntax-highlight may also be confused in a way that you deem
   undesirable.

 - clarify what kind of confusion this warning is talking about, and
   offer an example to avoid such confusion, and drop "in use during
   a long merge operation", as that phrase alone, without knowing
   in what way the tools are confused, is not useful to the readers.

For the last item, I unfortunately cannot offer a solid replacement
phrasing, as it was not quite clear from your explanation during the
discussion, at least to me.  Is it that Eclipse notices that a new
".java" file in the working tree appeared and offers to add it or
something?  If that is the case, then perhaps I would suggest
something like this:

    This reuse of the same file suffix may however confuse some
    tools.  For example, Eclipse may notice, while resolving
    conflicts on hello.java, that new files hello.LOCAL.java and
    hello.REMOTE.java appear in your working tree and helpfully
    offer to add it to your index and then upon conclusion of the
    merge it would complain because these files are now gone.  To
    avoid causing such confusion, you can use this variable to a
    suffix that your IDE does not treat specially, e.g. ".tmp" (this
    may obviously lose syntax highlighting, though).

But I am not sure what confusion you are trying to work around, so
the single sentence that begins with "For example," above would need
to be completely rewritten, I guess.

Thanks.

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

end of thread, other threads:[~2014-08-21 20:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 12:22 [PATCH] Allow the user to change the temporary file name for mergetool Robin Rosenberg
2014-08-19 12:52 ` Stefan Näwe
2014-08-19 14:55   ` [PATCH v2] " Robin Rosenberg
2014-08-19 17:02     ` Junio C Hamano
2014-08-19 17:15       ` [PATCH v3] " Robin Rosenberg
2014-08-19 18:01         ` Junio C Hamano
2014-08-19 20:36         ` Johannes Sixt
2014-08-19 22:14           ` Junio C Hamano
2014-08-20  7:24             ` Robin Rosenberg
2014-08-21  7:47               ` [PATCH v4] " Robin Rosenberg
2014-08-21 20:04                 ` Junio C Hamano
2014-08-20  7:22         ` [PATCH v3] " Stefan Näwe

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.