Hi Junio,
Please pull from:
git://repo.or.cz/git/mergetool.git
To receive the following fixes (see below). They are mostly cleanups
and portability fixes. They also include Arjen Laarjoven's support
for Apple Mac OS X's opendiff GUI merge tool.
----
Theodore Ts'o (11):
Fix minor formatting issue in man page for git-mergetool
mergetool: Replace use of "echo -n" with printf(3) to be more portable
mergetool: Don't error out in the merge case where the local file is deleted
mergetool: portability fix: don't assume true is in /bin
mergetool: portability fix: don't use reserved word function
mergetool: factor out common code
mergetool: Remove spurious error message if merge.tool config option not set
mergetool: Fix abort command when resolving symlinks and deleted files
mergetool: Add support for Apple Mac OS X's opendiff command
mergetool: Make git-rm quiet when resolving a deleted file conflict
mergetool: Clean up description of files and prompts for merge resolutions
- Ted
@@ -26,11 +26,11 @@ OPTIONS Use the merge resolution program specified by <tool>. Valid merge tools are: kdiff3, tkdiff, meld, xxdiff, emerge, and vimdiff.-- If a merge resolution program is not specified, 'git mergetool'- will use the configuration variable merge.tool. If the- configuration variable merge.tool is not set, 'git mergetool'- will pick a suitable default.+++If a merge resolution program is not specified, 'git mergetool'+will use the configuration variable merge.tool. If the+configuration variable merge.tool is not set, 'git mergetool'+will pick a suitable default. Author ------
@@ -63,7 +63,7 @@ function describe_file () { resolve_symlink_merge(){-while/bin/true;do+whiletrue;doprintf"Use (r)emote or (l)ocal, or (a)bort? "readanscase"$ans"in
@@ -87,7 +87,7 @@ resolve_symlink_merge () {} resolve_deleted_merge(){-while/bin/true;do+whiletrue;doprintf"Use (m)odified or (d)eleted file, or (a)bort? "readanscase"$ans"in
Create common function check_unchanged(), save_backup() and
remove_backup().
Also fix some minor whitespace issues while we're at it.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
git-mergetool.sh | 80 +++++++++++++++++++++++++-----------------------------
1 files changed, 37 insertions(+), 43 deletions(-)
@@ -46,7 +46,7 @@ describe_file () {printf" "iftest-z"$mode";then-printf"'$path' was deleted"+printf"'$path' was deleted"elifis_symlink"$mode";thenprintf"'$path' is a symlink containing '"cat"$file"
@@ -108,12 +108,40 @@ resolve_deleted_merge () {done}+check_unchanged(){+iftest"$path"-nt"$BACKUP";then+status=0;+else+whiletrue;do+echo"$path seems unchanged."+printf"Was the merge successful? [y/n] "+readanswer</dev/tty+case"$answer"in+y*|Y*)status=0;break;;+n*|N*)status=1;break;;+esac+done+fi+}++save_backup(){+iftest"$status"-eq0;then+mv--"$BACKUP""$path.orig"+fi+}++remove_backup(){+iftest"$status"-eq0;then+rm"$BACKUP"+fi+}+ merge_file(){path="$1"f=`git-ls-files-u--"$path"`iftest-z"$f";then-iftest!-f"$path";then+iftest!-f"$path";thenecho"$path: file not found"elseecho"$path: file does not need merging"
@@ -282,7 +292,7 @@ doneiftest-z"$merge_tool";thenmerge_tool=`git-configmerge.tool`case"$merge_tool"in-kdiff3|tkdiff|xxdiff|meld|emerge|vimdiff|"")+kdiff3|tkdiff|xxdiff|meld|opendiff|emerge|vimdiff|"");;# happy*)echo>&2"git config option merge.tool set to unknown tool: $merge_tool"
@@ -301,6 +311,8 @@ if test -z "$merge_tool" ; thenmerge_tool=xxdiffeliftypemeld>/dev/null2>&1&&test-n"$DISPLAY";thenmerge_tool=meld+eliftypeopendiff>/dev/null2>&1;then+merge_tool=opendiffeliftypeemacs>/dev/null2>&1;thenmerge_tool=emergeeliftypevimdiff>/dev/null2>&1;then
@@ -312,7 +324,7 @@ if test -z "$merge_tool" ; thenficase"$merge_tool"in-kdiff3|tkdiff|meld|xxdiff|vimdiff)+kdiff3|tkdiff|meld|xxdiff|vimdiff|opendiff)if!type"$merge_tool">/dev/null2>&1;thenecho"The merge tool $merge_tool is not available"exit1
This fixes complaints from Junio for how messages and prompts are
printed when resolving symlink and deleted file merges.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
git-mergetool.sh | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
@@ -44,27 +44,24 @@ describe_file () {branch="$2"file="$3"-printf" "+printf" {$branch}: "iftest-z"$mode";then-printf"'$path' was deleted"+echo"deleted"elifis_symlink"$mode";then-printf"'$path' is a symlink containing '"-cat"$file"-printf"'"+echo"a symbolic link -> '$(cat"$file")'"elseifbase_present;then-printf"'%s' was created""$path"+echo"modified"else-printf"'%s' was modified""$path"+echo"created"fifi-echo" in the $branch branch"} resolve_symlink_merge(){whiletrue;do-printf"Use (r)emote or (l)ocal, or (a)bort? "+printf"Use (l)ocal or (r)emote, or (a)bort? "readanscase"$ans"in[lL]*)
@@ -88,10 +85,14 @@ resolve_symlink_merge () { resolve_deleted_merge(){whiletrue;do-printf"Use (m)odified or (d)eleted file, or (a)bort? "+ifbase_present;then+printf"Use (m)odified or (d)eleted file, or (a)bort? "+else+printf"Use (c)reated or (d)eleted file, or (a)bort? "+fireadanscase"$ans"in-[mM]*)+[mMcC]*)git-add--"$path"cleanup_temp_files--save-backupreturn
@@ -166,7 +167,7 @@ merge_file () {remote_present&&gitcat-fileblob":3:$path">"$REMOTE"2>/dev/nulliftest-z"$local_mode"-o-z"$remote_mode";then-echo"Deleted merge conflict for $path:"+echo"Deleted merge conflict for '$path':"describe_file"$local_mode""local""$LOCAL"describe_file"$remote_mode""remote""$REMOTE"resolve_deleted_merge
@@ -174,14 +175,14 @@ merge_file () {fiifis_symlink"$local_mode"||is_symlink"$remote_mode";then-echo"Symlink merge conflict for $path:"+echo"Symbolic link merge conflict for '$path':"describe_file"$local_mode""local""$LOCAL"describe_file"$remote_mode""remote""$REMOTE"resolve_symlink_mergereturnfi-echo"Normal merge conflict for $path:"+echo"Normal merge conflict for '$path':"describe_file"$local_mode""local""$LOCAL"describe_file"$remote_mode""remote""$REMOTE"printf"Hit return to start merge resolution tool ($merge_tool): "
If the file we are trying to merge resolve is in git-ls-files -u, then
skip the file existence test. If the file isn't reported in
git-ls-files, then check to see if the file exists or not to give an
appropriate error message.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
git-mergetool.sh | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
@@ -111,14 +111,13 @@ resolve_deleted_merge () { merge_file(){path="$1"-iftest!-f"$path";then-echo"$path: file not found"-exit1-fi-f=`git-ls-files-u--"$path"`iftest-z"$f";then-echo"$path: file does not need merging"+iftest!-f"$path";then+echo"$path: file not found"+else+echo"$path: file does not need merging"+fiexit1fi
@@ -14,19 +14,19 @@ SUBDIRECTORY_OK=Yes require_work_tree# Returns true if the mode reflects a symlink-functionis_symlink(){+is_symlink(){test"$1"=120000}-functionlocal_present(){+local_present(){test-n"$local_mode"}-functionremote_present(){+remote_present(){test-n"$remote_mode"}-functionbase_present(){+base_present(){test-n"$base_mode"}
@@ -44,18 +44,18 @@ function describe_file () {branch="$2"file="$3"-echo-n" "+printf" "iftest-z"$mode";then-echo-n"'$path' was deleted"+printf"'$path' was deleted"elifis_symlink"$mode";then-echo-n"'$path' is a symlink containing '"+printf"'$path' is a symlink containing '"cat"$file"-echo-n"'"+printf"'"elseifbase_present;then-echo-n"'$path' was created"+printf"'%s' was created""$path"else-echo-n"'$path' was modified"+printf"'%s' was modified""$path"fifiecho" in the $branch branch"
@@ -64,7 +64,7 @@ function describe_file () { resolve_symlink_merge(){while/bin/true;do-echo-n"Use (r)emote or (l)ocal, or (a)bort? "+printf"Use (r)emote or (l)ocal, or (a)bort? "readanscase"$ans"in[lL]*)
@@ -88,7 +88,7 @@ resolve_symlink_merge () { resolve_deleted_merge(){while/bin/true;do-echo-n"Use (m)odified or (d)eleted file, or (a)bort? "+printf"Use (m)odified or (d)eleted file, or (a)bort? "readanscase"$ans"in[mM]*)
@@ -157,7 +157,7 @@ merge_file () {echo"Normal merge conflict for $path:"describe_file"$local_mode""local""$LOCAL"describe_file"$remote_mode""remote""$REMOTE"-echo-n"Hit return to start merge resolution tool ($merge_tool): "+printf"Hit return to start merge resolution tool ($merge_tool): "readanscase"$merge_tool"in
@@ -193,7 +193,7 @@ merge_file () {elsewhiletrue;doecho"$path seems unchanged."-echo-n"Was the merge successful? [y/n] "+printf"Was the merge successful? [y/n] "readanswer</dev/ttycase"$answer"iny*|Y*)status=0;break;;
@@ -225,7 +225,7 @@ merge_file () {elsewhiletrue;doecho"$path seems unchanged."-echo-n"Was the merge successful? [y/n] "+printf"Was the merge successful? [y/n] "readanswer</dev/ttycase"$answer"iny*|Y*)status=0;break;;
@@ -346,12 +346,12 @@ if test $# -eq 0 ; thenechoMergingthefiles:$filesgitls-files-u|sed-e's/^[^ ]* //'|sort-u|whilereadido-echo""+printf"\n"merge_file"$i"</dev/tty>/dev/ttydoneelsewhiletest$#-gt0;do-echo""+printf"\n"merge_file"$1"shiftdone
Here it is much more unlikely that $merge_tool contains a conversion
specifier but anyway I'd prefer to use %s.
Yep, agreed.
Junio, I've prepared an alterate patch series. If you haven't pulled
from repo.or.cz, I'd appreciate it if you could pull from the
mergetool branch (instead of master) instead:
http://repo.or.cz/w/git/mergetool.git
The differences between the patch series in the master and mergetool
branch are:
* Change the description of the printf patch to say:
printf(3)->printf(1)
* Fix the double space after printf and symlink %s conversion
earlier in the patch series (only to have it disappear
in the last patch, so this is a no-op at the end of
the day, but more of an excuse to go play with stgit
and in the name of anal-rententive correctness)
* Use a %s printf conversion for the "Hit return to start merge..."
statement as noted above in the last patch.
Thanks!!
(Apparently there's no way to forcibly reset the pointer of the master
head on repo.or.cz, probably for security/sanity reasons, without
going through an administrator.)
- Ted