git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] subtree: fix argument handling in check_parents

From
James Limbouris via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 6, 2021, 02:45 UTC
Message-ID
<pull.1086.v3.git.1638758742741.gitgitgadget@gmail.com>
In-Reply-To
<pull.1086.v2.git.1638424290015.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. For commits with a single parent this would succeed, but whenever a merge commit was processed, cache_miss would be passed "parent1 parent2" instead of "parent1" "parent2" and fail, leading to unecessary rechecks of the parent commits.

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
    
    > I agree with this. I'll mark the topic as "Expecting a reroll" in the
    > next "What's cooking" report, so that we do not forget that we are
    > waiting for such an improved description in the log message.
    
    Thanks for the feedback - log message has been amended.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1086%2Fjamesl-dm%2Fmaint-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1086/jamesl-dm/maint-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1086
Range-diff vs v2:
 1:  1198a84995b ! 1:  f734ca9d276 subtree: fix argument handling in check_parents
     @@ Commit message
          subtree: fix argument handling in check_parents
      
          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.
     +    and erroneously passing them to cache_miss as a single string. For
     +    commits with a single parent this would succeed, but whenever a merge
     +    commit was processed, cache_miss would be passed "parent1 parent2"
     +    instead of "parent1" "parent2" and fail, leading to unecessary rechecks
     +    of the parent commits.
      
          For consistency, take multiple arguments in check_parents,
          and pass all of them to cache_miss separately.
 contrib/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
Previous: James Limbouris via GitGitGadgetNext: James Limbouris via GitGitGadget
Message 4 of 10 in “subtree: fix argument handling in check_parents”
  1. subtree: fix argument handling in check_parentsJames Limbouris via GitGitGadget, Dec 1, 2021
  2. Junio C HamanoDec 1, 2021
  3. subtree: fix argument handling in check_parentsJames Limbouris via GitGitGadget, Dec 2, 2021
  4. subtree: fix argument handling in check_parentsJames Limbouris via GitGitGadget, Dec 6, 2021
  5. subtree: fix argument handling in check_parentsJames Limbouris via GitGitGadget, Dec 8, 2021
  6. Johannes SchindelinJan 4, 2022
  7. Junio C HamanoJan 4, 2022
  8. Johannes SchindelinDec 3, 2021
  9. Junio C HamanoDec 3, 2021
  10. Johannes SchindelinDec 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.