From: Junio C Hamano <gitster@pobox.com>
To: "Moritz Baumann via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Luke Diamand <luke@diamand.org>,
Moritz Baumann <moritz.baumann@sap.com>
Subject: Re: [PATCH 2/2] git-p4: fix error handling in P4Unshelve.renameBranch()
Date: Wed, 20 Jul 2022 09:21:07 -0700 [thread overview]
Message-ID: <xmqq5yjr4ux8.fsf@gitster.g> (raw)
In-Reply-To: <xmqqa6934v2c.fsf@gitster.g> (Junio C. Hamano's message of "Wed, 20 Jul 2022 09:18:03 -0700")
Junio C Hamano <gitster@pobox.com> writes:
>>
>> - found = True
>
> This has to be initialized to False, because ...
>
>> for i in range(0, 1000):
>> backup_branch_name = "{0}.{1}".format(branch_name, i)
>> if not gitBranchExists(backup_branch_name):
>> # Copy ref to backup
>> gitUpdateRef(backup_branch_name, branch_name)
>> gitDeleteRef(branch_name)
>> - found = True
>> print("renamed old unshelve branch to {0}".format(backup_branch_name))
>
> ... we flip it to True when we find an available unused name and
> break out ...
>
>> break
>> -
>> - if not found:
>> - sys.exit("gave up trying to rename existing branch {0}".format(sync.branch))
>
> ... so that we can complain when we didn't find anything usable.
By the way, isn't this a typical time-of-check to time-of-use bug?
Not the problem with the fix in the patch but in the original, but
regardless of whose fault it is, it may be good to fix it (outside
the topic of this patch).
Thanks.
next prev parent reply other threads:[~2022-07-20 16:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 6:34 [PATCH 0/2] git-p4: fix two undefined variables Moritz Baumann via GitGitGadget
2022-07-20 6:34 ` [PATCH 1/2] git-p4: fix typo in P4Submit.applyCommit() Moritz Baumann via GitGitGadget
2022-07-20 16:09 ` Junio C Hamano
2022-07-20 6:34 ` [PATCH 2/2] git-p4: fix error handling in P4Unshelve.renameBranch() Moritz Baumann via GitGitGadget
2022-07-20 16:18 ` Junio C Hamano
2022-07-20 16:21 ` Junio C Hamano [this message]
2022-07-20 17:01 ` Baumann, Moritz
2022-07-20 18:55 ` [PATCH v2 0/2] git-p4: fix two undefined variables Moritz Baumann via GitGitGadget
2022-07-20 18:55 ` [PATCH v2 1/2] git-p4: fix typo in P4Submit.applyCommit() Moritz Baumann via GitGitGadget
2022-07-20 18:55 ` [PATCH v2 2/2] git-p4: fix error handling in P4Unshelve.renameBranch() Moritz Baumann via GitGitGadget
2022-07-20 20:54 ` [PATCH v2 0/2] git-p4: fix two undefined variables 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=xmqq5yjr4ux8.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=luke@diamand.org \
--cc=moritz.baumann@sap.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).