Subject: Re: [PATCH v2 0/3] contrib/subtree: reduce recursion during split

From: Ian Jackson <[email-masked]>
Date: Thu, 16 Apr 2026 14:25:10 +0100

Colin Stagner writes ("[PATCH v2 0/3] contrib/subtree: reduce recursion during split"):
> On Debian's POSIX sh, shell recursion is artificially limited
> to 1000 calls. You can check if your sh has limited recursion
> with:

FTR Debian supports multiple options for /bin/sh.  The shell in
question, with the limit that's troubling us, is dash.

> Depending on the history graph, subtree split can recurse deeply
> enough to encounter this limit. Rewrite the rejoin-deepening
> algorithm to reduce recursive calls.

Hi.  I'm a git-subtree user and indeed I was the one who reported the
bug Colin is trying to fix.  I would be happy to do a code review of
these changes.

However, before I get stuck into that, which seems like it will
involve some serious staring at shell code, I'd like to ask what seems
like a logically prior question:

Why not run the script under bash in non-POSIX mode instead?  I think
that would sidestep the problem.  If you don't want this program to
always depend on bash, you could have a little snippet at the top to
re-exec with bash if (1) it's available (2) we don't seem to be
running under bash already.  (Presumably the Debian package of git
would need to Recommend bash then.)

TBH I was quite surprised, when I reported this bug some time ago, to
find that git-subtree was written in shell.  If it had been me I would
probably have used Rust and libgit2.

Ian.

-- 
Ian Jackson <[email-masked]>   These opinions are my own.  

Pronouns: they/he.  If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.