{"thread":{"id":"55305","subject":"bug report: mutual recursion in the git-subtree shell script","startedAt":"2021-03-13T16:07:07Z","lastAt":"2026-03-14T21:36:59Z","messageCount":5,"participants":["Arun Sharma","brian m. carlson","Johannes Schindelin","Colin Stagner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"419040","messageId":"CAN7rbOve-EFOGPjr1wrD77r-3RQ+3+qso82_oV5Qud-skobL7w@mail.gmail.com","threadId":"55305","inReplyTo":null,"subject":"bug report: mutual recursion in the git-subtree shell script","fromName":"Arun Sharma","fromEmail":"arun@sharma-home.net","sentAt":"2021-03-13T16:06:18Z","receivedAt":"2021-03-13T16:07:07Z","isPatch":false,"sender":{"key":"arun@sharma-home.net","avatar":null},"body":"[ resending bug report from git-users since there weren't any responses ]\n\nSo I'm trying to split out a directory from postgres source code\n(which has 52k commits). I was able to split a directory into a\nseparate subtree (with 1685 commits). All good so far.\n\nNow I do a pull from upstream and want to push the directory to my\nsubtree. The command fails with:\n\n$ git subtree push --prefix=src/interfaces/libpq libpq master\n/usr/lib/git-core/git-subtree: 647: Maximum function recursion depth\n(1000) reached\n\nAs far as I can see, it seems to be a mutual recursion between\n\nprocess_split_commit() and check_parents()\n\nIf this diagnosis is correct, are there any known workarounds? I've\ntried increasing ulimit -s and FUNCNEST=10000, but it didn't fix the\nproblem.\n\nCan this flow be coded without using recursion? Are there\nimplementations of git-subtree in another language which doesn't have\nthis problem?\n\n -Arun\n"},{"id":"419047","messageId":"YEzwOqgFcva4fmoV@camp.crustytoothpaste.net","threadId":"55305","inReplyTo":"CAN7rbOve-EFOGPjr1wrD77r-3RQ+3+qso82_oV5Qud-skobL7w@mail.gmail.com","subject":"Re: bug report: mutual recursion in the git-subtree shell script","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-03-13T17:02:50Z","receivedAt":"2021-03-13T17:04:01Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-03-13 at 16:06:18, Arun Sharma wrote:\n> [ resending bug report from git-users since there weren't any responses ]\n> \n> So I'm trying to split out a directory from postgres source code\n> (which has 52k commits). I was able to split a directory into a\n> separate subtree (with 1685 commits). All good so far.\n> \n> Now I do a pull from upstream and want to push the directory to my\n> subtree. The command fails with:\n> \n> $ git subtree push --prefix=src/interfaces/libpq libpq master\n> /usr/lib/git-core/git-subtree: 647: Maximum function recursion depth\n> (1000) reached\n> \n> As far as I can see, it seems to be a mutual recursion between\n> \n> process_split_commit() and check_parents()\n> \n> If this diagnosis is correct, are there any known workarounds? I've\n> tried increasing ulimit -s and FUNCNEST=10000, but it didn't fix the\n> problem.\n> \n> Can this flow be coded without using recursion? Are there\n> implementations of git-subtree in another language which doesn't have\n> this problem?\n\nI don't use git-subtree, but there's some additional information which\nwould probably be helpful here to someone who does.  What OS are you\nusing, what version of Git, and what shell is the shell you have as\n/bin/sh (or, if you've compiled using a custom shell, the shell you're\nusing for that)?\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"419085","messageId":"CAN7rbOuOaHY553KX1Qcr_XWGG6DFo1yUjdYVu5mn=HYPmOj6vQ@mail.gmail.com","threadId":"55305","inReplyTo":"YEzwOqgFcva4fmoV@camp.crustytoothpaste.net","subject":"Re: bug report: mutual recursion in the git-subtree shell script","fromName":"Arun Sharma","fromEmail":"arun@sharma-home.net","sentAt":"2021-03-14T17:31:11Z","receivedAt":"2021-03-14T17:32:18Z","isPatch":false,"sender":{"key":"arun@sharma-home.net","avatar":null},"body":"On Sat, Mar 13, 2021 at 9:03 AM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> I don't use git-subtree, but there's some additional information which\n> would probably be helpful here to someone who does.  What OS are you\n> using, what version of Git, and what shell is the shell you have as\n> /bin/sh (or, if you've compiled using a custom shell, the shell you're\n> using for that)?\n\nThanks for the hint. I was using ubuntu 20.04.\n\n$ git --version\ngit version 2.25.1\n\n$ bash --version\nGNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)\n\nTo repro, you can try to split a week old version of:\n\nhttps://github.com/postgres/postgres (subtree: src/interfaces/libpq)\n\nIt could take several minutes because of the size of the repo.\n\nAnd then try to pull the latest version and push the merged result\ninto the smaller subproject.\n\n -Arun\n"},{"id":"419162","messageId":"nycvar.QRO.7.76.6.2103150616410.50@tvgsbejvaqbjf.bet","threadId":"55305","inReplyTo":"CAN7rbOuOaHY553KX1Qcr_XWGG6DFo1yUjdYVu5mn=HYPmOj6vQ@mail.gmail.com","subject":"Re: bug report: mutual recursion in the git-subtree shell script","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2021-03-15T05:19:37Z","receivedAt":"2021-03-15T14:20:06Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 14 Mar 2021, Arun Sharma wrote:\n\n> On Sat, Mar 13, 2021 at 9:03 AM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> >\n> > I don't use git-subtree, but there's some additional information which\n> > would probably be helpful here to someone who does.  What OS are you\n> > using, what version of Git, and what shell is the shell you have as\n> > /bin/sh (or, if you've compiled using a custom shell, the shell you're\n> > using for that)?\n>\n> Thanks for the hint. I was using ubuntu 20.04.\n>\n> $ git --version\n> git version 2.25.1\n>\n> $ bash --version\n> GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)\n>\n> To repro, you can try to split a week old version of:\n>\n> https://github.com/postgres/postgres (subtree: src/interfaces/libpq)\n>\n> It could take several minutes because of the size of the repo.\n>\n> And then try to pull the latest version and push the merged result\n> into the smaller subproject.\n\nWithout having had the time to read the bug report in detail (let alone\nthe time to try to reproduce), I nevertheless got reminded of this PR:\nhttps://github.com/gitgitgadget/git/pull/493\n\nThe most recent iteration was sent here:\nhttps://lore.kernel.org/git/pull.493.v2.git.1602021913.gitgitgadget@gmail.com/\n\nThis patch series _might_ address the issue (IIRC it talked about removing\na deep recursion). Arun, maybe you want to give it a swirl?\n\nCiao,\nJohannes\n"},{"id":"538993","messageId":"454235b2-139f-40bd-a4ac-fb7664962471@howdoi.land","threadId":"55305","inReplyTo":"CAN7rbOuOaHY553KX1Qcr_XWGG6DFo1yUjdYVu5mn=HYPmOj6vQ@mail.gmail.com","subject":"Re: bug report: mutual recursion in the git-subtree shell script","fromName":"Colin Stagner","fromEmail":"ask+git@howdoi.land","sentAt":"2026-03-14T21:36:27Z","receivedAt":"2026-03-14T21:36:59Z","isPatch":false,"sender":{"key":"ask+git@howdoi.land","avatar":null},"body":"Arun,\n\nI found your git-subtree bug report from several years ago.\n\nOn 3/13/21 10:06, Arun Sharma wrote:\n\n> So I'm trying to split out a directory from postgres source code\n> (which has 52k commits).\n> \n> $ git subtree push --prefix=src/interfaces/libpq libpq master\n> /usr/lib/git-core/git-subtree: 647: Maximum function recursion depth\n> (1000) reached\n\nOn 3/14/21 12:31, Arun Sharma wrote:\n\n> I was using ubuntu 20.04.\n> \n> $ git --version\n> git version 2.25.1\n> \n> $ bash --version\n> GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)\n> \n> To repro, you can try to split a week old version of:\n> \n> https://github.com/postgres/postgres (subtree: src/interfaces/libpq)\n\nIs this issue still relevant to you?\n\nI have prepared a patch series that I hope will correct this problem. If \nyou have the time, can you please test and review:\n\n<https://lore.kernel.org/git/20260305-cs-subtree-split-recursion-v2-0-7266be870ba9@howdoi.land/>\n\nCode reviews are eagerly solicited.\n\nColin\n\n"}]}