Re: [PATCH 1/2] Feature Request: user defined suffix for temp files created by git-mergetool

2016-10-12 Thread David Aguilar
On Thu, Oct 06, 2016 at 08:43:02AM -0400, Josef Ridky wrote:
> This is the first of two variant for request to add option to change
> suffix of name of temporary files generated by git mergetool. This
> change is requested for cases, when is git mergetool used for local
> comparision between two version of same package during package rebase.
> 
> Signed-off-by: Josef Ridky 
> ---
>  Documentation/git-mergetool.txt |  7 ++-
>  git-mergetool.sh| 23 ++-
>  2 files changed, 24 insertions(+), 6 deletions(-)

While I do like that this variant only uses a single flag, I was
curious whether it would make sense for us to change our
defaults to OLD/NEW?  I'm thinking "no" since it's totally legit
to merge "old" branches so I'll stop there.

What I really wanted to mention was...

If the patch does not update t/t7610-mergetool.sh then there is
no guarantee that my clumsy fingers won't break the new feature
in the future ;-)  So please make sure to update the tests once
we decide on the final direction.  It makes sense we wouldn't
want to update them just yet (in this patch) since this is still
RFC, but the final one should include it.

I'm still leaning towards environment variables personally,
and would have no qualms against taking a patch that teaches it
to support environment variables as long as it adds a test case
for the new feature.

Thanks for sticking with it, Josef!

cheers,
-- 
David


[PATCH 1/2] Feature Request: user defined suffix for temp files created by git-mergetool

2016-10-06 Thread Josef Ridky
This is the first of two variant for request to add option to change
suffix of name of temporary files generated by git mergetool. This
change is requested for cases, when is git mergetool used for local
comparision between two version of same package during package rebase.

Signed-off-by: Josef Ridky 
---
 Documentation/git-mergetool.txt |  7 ++-
 git-mergetool.sh| 23 ++-
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..a212cef 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -8,7 +8,7 @@ git-mergetool - Run merge conflict resolution tools to resolve 
merge conflicts
 SYNOPSIS
 
 [verse]
-'git mergetool' [--tool=] [-y | --[no-]prompt] [...]
+'git mergetool' [--tool=] [-y | --[no-]prompt] [-l | --local] [...]
 
 DESCRIPTION
 ---
@@ -79,6 +79,11 @@ success of the resolution after the custom tool has exited.
Prompt before each invocation of the merge resolution program
to give the user a chance to skip the path.
 
+-l::
+--local::
+   Change suffix of name of temporary files generated by git
+   mergetool from `_REMOTE_` and `_LOCAL_` to `_OLD_` and `_NEW_`.
+
 TEMPORARY FILES
 ---
 `git mergetool` creates `*.orig` backup files while resolving merges.
diff --git a/git-mergetool.sh b/git-mergetool.sh
index bf86270..1e04368 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -8,10 +8,11 @@
 # at the discretion of Junio C Hamano.
 #
 
-USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] 
...'
+USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-l|--local] 
[file to merge] ...'
 SUBDIRECTORY_OK=Yes
 NONGIT_OK=Yes
 OPTIONS_SPEC=
+LOCAL_MODE=false
 TOOL_MODE=merge
 . git-sh-setup
 . git-mergetool--lib
@@ -271,10 +272,19 @@ merge_file () {
BASE=${BASE##*/}
fi
 
-   BACKUP="$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext"
-   LOCAL="$MERGETOOL_TMPDIR/${BASE}_LOCAL_$$$ext"
-   REMOTE="$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext"
-   BASE="$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext"
+   if test "$LOCAL_MODE"
+   then
+
+   BACKUP="$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext"
+   LOCAL="$MERGETOOL_TMPDIR/${BASE}_NEW_$$$ext"
+   REMOTE="$MERGETOOL_TMPDIR/${BASE}_OLD_$$$ext"
+   BASE="$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext"
+   else
+   BACKUP="$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext"
+   LOCAL="$MERGETOOL_TMPDIR/${BASE}_LOCAL_$$$ext"
+   REMOTE="$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext"
+   BASE="$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext"
+   fi
 
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;}')
@@ -396,6 +406,9 @@ do
--prompt)
prompt=true
;;
+   -l|--local)
+   LOCAL_MODE=true
+   ;;
--)
shift
break
-- 
2.7.4