From: Josef Ridky <jridky@redhat.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 2/2] Feature Request: user defined suffix for temp files created by git-mergetool
Date: Wed, 12 Oct 2016 04:24:37 -0400 (EDT) [thread overview]
Message-ID: <1550673688.5271111.1476260677732.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <xmqq7f9lmmol.fsf@gitster.mtv.corp.google.com>
This is update of the second 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
comparison between two version of same package during package rebase.
Signed-off-by: Josef Ridky <jridky@redhat.com>
---
Documentation/git-mergetool.txt | 22 ++++++++++++++-
git-mergetool.sh | 60 +++++++++++++++++++++++++++++++++++++----
2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..a0466ac 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=<tool>] [-y | --[no-]prompt] [<file>...]
+'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [--local=<name>] [--remote=<name>] [--backup=<name>] [--base=<name>] [<file>...]
DESCRIPTION
-----------
@@ -79,6 +79,26 @@ 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.
+--local=<name>::
+ Use string from <name> as part of suffix of name of temporary
+ file (local) for merging. If not set, default value is used.
+ Default suffix is LOCAL.
+
+--remote=<name>::
+ Use string from <name> as part of suffix of name of temporary
+ file (remote) for merging. If not set, default value is used.
+ Default suffix is REMOTE.
+
+--backup=<name>::
+ Use string from <name> as part of suffix of name of temporary
+ file (backup) for merging. If not set, default value is used.
+ Default suffix is BACKUP.
+
+--base=<name>::
+ Use string from <name> as part of suffix of name of temporary
+ file (base) for merging. If not set, default value is used.
+ Default suffix is BASE.
+
TEMPORARY FILES
---------------
`git mergetool` creates `*.orig` backup files while resolving merges.
diff --git a/git-mergetool.sh b/git-mergetool.sh
index bf86270..ed9ba82 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -8,7 +8,7 @@
# 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] [--local=name] [--remote=name] [--backup=name] [--base=name] [file to merge] ...'
SUBDIRECTORY_OK=Yes
NONGIT_OK=Yes
OPTIONS_SPEC=
@@ -16,6 +16,13 @@ TOOL_MODE=merge
. git-sh-setup
. git-mergetool--lib
+# Can be changed by user
+LOCAL_NAME='LOCAL'
+BASE_NAME='BASE'
+BACKUP_NAME='BACKUP'
+REMOTE_NAME='REMOTE'
+
+
# Returns true if the mode reflects a symlink
is_symlink () {
test "$1" = 120000
@@ -271,10 +278,10 @@ 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"
+ BACKUP="$MERGETOOL_TMPDIR/${BASE}_${BACKUP_NAME}_$$$ext"
+ LOCAL="$MERGETOOL_TMPDIR/${BASE}_${LOCAL_NAME}_$$$ext"
+ REMOTE="$MERGETOOL_TMPDIR/${BASE}_${REMOTE_NAME}_$$$ext"
+ BASE="$MERGETOOL_TMPDIR/${BASE}_${BASE_NAME}_$$$ext"
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 +403,18 @@ do
--prompt)
prompt=true
;;
+ --local=*)
+ LOCAL_NAME=${1#--local=}
+ ;;
+ --remote=*)
+ REMOTE_NAME=${1#--remote=}
+ ;;
+ --base=*)
+ BASE_NAME=${1#--base=}
+ ;;
+ --backup=*)
+ BACKUP_NAME=${1#--backup=}
+ ;;
--)
shift
break
@@ -410,6 +429,37 @@ do
shift
done
+# sanity check after parsing command line
+case "" in
+"$LOCAL_NAME"|"$REMOTE_NAME"|"$BASE_NAME"|"$BACKUP_NAME")
+ die "You cannot set any of --local/remote/base/backup to empty."
+ ;;
+esac
+
+case "$LOCAL_NAME" in
+"$REMOTE_NAME"|"$BASE_NAME"|"$BACKUP_NAME")
+ die "You cannot set any of --remote/base/backup to same as --local."
+ ;;
+esac
+
+case "$REMOTE_NAME" in
+"$LOCAL_NAME"|"$BASE_NAME"|"$BACKUP_NAME")
+ die "You cannot set any of --local/base/backup to same as --remote."
+ ;;
+esac
+
+case "$BASE_NAME" in
+"$LOCAL_NAME"|"$REMOTE_NAME"|"$BACKUP_NAME")
+ die "You cannot set any of --local/remote/backup to same as --base."
+ ;;
+esac
+
+case "$BACKUP_NAME" in
+"$LOCAL_NAME"|"$REMOTE_NAME"|"$BASE_NAME")
+ die "You cannot set any of --local/remote/base to same as --backup."
+ ;;
+esac
+
prompt_after_failed_merge () {
while true
do
--
2.7.4
next prev parent reply other threads:[~2016-10-12 8:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <88486231.114620.1475474318974.JavaMail.zimbra@redhat.com>
2016-10-03 6:36 ` Feature Request: user defined suffix for temp files created by git-mergetool Josef Ridky
2016-10-03 15:18 ` Anatoly Borodin
2016-10-04 5:18 ` Josef Ridky
2016-10-05 9:47 ` David Aguilar
2016-10-05 10:19 ` Josef Ridky
2016-10-05 7:47 ` Josef Ridky
2016-10-05 16:05 ` Junio C Hamano
2016-10-06 6:47 ` Josef Ridky
2016-10-05 21:04 ` Johannes Sixt
2016-10-06 7:21 ` Josef Ridky
2016-10-06 12:43 ` [PATCH 1/2] " Josef Ridky
2016-10-06 13:09 ` [PATCH 2/2] " Josef Ridky
2016-10-06 17:06 ` Junio C Hamano
2016-10-12 8:24 ` Josef Ridky [this message]
2016-10-12 17:59 ` [PATCH v2 " Junio C Hamano
2016-10-13 4:55 ` David Aguilar
2016-10-13 5:13 ` [PATCH 1/2] " David Aguilar
2016-10-06 16:58 ` Junio C Hamano
2016-10-06 15:54 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1550673688.5271111.1476260677732.JavaMail.zimbra@redhat.com \
--to=jridky@redhat.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).