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 1/4] t4041 (diff-submodule-option): parse digests sensibly
Date: Tue, 27 Nov 2012 14:11:29 +0530	[thread overview]
Message-ID: <1354005692-2809-2-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1354005692-2809-1-git-send-email-artagnon@gmail.com>

`git rev-list --max-count=1 HEAD` is a roundabout way of saying `git
rev-parse --verify HEAD`; replace a bunch of instances of the former
with the latter.  Also, don't unnecessarily `cut -c1-7` the rev-parse
output when the `--short` option is available.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t4041-diff-submodule-option.sh |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 5377639..cfb71e5 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -21,7 +21,7 @@ add_file () {
 		test_tick &&
 		git commit -m "Add $name"
 	done >/dev/null
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --short --verify HEAD
 	cd "$owd"
 }
 commit_file () {
@@ -33,7 +33,7 @@ test_create_repo sm1 &&
 add_file . foo >/dev/null
 
 head1=$(add_file sm1 foo1 foo2)
-fullhead1=$(cd sm1; git rev-list --max-count=1 $head1)
+fullhead1=$(cd sm1; git rev-parse --verify $head1)
 
 test_expect_success 'added submodule' "
 	git add sm1 &&
@@ -116,8 +116,8 @@ EOF
 	test_cmp expected actual
 "
 
-fullhead2=$(cd sm1; git rev-list --max-count=1 $head2)
 test_expect_success 'modified submodule(forward) --submodule=short' "
+fullhead2=$(cd sm1; git rev-parse --verify $head2)
 	git diff --submodule=short >actual &&
 	cat >expected <<-EOF &&
 diff --git a/sm1 b/sm1
@@ -135,7 +135,7 @@ commit_file sm1 &&
 head3=$(
 	cd sm1 &&
 	git reset --hard HEAD~2 >/dev/null &&
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --short --verify HEAD
 )
 
 test_expect_success 'modified submodule(backward)' "
@@ -220,8 +220,8 @@ EOF
 rm -f sm1 &&
 test_create_repo sm1 &&
 head6=$(add_file sm1 foo6 foo7)
-fullhead6=$(cd sm1; git rev-list --max-count=1 $head6)
 test_expect_success 'nonexistent commit' "
+fullhead6=$(cd sm1; git rev-parse --verify $head6)
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 Submodule sm1 $head4...$head6 (commits not present)
@@ -318,8 +318,8 @@ EOF
 "
 
 (cd sm1; git commit -mchange foo6 >/dev/null) &&
-head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) &&
 test_expect_success 'submodule is modified' "
+head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 Submodule sm1 $head6..$head8:
@@ -461,7 +461,7 @@ EOF
 	test_cmp expected actual
 "
 
-fullhead7=$(cd sm2; git rev-list --max-count=1 $head7)
+fullhead7=$(cd sm2; git rev-parse --verify $head7)
 
 test_expect_success 'given commit --submodule=short' "
 	git diff-index -p --submodule=short HEAD^ >actual &&
-- 
1.7.8.1.362.g5d6df.dirty

  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 ` Ramkumar Ramachandra [this message]
2012-11-27 17:38   ` [PATCH 1/4] t4041 (diff-submodule-option): parse digests sensibly Junio C Hamano
2012-11-27  8:41 ` [PATCH 2/4] t4041 (diff-submodule-option): rewrite add_file() routine Ramkumar Ramachandra
2012-11-27 17:56   ` 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-2-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).