From: Jiang Xin <worldhello.net@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Git List" <git@vger.kernel.org>,
"Nicolas Pitre" <nico@fluxnic.net>
Cc: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Subject: [PATCH 3/4] test: refactor to use "test_commit" to create commits
Date: Thu, 17 Jun 2021 11:17:26 +0800 [thread overview]
Message-ID: <20210617031727.81105-3-zhiyou.jx@alibaba-inc.com> (raw)
In-Reply-To: <20210617031727.81105-1-zhiyou.jx@alibaba-inc.com>
Refactor function "create_commits_in" to use "test_commit" to create
commit.
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
---
t/t5411/common-functions.sh | 25 ++++++-------------------
t/t5548-push-porcelain.sh | 25 ++++++-------------------
2 files changed, 12 insertions(+), 38 deletions(-)
diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh
index 6c347b4caa..b9c6adecf5 100644
--- a/t/t5411/common-functions.sh
+++ b/t/t5411/common-functions.sh
@@ -6,29 +6,16 @@
# NOTE: Never calling this function from a subshell since variable
# assignments will disappear when subshell exits.
create_commits_in () {
- repo="$1" &&
- if ! parent=$(git -C "$repo" rev-parse HEAD^{} --)
- then
- parent=
- fi &&
- T=$(git -C "$repo" write-tree) &&
+ repo="$1" && test -d "$repo" ||
+ error "Repository $repo does not exist."
shift &&
while test $# -gt 0
do
name=$1 &&
- test_tick &&
- if test -z "$parent"
- then
- oid=$(echo $name | git -C "$repo" commit-tree $T)
- else
- oid=$(echo $name | git -C "$repo" commit-tree -p $parent $T)
- fi &&
- eval $name=$oid &&
- parent=$oid &&
- shift ||
- return 1
- done &&
- git -C "$repo" update-ref refs/heads/main $oid
+ shift &&
+ test_commit -C "$repo" --no-tag "$name" &&
+ eval $name=$(git -C "$repo" rev-parse HEAD)
+ done
}
# Format the output of git-push, git-show-ref and other commands to make a
diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh
index 2ab7c3cf5a..c8f18a7a12 100755
--- a/t/t5548-push-porcelain.sh
+++ b/t/t5548-push-porcelain.sh
@@ -14,29 +14,16 @@ test_description='Test git push porcelain output'
# NOTE: Never calling this function from a subshell since variable
# assignments will disappear when subshell exits.
create_commits_in () {
- repo="$1" &&
- if ! parent=$(git -C "$repo" rev-parse HEAD^{} --)
- then
- parent=
- fi &&
- T=$(git -C "$repo" write-tree) &&
+ repo="$1" && test -d "$repo" ||
+ error "Repository $repo does not exist."
shift &&
while test $# -gt 0
do
name=$1 &&
- test_tick &&
- if test -z "$parent"
- then
- oid=$(echo $name | git -C "$repo" commit-tree $T)
- else
- oid=$(echo $name | git -C "$repo" commit-tree -p $parent $T)
- fi &&
- eval $name=$oid &&
- parent=$oid &&
- shift ||
- return 1
- done &&
- git -C "$repo" update-ref refs/heads/main $oid
+ shift &&
+ test_commit -C "$repo" --no-tag "$name" &&
+ eval $name=$(git -C "$repo" rev-parse HEAD)
+ done
}
# Format the output of git-push, git-show-ref and other commands to make a
--
2.32.0.rc0.27.g7b1e85181b
next prev parent reply other threads:[~2021-06-17 3:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 3:17 [PATCH 1/4] sideband: don't lose clear-to-eol at packet boundary Jiang Xin
2021-06-17 3:17 ` [PATCH 2/4] test: compare raw output, not mangle tabs and spaces Jiang Xin
2021-06-17 3:17 ` Jiang Xin [this message]
2021-06-17 3:17 ` [PATCH 4/4] test: refactor to use "get_abbrev_oid" to get abbrev oid Jiang Xin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210617031727.81105-3-zhiyou.jx@alibaba-inc.com \
--to=worldhello.net@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nico@fluxnic.net \
--cc=zhiyou.jx@alibaba-inc.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).