git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 2/4] t4041 (diff-submodule-option): rewrite add_file() routine
Date: Tue, 27 Nov 2012 14:11:30 +0530	[thread overview]
Message-ID: <1354005692-2809-3-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1354005692-2809-1-git-send-email-artagnon@gmail.com>

Instead of "cd there and then come back", use the "cd there in a
subshell" pattern.  Also fix '&&' chaining in one place.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t4041-diff-submodule-option.sh |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index cfb71e5..103c690 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,18 +11,15 @@ This test tries to verify the sanity of the --submodule option of git diff.
 . ./test-lib.sh
 
 add_file () {
-	sm=$1
-	shift
-	owd=$(pwd)
-	cd "$sm"
-	for name; do
+	(cd "$1" &&
+	    shift &&
+	    for name; do
 		echo "$name" > "$name" &&
 		git add "$name" &&
 		test_tick &&
 		git commit -m "Add $name"
-	done >/dev/null
-	git rev-parse --short --verify HEAD
-	cd "$owd"
+	    done >/dev/null &&
+	    git rev-parse --short --verify HEAD)
 }
 commit_file () {
 	test_tick &&
-- 
1.7.8.1.362.g5d6df.dirty

  parent reply	other threads:[~2012-11-27  8:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27  8:41 [PATCH 0/4] t4041 (diff-submodule-option): minor cleanup Ramkumar Ramachandra
2012-11-27  8:41 ` [PATCH 1/4] t4041 (diff-submodule-option): parse digests sensibly Ramkumar Ramachandra
2012-11-27 17:38   ` Junio C Hamano
2012-11-27  8:41 ` Ramkumar Ramachandra [this message]
2012-11-27 17:56   ` [PATCH 2/4] t4041 (diff-submodule-option): rewrite add_file() routine Junio C Hamano
2012-11-27  8:41 ` [PATCH 3/4] t4041 (diff-submodule-option): modernize style Ramkumar Ramachandra
2012-11-27  8:41 ` [PATCH 4/4] t4041 (diff-submodule-option): change tense of test names Ramkumar Ramachandra
2012-11-27 17:51   ` 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=1354005692-2809-3-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    /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).