From: Junio C Hamano <gitster@pobox.com>
To: "James Limbouris via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, James Limbouris <james@digitalmatter.com>
Subject: Re: [PATCH] subtree: fix argument handling in check_parents
Date: Wed, 01 Dec 2021 15:04:51 -0800 [thread overview]
Message-ID: <xmqq1r2wylik.fsf@gitster.g> (raw)
In-Reply-To: <pull.1086.git.1638324413653.gitgitgadget@gmail.com> (James Limbouris via GitGitGadget's message of "Wed, 01 Dec 2021 02:06:53 +0000")
"James Limbouris via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 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
>
> Hello git developers. Please consider this small patch that fixes a bug
> introduced during a coding style cleanup of the subtree command. Changes
> to the argument handling were causing check_parents to fail when more
> than one parent was supplied, which led to a small loss of performance.
I do not do "git subtree", and this cannot really be a proper review
that is more than "Looks OK from a cursory look", but anyway...
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.
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 7f767b5c38f..56f24000c2c 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 $?
We know at this point each of $1, $2, etc. have exactly one
revision, and we want cache_miss function to take one revision per
its parameter, so writing "$@" is much more preferrable over $* even
though they do the same thing in practice in the context of this
code, I think.
> 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
next prev parent reply other threads:[~2021-12-01 23:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 2:06 [PATCH] subtree: fix argument handling in check_parents James Limbouris via GitGitGadget
2021-12-01 23:04 ` Junio C Hamano [this message]
2021-12-02 5:51 ` [PATCH v2] " James Limbouris via GitGitGadget
2021-12-06 2:45 ` [PATCH v3] " James Limbouris via GitGitGadget
2021-12-08 2:11 ` [PATCH v4] " James Limbouris via GitGitGadget
2022-01-04 12:21 ` Johannes Schindelin
2022-01-04 20:04 ` Junio C Hamano
2021-12-03 15:22 ` [PATCH] " Johannes Schindelin
2021-12-03 20:02 ` Junio C Hamano
2021-12-07 21:45 ` Johannes Schindelin
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=xmqq1r2wylik.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=james@digitalmatter.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).