Re: [PATCH v2] contrib/subtree: fix split with squashed subtrees
- From
- Colin Stagner <ask+git@howdoi.land>
- Date
- Sep 10, 2025, 03:00 UTC
- Message-ID
- <641aaa9b-2b23-4faf-a13e-f6205e9ef5a2@howdoi.land>
- In-Reply-To
- <xmqqbjnjt67y.fsf@gitster.g>
On 9/9/25 21:02, Junio C Hamano wrote:
Show 7 quoted lines
> Besides, "if test -n ${subtree_dir-}" without colon would be the
> more proper way for those who care about "set -u", wouldn't it? It
> is not that you want to substitute with an empty string that comes
> between that "-" and "}" when subtree_dir is unset or set to empty.
> You are preparing for the case where the variable is truly not set,
> and the variable being set to an empty string is not something you
> are worried about.Yes, "test -n ${subtree_dir-}" is definitely the more correct expression.At the very real risk of embarrassing myself in public today... in the particular case of a "test -n," is there actually an appreciable difference? Either way, the output of the substitution is empty if the input is empty or undefined. Here, "test -n ${subtree_dir:-}" is merely less efficient. Right?
The difference between "${x:-}" vs "${x-}" really starts to matter if you want to permit the empty string (or not). It also matters if you call a command that has side effects.
(And in the context of this patch, neither are necessary.)