From: Robert Luberda <robert@debian.org>
To: Eric Wong <normalperson@yhbt.net>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Cc: Robert Luberda <robert@debian.org>
Subject: [PATCH] t9164: More style fixes
Date: Fri, 31 Aug 2012 08:29:39 +0200 [thread overview]
Message-ID: <1346394580-12083-1-git-send-email-robert@debian.org> (raw)
In-Reply-To: <20120826003430.GA32346@dcvr.yhbt.net>
Make sure t9164 conforms with the coding guidelines:
- remove spaces after redirection operators;
- insert spaces between function names and parentheses;
- split `if ...; then' lines;
- use `test' instead of `['.
Signed-off-by: Robert Luberda <robert@debian.org>
---
t/t9164-git-svn-dcommit-concurrent.sh | 69 ++++++++++++++++-----------------
1 file changed, 33 insertions(+), 36 deletions(-)
diff --git a/t/t9164-git-svn-dcommit-concurrent.sh b/t/t9164-git-svn-dcommit-concurrent.sh
index d8464d4..d75ebdc 100755
--- a/t/t9164-git-svn-dcommit-concurrent.sh
+++ b/t/t9164-git-svn-dcommit-concurrent.sh
@@ -12,16 +12,15 @@ test_expect_success 'setup svn repository' '
svn_cmd checkout "$svnrepo" work.svn &&
(
cd work.svn &&
- echo >file && echo > auto_updated_file
+ echo >file && echo >auto_updated_file
svn_cmd add file auto_updated_file &&
svn_cmd commit -m "initial commit"
) &&
svn_cmd checkout "$svnrepo" work-auto-commits.svn
'
N=0
-next_N()
-{
- N=$(( $N + 1 ))
+next_N () {
+ N=$(($N + 1))
}
# Setup SVN repository hooks to emulate SVN failures or concurrent commits
@@ -35,39 +34,39 @@ next_N()
# the hook should be applied for (each time the hook is run, the given
# number is decreased by one until it gets 0, in which case the hook
# will execute its real action)
-setup_hook()
-{
+setup_hook () {
hook_type="$1" # "pre-commit" or "post-commit"
skip_revs="$2"
- [ "$hook_type" = "pre-commit" ] ||
- [ "$hook_type" = "post-commit" ] ||
+ test "$hook_type" = "pre-commit" ||
+ test "$hook_type" = "post-commit" ||
{ echo "ERROR: invalid argument ($hook_type)" \
"passed to setup_hook" >&2 ; return 1; }
- echo "cnt=$skip_revs" > "$hook_type-counter"
+ echo "cnt=$skip_revs" >"$hook_type-counter"
rm -f "$rawsvnrepo/hooks/"*-commit # drop previous hooks
hook="$rawsvnrepo/hooks/$hook_type"
- cat > "$hook" <<- 'EOF1'
+ cat >"$hook" <<-'EOF1'
#!/bin/sh
set -e
cd "$1/.." # "$1" is repository location
- exec >> svn-hook.log 2>&1
+ exec >>svn-hook.log 2>&1
hook="$(basename "$0")"
echo "*** Executing $hook $@"
set -x
- . ./$hook-counter
+ . "./$hook-counter"
cnt="$(($cnt - 1))"
- echo "cnt=$cnt" > ./$hook-counter
- [ "$cnt" = "0" ] || exit 0
+ echo "cnt=$cnt" >"./$hook-counter"
+ test "$cnt" = "0" || exit 0
EOF1
- if [ "$hook_type" = "pre-commit" ]; then
+ if test "$hook_type" = "pre-commit"
+ then
echo "echo 'commit disallowed' >&2; exit 1" >>"$hook"
else
echo "PATH=\"$PATH\"; export PATH" >>"$hook"
echo "svnconf=\"$svnconf\"" >>"$hook"
- cat >>"$hook" <<- 'EOF2'
+ cat >>"$hook" <<-'EOF2'
cd work-auto-commits.svn
svn up --config-dir "$svnconf"
- echo "$$" >> auto_updated_file
+ echo "$$" >>auto_updated_file
svn commit --config-dir "$svnconf" \
-m "auto-committing concurrent change"
exit 0
@@ -76,8 +75,7 @@ EOF2
chmod 755 "$hook"
}
-check_contents()
-{
+check_contents () {
gitdir="$1"
(cd ../work.svn && svn_cmd up) &&
test_cmp file ../work.svn/file &&
@@ -89,7 +87,7 @@ test_expect_success 'check if post-commit hook creates a concurrent commit' '
(
cd work.svn &&
cp auto_updated_file au_file_saved &&
- echo 1 >> file &&
+ echo 1 >>file &&
svn_cmd commit -m "changing file" &&
svn_cmd up &&
test_must_fail test_cmp auto_updated_file au_file_saved
@@ -100,9 +98,9 @@ test_expect_success 'check if pre-commit hook fails' '
setup_hook pre-commit 2 &&
(
cd work.svn &&
- echo 2 >> file &&
+ echo 2 >>file &&
svn_cmd commit -m "changing file once again" &&
- echo 3 >> file &&
+ echo 3 >>file &&
test_must_fail svn_cmd commit -m "this commit should fail" &&
svn_cmd revert file
)
@@ -113,9 +111,9 @@ test_expect_success 'dcommit error handling' '
next_N && git svn clone "$svnrepo" work$N.git &&
(
cd work$N.git &&
- echo 1 >> file && git commit -am "commit change $N.1" &&
- echo 2 >> file && git commit -am "commit change $N.2" &&
- echo 3 >> file && git commit -am "commit change $N.3" &&
+ echo 1 >>file && git commit -am "commit change $N.1" &&
+ echo 2 >>file && git commit -am "commit change $N.2" &&
+ echo 3 >>file && git commit -am "commit change $N.3" &&
# should fail to dcommit 2nd and 3rd change
# but still should leave the repository in reasonable state
test_must_fail git svn dcommit &&
@@ -131,9 +129,9 @@ test_expect_success 'dcommit concurrent change in non-changed file' '
next_N && git svn clone "$svnrepo" work$N.git &&
(
cd work$N.git &&
- echo 1 >> file && git commit -am "commit change $N.1" &&
- echo 2 >> file && git commit -am "commit change $N.2" &&
- echo 3 >> file && git commit -am "commit change $N.3" &&
+ echo 1 >>file && git commit -am "commit change $N.1" &&
+ echo 2 >>file && git commit -am "commit change $N.2" &&
+ echo 3 >>file && git commit -am "commit change $N.3" &&
# should rebase and leave the repository in reasonable state
git svn dcommit &&
git update-index --refresh &&
@@ -146,10 +144,9 @@ test_expect_success 'dcommit concurrent change in non-changed file' '
'
# An utility function used in the following test
-delete_first_line()
-{
+delete_first_line () {
file="$1" &&
- sed 1d < "$file" > "${file}.tmp" &&
+ sed 1d <"$file" >"${file}.tmp" &&
rm "$file" &&
mv "${file}.tmp" "$file"
}
@@ -159,7 +156,7 @@ test_expect_success 'dcommit concurrent non-conflicting change' '
next_N && git svn clone "$svnrepo" work$N.git &&
(
cd work$N.git &&
- cat file >> auto_updated_file &&
+ cat file >>auto_updated_file &&
git commit -am "commit change $N.1" &&
delete_first_line auto_updated_file &&
git commit -am "commit change $N.2" &&
@@ -181,7 +178,7 @@ test_expect_success 'dcommit --no-rebase concurrent non-conflicting change' '
next_N && git svn clone "$svnrepo" work$N.git &&
(
cd work$N.git &&
- cat file >> auto_updated_file &&
+ cat file >>auto_updated_file &&
git commit -am "commit change $N.1" &&
delete_first_line auto_updated_file &&
git commit -am "commit change $N.2" &&
@@ -202,11 +199,11 @@ test_expect_success 'dcommit fails on concurrent conflicting change' '
next_N && git svn clone "$svnrepo" work$N.git &&
(
cd work$N.git &&
- echo a >> file &&
+ echo a >>file &&
git commit -am "commit change $N.1" &&
- echo b >> auto_updated_file &&
+ echo b >>auto_updated_file &&
git commit -am "commit change $N.2" &&
- echo c >> auto_updated_file &&
+ echo c >>auto_updated_file &&
git commit -am "commit change $N.3" &&
test_must_fail git svn dcommit && # rebase should fail
test_must_fail git update-index --refresh
--
1.7.10.4
next prev parent reply other threads:[~2012-08-31 6:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-01 21:26 [PATCH/RFC] git svn: handle errors and concurrent commits in dcommit Robert Luberda
2012-08-02 10:44 ` Eric Wong
2012-08-08 5:32 ` Robert Luberda
2012-08-08 5:35 ` Robert Luberda
2012-08-08 23:07 ` Eric Wong
2012-08-09 17:44 ` Junio C Hamano
2012-08-10 19:51 ` Eric Wong
2012-08-19 22:43 ` Robert Luberda
2012-08-20 1:20 ` Junio C Hamano
2012-08-21 22:01 ` Eric Wong
2012-08-24 23:47 ` Robert Luberda
2012-08-26 0:34 ` Eric Wong
2012-08-31 6:29 ` Robert Luberda [this message]
2012-08-31 18:01 ` [PATCH] t9164: More style fixes Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346394580-12083-1-git-send-email-robert@debian.org \
--to=robert@debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).