Re: [PATCH v2] contrib/subtree: fix split with squashed subtrees

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Colin Stagner <ask+git@xxxxxxxxxxx> 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.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux