mergetools: Simplify how we handle "vim" and "defaults"
PATCH v3 2/2 mergetools: Simplify how we handle "vim" and "defaults"
Remove the exceptions for "vim" and "defaults" in the mergetool library so that every filename in mergetools/ matches 1:1 with the name of a valid built-in tool.
Make common functions available in $MERGE_TOOLS_DIR/include/.
---
v2 used "include" instead of "mergetools/include"
in the Makefile. Please ignore it.
Makefile | 6 +++-
git-mergetool--lib.sh | 41 ++++++++--------------------
mergetools/gvimdiff | 1 +
mergetools/gvimdiff2 | 1 +
mergetools/{defaults => include/defaults.sh} | 0
mergetools/{vim => vimdiff} | 0
mergetools/vimdiff2 | 1 +
7 files changed, 19 insertions(+), 31 deletions(-)
create mode 100644 mergetools/gvimdiff
create mode 100644 mergetools/gvimdiff2
rename mergetools/{defaults => include/defaults.sh} (100%)
rename mergetools/{vim => vimdiff} (100%)
create mode 100644 mergetools/vimdiff2Makefile +5 -1
@@ -2724,7 +2724,11 @@ install: all $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)' $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)' - $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)' + $(INSTALL) -m 644 $(filter-out mergetools/include,$(wildcard mergetools/*)) \ + '$(DESTDIR_SQ)$(mergetools_instdir_SQ)' + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)/include' + $(INSTALL) -m 644 mergetools/include/* \ + '$(DESTDIR_SQ)$(mergetools_instdir_SQ)/include' ifndef NO_GETTEXT $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)' (cd po/build/locale && $(TAR) cf - .) | \
git-mergetool--lib.sh +11 -30
67 lines not on this page · raw message
mergetools/gvimdiff new file +1 -0
@@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff"
mergetools/gvimdiff2 new file +1 -0
@@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff"
mergetools/include/defaults.sh renamed from mergetools/defaults +0 -0
mergetools/vimdiff renamed from mergetools/vim +0 -0
mergetools/vimdiff2 new file +1 -0
@@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff"
Signature · 1 line
1.8.0.8.gd6b90fb.dirty
git-mergetool--lib.sh valid_tool () { · line 54
Quoted 12 lines · David Aguilar
git-mergetool--lib.sh +0
-8@@ -44,19 +46,9 @@ valid_tool () { } setup_tool () { - case "$1" in - vim*|gvim*) - tool=vim - ;; - *) - tool="$1" - ;; - esac
This part was an eyesore every time I looked at mergetools scripts. Good riddance.
Is there still other special case like this, or was this the last one?
Thanks, both of you, for working on this.
Quoted 18 lines · Junio C Hamano
git-mergetool--lib.sh valid_tool () { · line 54
Quoted 12 lines · David Aguilar
git-mergetool--lib.sh +0
-8@@ -44,19 +46,9 @@ valid_tool () { } setup_tool () { - case "$1" in - vim*|gvim*) - tool=vim - ;; - *) - tool="$1" - ;; - esacThis part was an eyesore every time I looked at mergetools scripts. Good riddance.
Quoted 4 lines
Is there still other special case like this, or was this the last one?
Thanks, both of you, for working on this.
I believe that was the last special case. :-) It should be easier to auto-generate a list of tools for use in the documentation now. That'll be the the next topic I look into.
I have a question. John mentioned that we can replace the use of "$(..)" with $(..) in shell.
I have a trivial style patches to replace "$(..)" with $(..) sitting uncommitted in my tree for mergetool--lib.
Grepping the rest of the tree shows that there are many occurrences of the "$(..)" idiom in the shell code.
Is this a general rule that should be in CodingStyle, or is it better left as-is? Are there cases where DQ should be used around $(..)? My understanding is "no", but I don't know whether that is correct.
Doing the documentation stuff is more important IMO so I probably shouldn't let myself get too distracted by it, though I am curious.
Signature · 1 line
David
Quoted 2 lines · David Aguilar
I have a question. John mentioned that we can replace the use of "$(..)" with $(..) in shell.
I think it isn't so much about $(...) but more about quoting the RHS of assignment.
Consider these:
var="$another_var" var="$(command)" var="$one_var$two_var" var="$another_var$(command)"
all of which _can_ be done without dq around the RHS, because the result of variable substitution and command substitution will not be subject to further word splitting.
I however find it easier to read with dq around the latter two, i.e. substitution and then concatenation of the result of substitution. The extra dq makes the intent of the author clearer, especially while reviewing a script written by other people whose understanding of the syntax I am not sure about ;-). Between var=$another and var="$another", the latter is slightly preferrable for the same reason.
One questionable case is:
var=$(command "with quoted parameter")
It makes it a bit harder to scan if there is an extra set of dq around RHS, i.e.
var="$(command "with quoted parameter")"
That case is easier to read without dq around it, or you could cheat by doing this:
var="$(command 'with quoted parameter')"
In any case, as long as the result is correct, I do not have very strong preference either way.