t/lib-t6000: style fixes
Mostly fixes to initial indentation with 8-SP (they should be HT) and wrapping long lines. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 21, 2013 at 10:12 UTC
50e5a252225137f0fbb18a0ff72a0ae052e09d24
1 file changed
+40
-47
t/lib-t6000.sh
+40
-47
@@ -1,55 +1,50 @@
1
: included from 6002 and others
2
3
-[ -d .git/refs/tags ] || mkdir -p .git/refs/tags
3
+mkdir -p .git/refs/tags
4
5
-:> sed.script
5
+>sed.script
6
7
-# Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags
8
-tag()
9
-{
7
+# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
8
+tag () {
9
_tag=$1
11
- [ -f .git/refs/tags/$_tag ] || error "tag: \"$_tag\" does not exist"
12
- cat .git/refs/tags/$_tag
10
+ test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
11
+ cat ".git/refs/tags/$_tag"
12
}
13
14
# Generate a commit using the text specified to make it unique and the tree
15
# named by the tag specified.
17
-unique_commit()
18
-{
16
+unique_commit () {
17
_text=$1
20
- _tree=$2
18
+ _tree=$2
19
shift 2
22
- echo $_text | git commit-tree $(tag $_tree) "$@"
20
+ echo "$_text" | git commit-tree $(tag "$_tree") "$@"
21
}
22
23
# Save the output of a command into the tag specified. Prepend
24
# a substitution script for the tag onto the front of sed.script
27
-save_tag()
28
-{
25
+save_tag () {
26
_tag=$1
30
- [ -n "$_tag" ] || error "usage: save_tag tag commit-args ..."
27
+ test -n "$_tag" || error "usage: save_tag tag commit-args ..."
28
shift 1
32
- "$@" >.git/refs/tags/$_tag
29
+ "$@" >".git/refs/tags/$_tag"
30
34
- echo "s/$(tag $_tag)/$_tag/g" > sed.script.tmp
35
- cat sed.script >> sed.script.tmp
31
+ echo "s/$(tag $_tag)/$_tag/g" >sed.script.tmp
32
+ cat sed.script >>sed.script.tmp
33
rm sed.script
34
mv sed.script.tmp sed.script
35
}
36
37
# Replace unhelpful sha1 hashses with their symbolic equivalents
41
-entag()
42
-{
38
+entag () {
39
sed -f sed.script
40
}
41
42
# Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL
43
# tag to a specified value. Restore the original value on return.
48
-as_author()
49
-{
44
+as_author () {
45
_author=$1
46
shift 1
52
- _save=$GIT_AUTHOR_EMAIL
47
+ _save=$GIT_AUTHOR_EMAIL
48
49
GIT_AUTHOR_EMAIL="$_author"
50
export GIT_AUTHOR_EMAIL
@@ -63,45 +58,41 @@ as_author()
58
fi
59
}
60
66
-commit_date()
67
-{
68
- _commit=$1
69
- git cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
61
+commit_date () {
62
+ _commit=$1
63
+ git cat-file commit $_commit |
64
+ sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
65
}
66
72
-on_committer_date()
73
-{
74
- _date=$1
75
- shift 1
76
- GIT_COMMITTER_DATE="$_date"
77
- export GIT_COMMITTER_DATE
78
- "$@"
79
- unset GIT_COMMITTER_DATE
67
+on_committer_date () {
68
+ _date=$1
69
+ shift 1
70
+ GIT_COMMITTER_DATE="$_date"
71
+ export GIT_COMMITTER_DATE
72
+ "$@"
73
+ unset GIT_COMMITTER_DATE
74
}
75
76
# Execute a command and suppress any error output.
83
-hide_error()
84
-{
77
+hide_error () {
78
"$@" 2>/dev/null
79
}
80
88
-check_output()
89
-{
81
+check_output () {
82
_name=$1
83
shift 1
92
- if eval "$*" | entag > $_name.actual
84
+ if eval "$*" | entag >"$_name.actual"
85
then
94
- test_cmp $_name.expected $_name.actual
86
+ test_cmp "$_name.expected" "$_name.actual"
87
else
96
- return 1;
88
+ return 1
89
fi
90
}
91
92
# Turn a reasonable test description into a reasonable test name.
93
# All alphanums translated into -'s which are then compressed and stripped
94
# from front and back.
103
-name_from_description()
104
-{
95
+name_from_description () {
96
perl -pe '
97
s/[^A-Za-z0-9.]/-/g;
98
s/-+/-/g;
@@ -119,9 +110,11 @@ name_from_description()
110
test_output_expect_success()
111
{
112
_description=$1
122
- _test=$2
123
- [ $# -eq 2 ] || error "usage: test_output_expect_success description test <<EOF ... EOF"
124
- _name=$(echo $_description | name_from_description)
125
- cat > $_name.expected
113
+ _test=$2
114
+ test $# -eq 2 ||
115
+ error "usage: test_output_expect_success description test <<EOF ... EOF"
116
+
117
+ _name=$(echo $_description | name_from_description)
118
+ cat >"$_name.expected"
119
test_expect_success "$_description" "check_output $_name \"$_test\""
120
}