git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 3/4] t4041 (diff-submodule-option): rewrite add_file() routine
Date: Fri, 30 Nov 2012 17:07:35 +0530	[thread overview]
Message-ID: <1354275456-11104-4-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1354275456-11104-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 |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 08d549a..d745197 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,18 +11,17 @@ 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
-		echo "$name" > "$name" &&
-		git add "$name" &&
-		test_tick &&
-		git commit -m "Add $name"
-	done >/dev/null
-	git rev-parse --short --verify HEAD
-	cd "$owd"
+	(
+		cd "$1" &&
+		shift &&
+		for name; do
+			echo "$name" > "$name" &&
+			git add "$name" &&
+			test_tick &&
+			git commit -m "Add $name" || exit
+		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-30 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 11:37 [PATCH v2 0/4] t4041 (diff-submodule-option): minor cleanup Ramkumar Ramachandra
2012-11-30 11:37 ` [PATCH v2 1/4] t4041 (diff-submodule-option): don't hardcode SHA-1 in expected outputs Ramkumar Ramachandra
2012-11-30 11:37 ` [PATCH v2 2/4] t4041 (diff-submodule-option): parse digests sensibly Ramkumar Ramachandra
2012-11-30 11:37 ` Ramkumar Ramachandra [this message]
2012-11-30 11:37 ` [PATCH v2 4/4] t4041 (diff-submodule-option): modernize style Ramkumar Ramachandra

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=1354275456-11104-4-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).