Quantcast

[PATCH v2 0/5] modernize t1500

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 0/5] modernize t1500

Eric Sunshine
This is a re-roll of [1] which modernizes t1500 by updating tests to set
up their own needed state rather than relying upon manipulation of
global state.

Changes since v1[1]:

In v1 patch 1/6, which makes test_rev_parse() for-loop driven, the loop
control has been moved to the top of the loop for improved robustness.

v1 patch 2/6, which tweaked the value of GIT_CONFIG in preparation for
removal of global cd's has been squashed into patch 3/6 which actually
removes the cd's since the below diff makes perfect sense in the context
of the latter patch, thus doesn't require its own preparatory patch.

    -cd work || exit 1
    -GIT_CONFIG="$(pwd)"/../.git/config
    +GIT_CONFIG="$(pwd)/work/../.git/config"

v1 patch 3/6, which teaches test_rev_parse() the -C option, has been
revised to ensure that the argument to -C is always quoted upon use to
avoid problems with whitespace in directory names (though current tests
don't have any such directories).

v1 patches 4/6 and 5/6, which teach test_rev_parse() the -b and -g
options, no longer assigns shell code to a variable for later
execution/evaluation; instead they just execute the code directly.

v1 patch 5/6 ensures that the argument to -g is properly quoted when
assigned to GIT_DIR to avoid problems with whitespace in directory
names.

v1 patch 6/6, which changes "mv .git repo.git" to "cp -R .git repo.git",
has been squashed with Junio's 7/6[2], which moves the "cp -R" earlier
in the script, and now sits at the front of the series. Other
setup-related actions have likewise been moved into a common "setup"
test[3].

Most commit messages have seen minor tweaks.

A v1 to v2 interdiff is included below.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/294088
[2]: http://thread.gmane.org/gmane.comp.version-control.git/294088/focus=294168
[3]: http://thread.gmane.org/gmane.comp.version-control.git/294088/focus=294170

Eric Sunshine (5):
  t1500: be considerate to future potential tests
  t1500: test_rev_parse: facilitate future test enhancements
  t1500: avoid changing working directory outside of tests
  t1500: avoid setting configuration options outside of tests
  t1500: avoid setting environment variables outside of tests

 t/t1500-rev-parse.sh | 123 ++++++++++++++++++++++++++-------------------------
 1 file changed, 63 insertions(+), 60 deletions(-)

--- >8 ---
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index af223ed..39af565 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -7,26 +7,21 @@ test_description='test git rev-parse'
 test_rev_parse () {
  dir=
  bare=
- env=
+ gitdir=
  while :
  do
  case "$1" in
- -C) dir="-C $2"; shift; shift ;;
- -b) bare="$2"; shift; shift ;;
- -g) env="GIT_DIR=$2; export GIT_DIR"; shift; shift ;;
+ -C) dir="$2"; shift; shift ;;
+ -b) case "$2" in
+    [tfu]*) bare="$2"; shift; shift ;;
+    *) error "test_rev_parse: bogus core.bare value '$2'" ;;
+    esac ;;
+ -g) gitdir="$2"; shift; shift ;;
  -*) error "test_rev_parse: unrecognized option '$1'" ;;
  *) break ;;
  esac
  done
 
- case "$bare" in
- '') ;;
- t*) bare="test_config $dir core.bare true" ;;
- f*) bare="test_config $dir core.bare false" ;;
- u*) bare="test_unconfig $dir core.bare" ;;
- *) error "test_rev_parse: unrecognized core.bare value '$bare'"
- esac
-
  name=$1
  shift
 
@@ -36,35 +31,48 @@ test_rev_parse () {
  show-prefix \
  git-dir
  do
+ test $# -eq 0 && break
  expect="$1"
  test_expect_success "$name: $o" '
- test_when_finished "sane_unset GIT_DIR" &&
- eval $env &&
- $bare &&
+ if test -n "$gitdir"
+ then
+ test_when_finished "unset GIT_DIR" &&
+ GIT_DIR="$gitdir" &&
+ export GIT_DIR
+ fi &&
+
+ case "$bare" in
+ t*) test_config ${dir:+-C "$dir"} core.bare true ;;
+ f*) test_config ${dir:+-C "$dir"} core.bare false ;;
+ u*) test_unconfig ${dir:+-C "$dir"} core.bare ;;
+ esac &&
+
  echo "$expect" >expect &&
- git $dir rev-parse --$o >actual &&
+ git ${dir:+-C "$dir"} rev-parse --$o >actual &&
  test_cmp expect actual
  '
  shift
- test $# -eq 0 && break
  done
 }
 
 ROOT=$(pwd)
 
+test_expect_success 'setup' '
+ mkdir -p sub/dir work &&
+ cp -R .git repo.git
+'
+
 test_rev_parse toplevel false false true '' .git
 
 test_rev_parse -C .git .git/ false true false '' .
 test_rev_parse -C .git/objects .git/objects/ false true false '' "$ROOT/.git"
 
-test_expect_success 'setup untracked sub/dir' 'mkdir -p sub/dir'
 test_rev_parse -C sub/dir subdirectory false false true sub/dir/ "$ROOT/.git"
 
 test_rev_parse -b t 'core.bare = true' true false false
 
 test_rev_parse -b u 'core.bare undefined' false false true
 
-test_expect_success 'setup non-local database ../.git' 'mkdir work'
 
 test_rev_parse -C work -g ../.git -b f 'GIT_DIR=../.git, core.bare = false' false false true ''
 
@@ -72,7 +80,6 @@ test_rev_parse -C work -g ../.git -b t 'GIT_DIR=../.git, core.bare = true' true
 
 test_rev_parse -C work -g ../.git -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
-test_expect_success 'setup non-local database ../repo.git' 'cp -R .git repo.git'
 
 test_rev_parse -C work -g ../repo.git -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''
 
--- >8 ---


--
2.8.2.703.g78b384c
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 1/5] t1500: be considerate to future potential tests

Eric Sunshine
The final batch of git-rev-parse tests work against a non-local object
database named repo.git. This is done by renaming .git to repo.git and
pointing GIT_DIR at it, but the name is never restored to .git at the
end of the script, which can be problematic for tests added in the
future. Be more friendly by instead making repo.git a copy of .git.

Furthermore, make it clear that tests in repo.git will be independent
from the results of earlier tests done in .git by initializing repo.git
earlier in the test sequence.

Likewise, bundle remaining preparation (such as directory creation) into
a common setup test consistent with modern practice.

Signed-off-by: Eric Sunshine <[hidden email]>
---
 t/t1500-rev-parse.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..0194f54 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -37,6 +37,11 @@ test_rev_parse() {
 
 ROOT=$(pwd)
 
+test_expect_success 'setup' '
+ mkdir -p sub/dir work &&
+ cp -R .git repo.git
+'
+
 test_rev_parse toplevel false false true '' .git
 
 cd .git || exit 1
@@ -45,7 +50,6 @@ cd objects || exit 1
 test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
 cd ../.. || exit 1
 
-mkdir -p sub/dir || exit 1
 cd sub/dir || exit 1
 test_rev_parse subdirectory false false true sub/dir/ "$ROOT/.git"
 cd ../.. || exit 1
@@ -56,7 +60,6 @@ test_rev_parse 'core.bare = true' true false false
 git config --unset core.bare
 test_rev_parse 'core.bare undefined' false false true
 
-mkdir work || exit 1
 cd work || exit 1
 GIT_DIR=../.git
 GIT_CONFIG="$(pwd)"/../.git/config
@@ -71,7 +74,6 @@ test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
 git config --unset core.bare
 test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
-mv ../.git ../repo.git || exit 1
 GIT_DIR=../repo.git
 GIT_CONFIG="$(pwd)"/../repo.git/config
 
--
2.8.2.703.g78b384c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 2/5] t1500: test_rev_parse: facilitate future test enhancements

Eric Sunshine
In reply to this post by Eric Sunshine
Tests run by test_rev_parse() are nearly identical; each invokes
git-rev-parse with a single option and compares the result against an
expected value. Such duplication makes it onerous to extend the tests
since any change needs to be repeated in each test. Avoid the
duplication by parameterizing the test and driving it via a for-loop.

Signed-off-by: Eric Sunshine <[hidden email]>
---
 t/t1500-rev-parse.sh | 44 +++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 0194f54..c84f5c3 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -3,38 +3,28 @@
 test_description='test git rev-parse'
 . ./test-lib.sh
 
-test_rev_parse() {
+# usage: label is-bare is-inside-git is-inside-work prefix git-dir
+test_rev_parse () {
  name=$1
  shift
 
- test_expect_success "$name: is-bare-repository" \
- "test '$1' = \"\$(git rev-parse --is-bare-repository)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: is-inside-git-dir" \
- "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: is-inside-work-tree" \
- "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: prefix" \
- "test '$1' = \"\$(git rev-parse --show-prefix)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: git-dir" \
- "test '$1' = \"\$(git rev-parse --git-dir)\""
- shift
- [ $# -eq 0 ] && return
+ for o in is-bare-repository \
+ is-inside-git-dir \
+ is-inside-work-tree \
+ show-prefix \
+ git-dir
+ do
+ test $# -eq 0 && break
+ expect="$1"
+ test_expect_success "$name: $o" '
+ echo "$expect" >expect &&
+ git rev-parse --$o >actual &&
+ test_cmp expect actual
+ '
+ shift
+ done
 }
 
-# label is-bare is-inside-git is-inside-work prefix git-dir
-
 ROOT=$(pwd)
 
 test_expect_success 'setup' '
--
2.8.2.703.g78b384c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Eric Sunshine
In reply to this post by Eric Sunshine
Ideally, each test should be responsible for setting up state it needs
rather than relying upon transient global state. Toward this end, teach
test_rev_parse() to accept a "-C <dir>" option to allow callers to
instruct it explicitly in which directory its tests should be run. Take
advantage of this new option to avoid changing the working directory
outside of tests.

Signed-off-by: Eric Sunshine <[hidden email]>
---
 t/t1500-rev-parse.sh | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index c84f5c3..fb2cee8 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -3,8 +3,18 @@
 test_description='test git rev-parse'
 . ./test-lib.sh
 
-# usage: label is-bare is-inside-git is-inside-work prefix git-dir
+# usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir
 test_rev_parse () {
+ dir=
+ while :
+ do
+ case "$1" in
+ -C) dir="$2"; shift; shift ;;
+ -*) error "test_rev_parse: unrecognized option '$1'" ;;
+ *) break ;;
+ esac
+ done
+
  name=$1
  shift
 
@@ -18,7 +28,7 @@ test_rev_parse () {
  expect="$1"
  test_expect_success "$name: $o" '
  echo "$expect" >expect &&
- git rev-parse --$o >actual &&
+ git ${dir:+-C "$dir"} rev-parse --$o >actual &&
  test_cmp expect actual
  '
  shift
@@ -34,15 +44,10 @@ test_expect_success 'setup' '
 
 test_rev_parse toplevel false false true '' .git
 
-cd .git || exit 1
-test_rev_parse .git/ false true false '' .
-cd objects || exit 1
-test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
-cd ../.. || exit 1
+test_rev_parse -C .git .git/ false true false '' .
+test_rev_parse -C .git/objects .git/objects/ false true false '' "$ROOT/.git"
 
-cd sub/dir || exit 1
-test_rev_parse subdirectory false false true sub/dir/ "$ROOT/.git"
-cd ../.. || exit 1
+test_rev_parse -C sub/dir subdirectory false false true sub/dir/ "$ROOT/.git"
 
 git config core.bare true
 test_rev_parse 'core.bare = true' true false false
@@ -50,30 +55,29 @@ test_rev_parse 'core.bare = true' true false false
 git config --unset core.bare
 test_rev_parse 'core.bare undefined' false false true
 
-cd work || exit 1
 GIT_DIR=../.git
-GIT_CONFIG="$(pwd)"/../.git/config
+GIT_CONFIG="$(pwd)/work/../.git/config"
 export GIT_DIR GIT_CONFIG
 
 git config core.bare false
-test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
+test_rev_parse -C work 'GIT_DIR=../.git, core.bare = false' false false true ''
 
 git config core.bare true
-test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
+test_rev_parse -C work 'GIT_DIR=../.git, core.bare = true' true false false ''
 
 git config --unset core.bare
-test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
+test_rev_parse -C work 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
 GIT_DIR=../repo.git
-GIT_CONFIG="$(pwd)"/../repo.git/config
+GIT_CONFIG="$(pwd)/work/../repo.git/config"
 
 git config core.bare false
-test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = false' false false true ''
 
 git config core.bare true
-test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = true' true false false ''
 
 git config --unset core.bare
-test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
+test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
 
 test_done
--
2.8.2.703.g78b384c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 4/5] t1500: avoid setting configuration options outside of tests

Eric Sunshine
In reply to this post by Eric Sunshine
Ideally, each test should be responsible for setting up state it needs
rather than relying upon transient global state. Toward this end, teach
test_rev_parse() to accept a "-b <value>" option to allow callers to set
"core.bare" explicitly or undefine it. Take advantage of this new option
to avoid setting "core.bare" outside of tests.

Under the hood, "-b <value>" invokes "test_config -C <dir>" (or
"test_unconfig -C <dir>"), thus git-config knows explicitly where to
find its configuration file. Consequently, the global GIT_CONFIG
environment variable required by the manual git-config invocations
outside of tests is no longer needed, and is thus dropped.

Signed-off-by: Eric Sunshine <[hidden email]>
---
 t/t1500-rev-parse.sh | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index fb2cee8..5be463f 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -6,10 +6,15 @@ test_description='test git rev-parse'
 # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir
 test_rev_parse () {
  dir=
+ bare=
  while :
  do
  case "$1" in
  -C) dir="$2"; shift; shift ;;
+ -b) case "$2" in
+    [tfu]*) bare="$2"; shift; shift ;;
+    *) error "test_rev_parse: bogus core.bare value '$2'" ;;
+    esac ;;
  -*) error "test_rev_parse: unrecognized option '$1'" ;;
  *) break ;;
  esac
@@ -27,6 +32,12 @@ test_rev_parse () {
  test $# -eq 0 && break
  expect="$1"
  test_expect_success "$name: $o" '
+ case "$bare" in
+ t*) test_config ${dir:+-C "$dir"} core.bare true ;;
+ f*) test_config ${dir:+-C "$dir"} core.bare false ;;
+ u*) test_unconfig ${dir:+-C "$dir"} core.bare ;;
+ esac &&
+
  echo "$expect" >expect &&
  git ${dir:+-C "$dir"} rev-parse --$o >actual &&
  test_cmp expect actual
@@ -49,35 +60,25 @@ test_rev_parse -C .git/objects .git/objects/ false true false '' "$ROOT/.git"
 
 test_rev_parse -C sub/dir subdirectory false false true sub/dir/ "$ROOT/.git"
 
-git config core.bare true
-test_rev_parse 'core.bare = true' true false false
+test_rev_parse -b t 'core.bare = true' true false false
 
-git config --unset core.bare
-test_rev_parse 'core.bare undefined' false false true
+test_rev_parse -b u 'core.bare undefined' false false true
 
 GIT_DIR=../.git
-GIT_CONFIG="$(pwd)/work/../.git/config"
-export GIT_DIR GIT_CONFIG
+export GIT_DIR
 
-git config core.bare false
-test_rev_parse -C work 'GIT_DIR=../.git, core.bare = false' false false true ''
+test_rev_parse -C work -b f 'GIT_DIR=../.git, core.bare = false' false false true ''
 
-git config core.bare true
-test_rev_parse -C work 'GIT_DIR=../.git, core.bare = true' true false false ''
+test_rev_parse -C work -b t 'GIT_DIR=../.git, core.bare = true' true false false ''
 
-git config --unset core.bare
-test_rev_parse -C work 'GIT_DIR=../.git, core.bare undefined' false false true ''
+test_rev_parse -C work -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
 GIT_DIR=../repo.git
-GIT_CONFIG="$(pwd)/work/../repo.git/config"
 
-git config core.bare false
-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = false' false false true ''
+test_rev_parse -C work -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''
 
-git config core.bare true
-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare = true' true false false ''
+test_rev_parse -C work -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''
 
-git config --unset core.bare
-test_rev_parse -C work 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
+test_rev_parse -C work -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
 
 test_done
--
2.8.2.703.g78b384c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2 5/5] t1500: avoid setting environment variables outside of tests

Eric Sunshine
In reply to this post by Eric Sunshine
Ideally, each test should be responsible for setting up state it needs
rather than relying upon transient global state. Toward this end, teach
test_rev_parse() to accept a "-g <dir>" option to allow callers to
specify the value of the GIT_DIR environment variable explicitly. Take
advantage of this new option to avoid polluting the global scope with
GIT_DIR assignments.

Implementation note: Typically, tests avoid polluting the global state
by wrapping transient environment variable assignments within a
subshell, however, this technique doesn't work here since test_config()
and test_unconfig() need to know GIT_DIR, as well, but neither function
can be used within a subshell. Consequently, GIT_DIR is instead cleared
manually via test_when_finished().

Signed-off-by: Eric Sunshine <[hidden email]>
---
 t/t1500-rev-parse.sh | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 5be463f..39af565 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -7,6 +7,7 @@ test_description='test git rev-parse'
 test_rev_parse () {
  dir=
  bare=
+ gitdir=
  while :
  do
  case "$1" in
@@ -15,6 +16,7 @@ test_rev_parse () {
     [tfu]*) bare="$2"; shift; shift ;;
     *) error "test_rev_parse: bogus core.bare value '$2'" ;;
     esac ;;
+ -g) gitdir="$2"; shift; shift ;;
  -*) error "test_rev_parse: unrecognized option '$1'" ;;
  *) break ;;
  esac
@@ -32,6 +34,13 @@ test_rev_parse () {
  test $# -eq 0 && break
  expect="$1"
  test_expect_success "$name: $o" '
+ if test -n "$gitdir"
+ then
+ test_when_finished "unset GIT_DIR" &&
+ GIT_DIR="$gitdir" &&
+ export GIT_DIR
+ fi &&
+
  case "$bare" in
  t*) test_config ${dir:+-C "$dir"} core.bare true ;;
  f*) test_config ${dir:+-C "$dir"} core.bare false ;;
@@ -64,21 +73,18 @@ test_rev_parse -b t 'core.bare = true' true false false
 
 test_rev_parse -b u 'core.bare undefined' false false true
 
-GIT_DIR=../.git
-export GIT_DIR
 
-test_rev_parse -C work -b f 'GIT_DIR=../.git, core.bare = false' false false true ''
+test_rev_parse -C work -g ../.git -b f 'GIT_DIR=../.git, core.bare = false' false false true ''
 
-test_rev_parse -C work -b t 'GIT_DIR=../.git, core.bare = true' true false false ''
+test_rev_parse -C work -g ../.git -b t 'GIT_DIR=../.git, core.bare = true' true false false ''
 
-test_rev_parse -C work -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''
+test_rev_parse -C work -g ../.git -b u 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
-GIT_DIR=../repo.git
 
-test_rev_parse -C work -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''
+test_rev_parse -C work -g ../repo.git -b f 'GIT_DIR=../repo.git, core.bare = false' false false true ''
 
-test_rev_parse -C work -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''
+test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = true' true false false ''
 
-test_rev_parse -C work -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
+test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
 
 test_done
--
2.8.2.703.g78b384c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Junio C Hamano
In reply to this post by Eric Sunshine
Eric Sunshine <[hidden email]> writes:

> + git ${dir:+-C "$dir"} rev-parse --$o >actual &&

This is kosher POSIX, but I vaguely recall some shells had trouble
with the SP between -C and "$dir" in the past.  Let's see if anybody
screams; hopefully I am misremembering or buggy shells died out.

Other than that, the entire series makes the script easier to grok.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Eric Sunshine
On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]> wrote:
> Eric Sunshine <[hidden email]> writes:
>> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
>
> This is kosher POSIX, but I vaguely recall some shells had trouble
> with the SP between -C and "$dir" in the past.  Let's see if anybody
> screams; hopefully I am misremembering or buggy shells died out.

I also am bothered by a vague recollection of some issue (possibly
involving the internal space and lack of quotes around the entire
${...}), but couldn't remember nor find a reference to the specific
details. Perhaps someone reading the patch has a better memory than I.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Jeff King
On Tue, May 17, 2016 at 04:48:33PM -0400, Eric Sunshine wrote:

> On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]> wrote:
> > Eric Sunshine <[hidden email]> writes:
> >> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
> >
> > This is kosher POSIX, but I vaguely recall some shells had trouble
> > with the SP between -C and "$dir" in the past.  Let's see if anybody
> > screams; hopefully I am misremembering or buggy shells died out.
>
> I also am bothered by a vague recollection of some issue (possibly
> involving the internal space and lack of quotes around the entire
> ${...}), but couldn't remember nor find a reference to the specific
> details. Perhaps someone reading the patch has a better memory than I.

Probably:

  http://thread.gmane.org/gmane.comp.version-control.git/265094

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Eric Sunshine
On Tue, May 17, 2016 at 5:52 PM, Jeff King <[hidden email]> wrote:

> On Tue, May 17, 2016 at 04:48:33PM -0400, Eric Sunshine wrote:
>> On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]> wrote:
>> > Eric Sunshine <[hidden email]> writes:
>> >> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
>> >
>> > This is kosher POSIX, but I vaguely recall some shells had trouble
>> > with the SP between -C and "$dir" in the past.  Let's see if anybody
>> > screams; hopefully I am misremembering or buggy shells died out.
>>
>> I also am bothered by a vague recollection of some issue (possibly
>> involving the internal space and lack of quotes around the entire
>> ${...}), but couldn't remember nor find a reference to the specific
>> details. Perhaps someone reading the patch has a better memory than I.
>
>   http://thread.gmane.org/gmane.comp.version-control.git/265094

Thanks for the link. I just tested with FreeBSD 8, and the shell
indeed exhibits that broken behavior. The workaround in Kyle's patch
isn't the prettiest (and is a bit verbose), but it gets the job done.

I can send v3 using that workaround unless Junio wants to patch it locally(?).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Junio C Hamano
In reply to this post by Jeff King
Jeff King <[hidden email]> writes:

> On Tue, May 17, 2016 at 04:48:33PM -0400, Eric Sunshine wrote:
>
>> On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]> wrote:
>> > Eric Sunshine <[hidden email]> writes:
>> >> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
>> >
>> > This is kosher POSIX, but I vaguely recall some shells had trouble
>> > with the SP between -C and "$dir" in the past.  Let's see if anybody
>> > screams; hopefully I am misremembering or buggy shells died out.
>>
>> I also am bothered by a vague recollection of some issue (possibly
>> involving the internal space and lack of quotes around the entire
>> ${...}), but couldn't remember nor find a reference to the specific
>> details. Perhaps someone reading the patch has a better memory than I.
>
> Probably:
>
>   http://thread.gmane.org/gmane.comp.version-control.git/265094

Yikes, you're right.  Does anybody know if FreeBSD shell is still
buggy?


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

SZEDER Gábor

Quoting Junio C Hamano <[hidden email]>:

> Jeff King <[hidden email]> writes:
>
>> On Tue, May 17, 2016 at 04:48:33PM -0400, Eric Sunshine wrote:
>>
>>> On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]> wrote:
>>>> Eric Sunshine <[hidden email]> writes:
>>>>> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
>>>>
>>>> This is kosher POSIX, but I vaguely recall some shells had trouble
>>>> with the SP between -C and "$dir" in the past.  Let's see if anybody
>>>> screams; hopefully I am misremembering or buggy shells died out.
>>>
>>> I also am bothered by a vague recollection of some issue (possibly
>>> involving the internal space and lack of quotes around the entire
>>> ${...}), but couldn't remember nor find a reference to the specific
>>> details. Perhaps someone reading the patch has a better memory than I.
>>
>> Probably:
>>
>>  http://thread.gmane.org/gmane.comp.version-control.git/265094

And ea10b60c910e (Work around ash "alternate value" expansion bug,
2009-04-18) as well.

    http://thread.gmane.org/gmane.comp.version-control.git/116816

> Yikes, you're right.  Does anybody know if FreeBSD shell is still
> buggy?

git-submodule.sh contains a few offending constructs:

        git submodule--helper update-clone ${GIT_QUIET:+--quiet} \
                ${wt_prefix:+--prefix "$wt_prefix"} \
                ${prefix:+--recursive-prefix "$prefix"} \
                ${update:+--update "$update"} \
                ${reference:+--reference "$reference"} \
                ${depth:+--depth "$depth"} \
                "$@" || echo "#unmatched"
        } | {

They were added recently in 48308681b072 (git submodule update: have
a dedicated helper for cloning, 2016-02-29), which is not in any
release yet, perhaps that's why noone complained yet.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 3/5] t1500: avoid changing working directory outside of tests

Eric Sunshine
On Tue, May 17, 2016 at 7:06 PM, SZEDER Gábor <[hidden email]> wrote:

> Quoting Junio C Hamano <[hidden email]>:
>> Jeff King <[hidden email]> writes:
>>> On Tue, May 17, 2016 at 04:48:33PM -0400, Eric Sunshine wrote:
>>>> On Tue, May 17, 2016 at 4:37 PM, Junio C Hamano <[hidden email]>
>>>> wrote:
>>>>> Eric Sunshine <[hidden email]> writes:
>>>>>> +                     git ${dir:+-C "$dir"} rev-parse --$o >actual &&
>>>>>
>>>>> This is kosher POSIX, but I vaguely recall some shells had trouble
>>>>> with the SP between -C and "$dir" in the past.  Let's see if anybody
>>>>> screams; hopefully I am misremembering or buggy shells died out.
>>>>
>>>> I also am bothered by a vague recollection of some issue (possibly
>>>> involving the internal space and lack of quotes around the entire
>>>> ${...}), but couldn't remember nor find a reference to the specific
>>>> details. Perhaps someone reading the patch has a better memory than I.
>>>
>>> Probably:
>>>  http://thread.gmane.org/gmane.comp.version-control.git/265094
>
> And ea10b60c910e (Work around ash "alternate value" expansion bug,
> 2009-04-18) as well.
>
>    http://thread.gmane.org/gmane.comp.version-control.git/116816

Thanks for the additional link. I have v3 ready to roll and will send
it out within the next day if no more actionable review comments
arrive.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 2/5] t1500: test_rev_parse: facilitate future test enhancements

SZEDER Gábor
In reply to this post by Eric Sunshine

Quoting Eric Sunshine <[hidden email]>:

> Tests run by test_rev_parse() are nearly identical; each invokes
> git-rev-parse with a single option and compares the result against an
> expected value. Such duplication makes it onerous to extend the tests
> since any change needs to be repeated in each test. Avoid the
> duplication by parameterizing the test and driving it via a for-loop.
>
> Signed-off-by: Eric Sunshine <[hidden email]>
> ---
>  t/t1500-rev-parse.sh | 44 +++++++++++++++++---------------------------
>  1 file changed, 17 insertions(+), 27 deletions(-)
>
> diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
> index 0194f54..c84f5c3 100755
> --- a/t/t1500-rev-parse.sh
> +++ b/t/t1500-rev-parse.sh

> + for o in is-bare-repository \
> + is-inside-git-dir \
> + is-inside-work-tree \
> + show-prefix \
> + git-dir
> + do
> + test $# -eq 0 && break
> + expect="$1"
> + test_expect_success "$name: $o" '
> + echo "$expect" >expect &&
> + git rev-parse --$o >actual &&

I think that "--$o" looks really weird, but that's subjective, of course.

However, the idea popped up in an other thread[1] that we might want
something like 'git rev-parse --absolute-path --git-dir', which wouldn't
really work with '--$o'.

Even if we don't go that route, perhaps it would be better to list the
options to be tested including their doubledash prefix.


[1] -  
http://thread.gmane.org/gmane.comp.version-control.git/287449/focus=292585


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 2/5] t1500: test_rev_parse: facilitate future test enhancements

Eric Sunshine
On Wed, May 18, 2016 at 12:38 PM, SZEDER Gábor <[hidden email]> wrote:

> Quoting Eric Sunshine <[hidden email]>:
>> +       for o in is-bare-repository \
>> +                is-inside-git-dir \
>> +                is-inside-work-tree \
>> +                show-prefix \
>> +                git-dir
>> +       do
>> +               test $# -eq 0 && break
>> +               expect="$1"
>> +               test_expect_success "$name: $o" '
>> +                       echo "$expect" >expect &&
>> +                       git rev-parse --$o >actual &&
>
> I think that "--$o" looks really weird, but that's subjective, of course.
>
> However, the idea popped up in an other thread[1] that we might want
> something like 'git rev-parse --absolute-path --git-dir', which wouldn't
> really work with '--$o'.
>
> Even if we don't go that route, perhaps it would be better to list the
> options to be tested including their doubledash prefix.

As this series is only about modernizing t1500, I'd prefer to keep the
conversion faithful to the original which titles each test "$name:
is-bare-repository", "$name: is-inside-git-dir", etc., and the current
approach does so without additional complexity.

I have no objection to upgrading the for-loop items to include the
leading dashes or updating the logic to support --absolute-path, but
such changes are outside the scope of this series and can easily be
built atop it. Also, due to severe time constraints, I'd rather not
re-roll only for a superficial and subjective change such as adding
leading dashes to for-loop items.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v2 2/5] t1500: test_rev_parse: facilitate future test enhancements

Eric Sunshine
On Wed, May 18, 2016 at 1:32 PM, Eric Sunshine <[hidden email]> wrote:

> On Wed, May 18, 2016 at 12:38 PM, SZEDER Gábor <[hidden email]> wrote:
>> Quoting Eric Sunshine <[hidden email]>:
>>> +       for o in is-bare-repository \
>>> +                is-inside-git-dir \
>>> +                is-inside-work-tree \
>>> +                show-prefix \
>>> +                git-dir
>>> +       do
>>> +               test $# -eq 0 && break
>>> +               expect="$1"
>>> +               test_expect_success "$name: $o" '
>>> +                       echo "$expect" >expect &&
>>> +                       git rev-parse --$o >actual &&
>>
>> I think that "--$o" looks really weird, but that's subjective, of course.
>>
>> However, the idea popped up in an other thread[1] that we might want
>> something like 'git rev-parse --absolute-path --git-dir', which wouldn't
>> really work with '--$o'.
>>
>> Even if we don't go that route, perhaps it would be better to list the
>> options to be tested including their doubledash prefix.
>
> As this series is only about modernizing t1500, I'd prefer to keep the
> conversion faithful to the original which titles each test "$name:
> is-bare-repository", "$name: is-inside-git-dir", etc., and the current
> approach does so without additional complexity.
>
> I have no objection to upgrading the for-loop items to include the
> leading dashes or updating the logic to support --absolute-path, but
> such changes are outside the scope of this series and can easily be
> built atop it. Also, due to severe time constraints, I'd rather not
> re-roll only for a superficial and subjective change such as adding
> leading dashes to for-loop items.

On reflection, I agree with your points and will include the change in
the re-roll. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Loading...