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

Re: [PATCH v2 6/7] subtree: more robustly distinguish subtree and mainline commits

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 7, 2020, 19:42 UTC
Message-ID
<nycvar.QRO.7.76.6.2010072128130.50@tvgsbejvaqbjf.bet>
In-Reply-To
<a7aaedfed3785c6ca693f60f05e76156f68a5d39.1602021913.git.gitgitgadget@gmail.com>
Hi,
On Tue, 6 Oct 2020, Tom Clarkson via GitGitGadget wrote:
Show 6 quoted lines
> From: Tom Clarkson <tom@tqclarkson.com>
>
> Prevent a mainline commit without $dir being treated as a subtree
> commit and pulling in the entire mainline history. Any valid subtree
> commit will have only valid subtree commits as parents, which will be
> unchanged by check_parents.

I feel like this is only half the picture because I have a hard time stitching these two sentences together.

After studying the code and your patch a bit, it appears to me that `process_split_commit()` calls `check_parents()` first, which will call `process_split_commit()` for all as yet unmapped parents. So basically, it recurses until it found a commit all of whose parents are already mapped, then permeates that information all the way back.

Doesn't this cause serious issues with stack overflows and all for long commit histories?

Show 15 quoted lines
> Signed-off-by: Tom Clarkson <tom@tqclarkson.com>
> ---
>  contrib/subtree/git-subtree.sh | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index e56621a986..fa6293b372 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -224,8 +224,6 @@ cache_setup () {
>  	fi
>  	mkdir -p "$cachedir" ||
>  		die "Can't create new cachedir: $cachedir"
> -	mkdir -p "$cachedir/notree" ||
> -		die "Can't create new cachedir: $cachedir/notree"

It might make sense to talk about this a bit in the commit message. Essentially, you are replacing the `notree/<rev>` files by mapping `<rev>` to the empty string.

This makes me wonder, again, whether the file system layout of the cache can hold up to the demands. If a main project were to merge a subtree with, say, 10 million commits, wouldn't that mean that `git subtree` would now fill one directory with 10 million files? I cannot imagine that this performs well, still.

Show 14 quoted lines
>  	debug "Using cachedir: $cachedir" >&2
>  }
>
> @@ -255,18 +253,11 @@ check_parents () {
>  	local indent=$(($2 + 1))
>  	for miss in $missed
>  	do
> -		if ! test -r "$cachedir/notree/$miss"
> -		then
> -			debug "  unprocessed parent commit: $miss ($indent)"
> -			process_split_commit "$miss" "" "$indent"
> -		fi
> +		debug "  unprocessed parent commit: $miss ($indent)"
> +		process_split_commit "$miss" "" "$indent"

That makes sense to me, as the `missed` variable only contains as yet unmapped commits, therefore we do not have to have an equivalent `test -r` check.

Ciao, Dscho

Show 35 quoted lines
>  	done
>  }
>
> -set_notree () {
> -	echo "1" > "$cachedir/notree/$1"
> -}
> -
>  cache_set () {
>  	oldrev="$1"
>  	newrev="$2"
> @@ -719,11 +710,18 @@ process_split_commit () {
>  	# vs. a mainline commit?  Does it matter?
>  	if test -z "$tree"
>  	then
> -		set_notree "$rev"
>  		if test -n "$newparents"
>  		then
> -			cache_set "$rev" "$rev"
> +			if test "$newparents" = "$parents"
> +			then
> +				# if all parents were subtrees, this can be a subtree commit
> +				cache_set "$rev" "$rev"
> +			else
> +				# a mainline commit with tree missing is equivalent to the initial commit
> +				cache_set "$rev" ""
> +			fi
>  		else
> +			# no parents with valid subtree mappings means a commit prior to subtree add
>  			cache_set "$rev" ""
>  		fi
>  		return
> --
> gitgitgadget
>
>
Previous: Tom Clarkson via GitGitGadgetNext: Tom Clarkson via GitGitGadget
Message 21 of 28 in “subtree: Fix handling of complex history”
  1. 0/7 subtree: Fix handling of complex historyTom Clarkson via GitGitGadget, May 11, 2020
  2. 1/7 subtree: handle multiple parents passed to cache_missTom Clarkson via GitGitGadget, May 11, 2020
  3. 2/7 subtree: exclude commits predating add from recursive processingTom Clarkson via GitGitGadget, May 11, 2020
  4. 4/7 subtree: add git subtree map commandTom Clarkson via GitGitGadget, May 11, 2020
  5. 3/7 subtree: persist cache between split runsTom Clarkson via GitGitGadget, May 11, 2020
  6. 5/7 subtree: add git subtree use and ignore commandsTom Clarkson via GitGitGadget, May 11, 2020
  7. 7/7 subtree: document new subtree commandsTom Clarkson via GitGitGadget, May 11, 2020
  8. 6/7 subtree: more robustly distinguish subtree and mainline commitsTom Clarkson via GitGitGadget, May 11, 2020
  9. Ed MasteOct 4, 2020
  10. Johannes SchindelinOct 4, 2020
  11. Junio C HamanoOct 5, 2020
  12. Ed MasteOct 5, 2020
  13. Johannes SchindelinOct 7, 2020
  14. 0/7 subtree: Fix handling of complex historyTom Clarkson via GitGitGadget, Oct 6, 2020
  15. 4/7 subtree: add git subtree map commandTom Clarkson via GitGitGadget, Oct 6, 2020
  16. 1/7 subtree: handle multiple parents passed to cache_missTom Clarkson via GitGitGadget, Oct 6, 2020
  17. Ed MasteOct 7, 2020
  18. 5/7 subtree: add git subtree use and ignore commandsTom Clarkson via GitGitGadget, Oct 6, 2020
  19. Johannes SchindelinOct 7, 2020
  20. 6/7 subtree: more robustly distinguish subtree and mainline commitsTom Clarkson via GitGitGadget, Oct 6, 2020
  21. Johannes SchindelinOct 7, 2020
  22. 3/7 subtree: persist cache between split runsTom Clarkson via GitGitGadget, Oct 6, 2020
  23. Johannes SchindelinOct 7, 2020
  24. 2/7 subtree: exclude commits predating add from recursive processingTom Clarkson via GitGitGadget, Oct 6, 2020
  25. Johannes SchindelinOct 7, 2020
  26. 7/7 subtree: document new subtree commandsTom Clarkson via GitGitGadget, Oct 6, 2020
  27. Johannes SchindelinOct 7, 2020
  28. Johannes SchindelinOct 7, 2020

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.