From: Junio C Hamano <gitster@pobox.com>
To: Colin Stagner <ask+git@howdoi.land>
Cc: phillip.wood@dunelm.org.uk, git@vger.kernel.org,
Zach FettersMoore <zach.fetters@apollographql.com>,
Christian Couder <chriscool@tuxfamily.org>,
Patrik Weiskircher <patrik@pspdfkit.com>
Subject: Re: [PATCH v2] contrib/subtree: fix split with squashed subtrees
Date: Tue, 09 Sep 2025 19:02:41 -0700 [thread overview]
Message-ID: <xmqqbjnjt67y.fsf@gitster.g> (raw)
In-Reply-To: <8d341a51-2135-4c62-9df1-5be351e73275@howdoi.land> (Colin Stagner's message of "Tue, 9 Sep 2025 20:56:07 -0500")
Colin Stagner <ask+git@howdoi.land> writes:
>>> - if test -n "$(git log -1 --grep="git-subtree-dir:" $rev)"
>>> + if test -n "${subtree_dir:-}" &&
>>> + test -z "${have_mainline:-}" &&
>>> + test "${subtree_dir}" != "$arg_prefix"
>> What's the idea behind using "${var:-}" rather than "{var}"?
>
> I write a lot of shell scripts that run "set -u" (aka "set -o
> nounset"), so I do this a lot when testing for empty vars. In this
> case, it's not actually necessary since `have_mainline` is explicitly
> defined above. And we don't run `set -u` anyway.
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. THe same for ${have_mainline:-}.
>> If you use "git switch --orphan" that clears the worktree for you
>
> Very useful. I'll start using it in v3.
Excellent suggestion.
next prev parent reply other threads:[~2025-09-10 2:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-24 19:10 [PATCH] contrib/subtree: fix split with squashed subtrees Colin Stagner
2025-09-01 13:54 ` Phillip Wood
2025-09-01 20:43 ` Colin Stagner
2025-09-02 13:22 ` Phillip Wood
2025-09-02 14:57 ` Phillip Wood
2025-09-04 1:34 ` Colin Stagner
2025-09-05 2:27 ` [PATCH v2] " Colin Stagner
2025-09-08 15:21 ` Phillip Wood
2025-09-10 1:56 ` Colin Stagner
2025-09-10 2:02 ` Junio C Hamano [this message]
2025-09-10 3:00 ` Colin Stagner
2025-09-10 15:10 ` Junio C Hamano
2025-09-10 3:11 ` [PATCH v3] " Colin Stagner
2025-09-10 9:39 ` Phillip Wood
2025-09-11 16:01 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbjnjt67y.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ask+git@howdoi.land \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=patrik@pspdfkit.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=zach.fetters@apollographql.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).