[PATCH v3 1/3] git-sh-setup: move GIT_DIR initialization into a function

Subsystems: the rest

DORMANTno replies

3 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH v3 1/3] git-sh-setup: move GIT_DIR initialization into a function

From: David Aguilar <hidden>
Date: 2016-06-15 23:02:41

Signed-off-by: David Aguilar <redacted>
---
This is a new patch since the last round, prep for 2/3

 git-sh-setup.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 9447980..d968760 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -330,8 +330,7 @@ esac
 
 # Make sure we are in a valid repository of a vintage we understand,
 # if we require to be in a git repository.
-if test -z "$NONGIT_OK"
-then
+git_dir_init () {
 	GIT_DIR=$(git rev-parse --git-dir) || exit
 	if [ -z "$SUBDIRECTORY_OK" ]
 	then
@@ -346,6 +345,11 @@ then
 		exit 1
 	}
 	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
+}
+
+if test -z "$NONGIT_OK"
+then
+	git_dir_init
 fi
 
 peel_committish () {
-- 
2.1.2.378.g89c0b73

[PATCH v3 2/3] mergetool: don't require a work tree for --tool-help

From: David Aguilar <hidden>
Date: 2016-06-15 23:02:41

From: Charles Bailey <redacted>

Signed-off-by: Charles Bailey <redacted>
Signed-off-by: David Aguilar <redacted>
---
Changes since v2:

This now uses the new git_dir_init function.

 git-mergetool.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 96a61ba..cddb533 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -10,11 +10,11 @@
 
 USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] ...'
 SUBDIRECTORY_OK=Yes
+NONGIT_OK=Yes
 OPTIONS_SPEC=
 TOOL_MODE=merge
 . git-sh-setup
 . git-mergetool--lib
-require_work_tree
 
 # Returns true if the mode reflects a symlink
 is_symlink () {
@@ -378,6 +378,9 @@ prompt_after_failed_merge () {
 	done
 }
 
+require_work_tree
+git_dir_init
+
 if test -z "$merge_tool"
 then
 	# Check if a merge tool has been configured
-- 
2.1.2.378.g89c0b73

[PATCH v3 3/3] difftool: don't assume that default sh is sane

From: David Aguilar <hidden>
Date: 2016-06-15 23:02:41

From: Charles Bailey <redacted>

git-difftool used to create a command list script containing $( ... )
and explicitly calls "sh -c" with this list.

Instead, allow mergetool --tool-help to take a mode parameter and call
mergetool directly to invoke the show_tool_help function. This mode
parameter is intented for use solely by difftool.

Signed-off-by: Charles Bailey <redacted>
Helped-by: John Keeping [off-list ref]
Signed-off-by: David Aguilar <redacted>
---
No changes since v2.

 git-difftool.perl | 6 +-----
 git-mergetool.sh  | 4 ++++
 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 18ca61e..598fcc2 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -47,13 +47,9 @@ sub find_worktree
 
 sub print_tool_help
 {
-	my $cmd = 'TOOL_MODE=diff';
-	$cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
-	$cmd .= ' && show_tool_help';
-
 	# See the comment at the bottom of file_diff() for the reason behind
 	# using system() followed by exit() instead of exec().
-	my $rc = system('sh', '-c', $cmd);
+	my $rc = system(qw(git mergetool --tool-help=diff));
 	exit($rc | ($rc >> 8));
 }
 
diff --git a/git-mergetool.sh b/git-mergetool.sh
index cddb533..10782b8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -327,6 +327,10 @@ guessed_merge_tool=false
 while test $# != 0
 do
 	case "$1" in
+	--tool-help=*)
+		TOOL_MODE=${1#--tool-help=}
+		show_tool_help
+		;;
 	--tool-help)
 		show_tool_help
 		;;
-- 
2.1.2.378.g89c0b73
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help