Volume XXII, number 280Wednesday, October 7, 2026Latest message 1 hour ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

bug report: mutual recursion in the git-subtree shell script

5 messages between Mar 13, 2021 and Mar 14, 2026, from Arun Sharma, brian m. carlson, Johannes Schindelin, Colin Stagner.

Plain Markdown or JSON for tools and agents.

Arun SharmaMar 13, 2021, 16:06 UTC on lore
[ resending bug report from git-users since there weren't any responses ]

So I'm trying to split out a directory from postgres source code (which has 52k commits). I was able to split a directory into a separate subtree (with 1685 commits). All good so far.

Now I do a pull from upstream and want to push the directory to my subtree. The command fails with:

$ git subtree push --prefix=src/interfaces/libpq libpq master /usr/lib/git-core/git-subtree: 647: Maximum function recursion depth (1000) reached

As far as I can see, it seems to be a mutual recursion between
process_split_commit() and check_parents()

If this diagnosis is correct, are there any known workarounds? I've tried increasing ulimit -s and FUNCNEST=10000, but it didn't fix the problem.

Can this flow be coded without using recursion? Are there implementations of git-subtree in another language which doesn't have this problem?

 -Arun
brian m. carlsonMar 13, 2021, 17:02 UTC in reply to Arun Sharma on lore

Re: bug report: mutual recursion in the git-subtree shell script

On 2021-03-13 at 16:06:18, Arun Sharma wrote:
Show 24 quoted lines
> [ resending bug report from git-users since there weren't any responses ]
> 
> So I'm trying to split out a directory from postgres source code
> (which has 52k commits). I was able to split a directory into a
> separate subtree (with 1685 commits). All good so far.
> 
> Now I do a pull from upstream and want to push the directory to my
> subtree. The command fails with:
> 
> $ git subtree push --prefix=src/interfaces/libpq libpq master
> /usr/lib/git-core/git-subtree: 647: Maximum function recursion depth
> (1000) reached
> 
> As far as I can see, it seems to be a mutual recursion between
> 
> process_split_commit() and check_parents()
> 
> If this diagnosis is correct, are there any known workarounds? I've
> tried increasing ulimit -s and FUNCNEST=10000, but it didn't fix the
> problem.
> 
> Can this flow be coded without using recursion? Are there
> implementations of git-subtree in another language which doesn't have
> this problem?

I don't use git-subtree, but there's some additional information which would probably be helpful here to someone who does. What OS are you using, what version of Git, and what shell is the shell you have as /bin/sh (or, if you've compiled using a custom shell, the shell you're using for that)?

-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Arun SharmaMar 14, 2021, 17:31 UTC in reply to brian m. carlson on lore

Re: bug report: mutual recursion in the git-subtree shell script

On Sat, Mar 13, 2021 at 9:03 AM brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 6 quoted lines
>
> I don't use git-subtree, but there's some additional information which
> would probably be helpful here to someone who does.  What OS are you
> using, what version of Git, and what shell is the shell you have as
> /bin/sh (or, if you've compiled using a custom shell, the shell you're
> using for that)?
Thanks for the hint. I was using ubuntu 20.04.

$ git --version git version 2.25.1

$ bash --version GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)

To repro, you can try to split a week old version of:
https://github.com/postgres/postgres (subtree: src/interfaces/libpq)
It could take several minutes because of the size of the repo.

And then try to pull the latest version and push the merged result into the smaller subproject.

 -Arun
Johannes SchindelinMar 15, 2021, 05:19 UTC in reply to Arun Sharma on lore

Re: bug report: mutual recursion in the git-subtree shell script

Hi,
On Sun, 14 Mar 2021, Arun Sharma wrote:
Show 25 quoted lines
> On Sat, Mar 13, 2021 at 9:03 AM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> >
> > I don't use git-subtree, but there's some additional information which
> > would probably be helpful here to someone who does.  What OS are you
> > using, what version of Git, and what shell is the shell you have as
> > /bin/sh (or, if you've compiled using a custom shell, the shell you're
> > using for that)?
>
> Thanks for the hint. I was using ubuntu 20.04.
>
> $ git --version
> git version 2.25.1
>
> $ bash --version
> GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)
>
> To repro, you can try to split a week old version of:
>
> https://github.com/postgres/postgres (subtree: src/interfaces/libpq)
>
> It could take several minutes because of the size of the repo.
>
> And then try to pull the latest version and push the merged result
> into the smaller subproject.

Without having had the time to read the bug report in detail (let alone the time to try to reproduce), I nevertheless got reminded of this PR: https://github.com/gitgitgadget/git/pull/493

The most recent iteration was sent here: https://lore.kernel.org/git/pull.493.v2.git.1602021913.gitgitgadget@gmail.com/

This patch series _might_ address the issue (IIRC it talked about removing a deep recursion). Arun, maybe you want to give it a swirl?

Ciao, Johannes

Colin StagnerMar 14, 2026, 21:36 UTC in reply to Arun Sharma on lore

Re: bug report: mutual recursion in the git-subtree shell script

Arun,
I found your git-subtree bug report from several years ago.
On 3/13/21 10:06, Arun Sharma wrote:
Show 6 quoted lines
> So I'm trying to split out a directory from postgres source code
> (which has 52k commits).
> 
> $ git subtree push --prefix=src/interfaces/libpq libpq master
> /usr/lib/git-core/git-subtree: 647: Maximum function recursion depth
> (1000) reached
On 3/14/21 12:31, Arun Sharma wrote:
Show 11 quoted lines
> I was using ubuntu 20.04.
> 
> $ git --version
> git version 2.25.1
> 
> $ bash --version
> GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)
> 
> To repro, you can try to split a week old version of:
> 
> https://github.com/postgres/postgres (subtree: src/interfaces/libpq)
Is this issue still relevant to you?

I have prepared a patch series that I hope will correct this problem. If you have the time, can you please test and review:

<https://lore.kernel.org/git/20260305-cs-subtree-split-recursion-v2-0-7266be870ba9@howdoi.land/>
Code reviews are eagerly solicited.
Colin

Back to recent threads