Discussion:
[PATCH v3 1/3] git-sh-setup: move GIT_DIR initialization into a function
David Aguilar
2014-10-11 08:39:36 UTC
Permalink
Signed-off-by: David Aguilar <***@gmail.com>
---
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
David Aguilar
2014-10-11 08:39:37 UTC
Permalink
From: Charles Bailey <***@bloomberg.net>

Signed-off-by: Charles Bailey <***@bloomberg.net>
Signed-off-by: David Aguilar <***@gmail.com>
---
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
David Aguilar
2014-10-11 08:39:38 UTC
Permalink
From: Charles Bailey <***@bloomberg.net>

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 <***@bloomberg.net>
Helped-by: John Keeping <***@keeping.me.uk>
Signed-off-by: David Aguilar <***@gmail.com>
---
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
Junio C Hamano
2014-10-13 19:16:55 UTC
Permalink
Post by David Aguilar
---
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
This is somewhat curious. Shouldn't the order of these swapped?
Post by David Aguilar
+
if test -z "$merge_tool"
then
# Check if a merge tool has been configured
David Aguilar
2014-10-15 06:35:11 UTC
Permalink
Post by Junio C Hamano
Post by David Aguilar
---
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
This is somewhat curious. Shouldn't the order of these swapped?
Yes. I'll send a replacement patch for 2/3 only.
--
David
David Aguilar
2014-10-15 06:48:26 UTC
Permalink
Post by David Aguilar
Post by Junio C Hamano
Post by David Aguilar
---
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
This is somewhat curious. Shouldn't the order of these swapped?
Yes. I'll send a replacement patch for 2/3 only.
Nevermind, I noticed you already fixed this up in pu.

Thank you,
--
David
Loading...