[PATCH v2] subtree: fix argument handling in check_parents
- From
James Limbouris via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Dec 2, 2021, 05:51 UTC
- Message-ID
- <pull.1086.v2.git.1638424290015.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1086.git.1638324413653.gitgitgadget@gmail.com>
From: James Limbouris <james@digitalmatter.com>
check_parents was taking all of its arguments as a single string, and erroneously passing them to cache_miss as a single string. cache_miss would then fail, and the spurious cache misses it produced would hurt performance.
For consistency, take multiple arguments in check_parents, and pass all of them to cache_miss separately.
Signed-off-by: James Limbouris <james@digitalmatter.com>
---
subtree: fix argument handling in check_parents
> It seems that 315a84f9 (subtree: use commits before rejoins for
> splits, 2018-09-28) is what broke the logic, but it does not look like
> a coding style clean-up to me.
Sorry - you're right. I thought it was 6ae6a2 (subtree: adjust style to
match CodingGuidelines) that broke it, but it was actually the addition
of quotes in the check_parents and cache_miss calls of 315a84f9.
> so writing "$@" is much more preferrable over $*
Yes agreed - thanks!Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1086%2Fjamesl-dm%2Fmaint-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1086/jamesl-dm/maint-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/1086
Range-diff vs v1:
1: 11b65a7b3a5 ! 1: 1198a84995b subtree: fix argument handling in check_parents
@@ contrib/subtree/git-subtree.sh: cache_miss () {
check_parents () {
- assert test $# = 1
- missed=$(cache_miss "$1") || exit $?
-+ missed=$(cache_miss $*) || exit $?
++ missed=$(cache_miss "$@") || exit $?
local indent=$(($indent + 1))
for miss in $missed
docontrib/subtree/git-subtree.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index 7f767b5c38f..71f1fd94bde 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -296,10 +296,9 @@ cache_miss () { done } -# Usage: check_parents PARENTS_EXPR +# Usage: check_parents [REVS...] check_parents () { - assert test $# = 1 - missed=$(cache_miss "$1") || exit $? + missed=$(cache_miss "$@") || exit $? local indent=$(($indent + 1)) for miss in $missed do @@ -753,7 +752,7 @@ process_split_commit () { fi createcount=$(($createcount + 1)) debug "parents: $parents" - check_parents "$parents" + check_parents $parents newparents=$(cache_get $parents) || exit $? debug "newparents: $newparents" base-commit: e9d7761bb94f20acc98824275e317fa82436c25d
-- gitgitgadget