git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Race condition on `git checkout -c`
@ 2023-01-19 21:13 Arthur Milchior
  2023-01-19 22:55 ` Chris Torek
  0 siblings, 1 reply; 3+ messages in thread
From: Arthur Milchior @ 2023-01-19 21:13 UTC (permalink / raw)
  To: git

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
I was working on code as usual. I should note that the repo is big, so
it’s not unusual for some git operations to take half a minute.

Here is a simpler reproduction that worked on my machine.

```
mkdir g
cd g
git init
git touch a
git add a
git commit -am "a"
git checkout -b b
```

While the last command is being run, in a different terminal, run `git
checkout -b B`

I realized that I can do it manually, by just using cmd-tab, then enter.

Finally, type `git branch`


What did you expect to happen? (Expected behavior)

I expect either:
* to see an error message stating that `b` already exists
* to see `b` and `B` in the list of branch.

In any case, when both branches exists, which will be the case on
system which were started with this "bug", I expect to see both
branches listed.

What happened instead? (Actual behavior)

I was able to successively create both branches.
The branch `b` is not listed. If I check it out, then `git branch`
does not list a single branch as the current branch.

What's different between what you expected and what actually happened?

I expect that `git branch` always list me on a branch, and let me know
of all existing branch.

Anything else you want to add:

First: I can’t reproduce with `git branch b` and `git branch B`, so I
guess either `branch` is faster than `checkout -c`, or something else
is done right there.

I know that this race condition seems very contrived. In real life,
the names were `bookmarkShome` and `bookmarksHome`. Obviously, both
were supposed to be `bookmarksHome`, in camlCase. The first one was a
typo. But that was the one git show, which was confusing.
However, even if the repo is big and checking out a branch can easily
take 30 seconds, I’m still not sure when I’d have two terminals
creating branchs at the same time.

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.39.0.246.g2a6d74b583-goog
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51
PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 x86_64
compiler info: clang: 14.0.0 (clang-1400.0.29.202)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-20  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 21:13 Race condition on `git checkout -c` Arthur Milchior
2023-01-19 22:55 ` Chris Torek
2023-01-20  9:01   ` Arthur Milchior

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).