From 3c06a583398f6630c7162b463ff1acbdf0110f83 Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Thu, 17 Jun 2021 11:17:26 +0800 Subject: test: refactor to use "test_commit" to create commits Refactor function "create_commits_in" to use "test_commit" to create commit. Signed-off-by: Jiang Xin Signed-off-by: Junio C Hamano --- t/t5411/common-functions.sh | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 't/t5411') 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 -- cgit v1.2.3