Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commitbe53823
committed
Have init script treat master unambiguously as a branch
Because users may have an old version of git without "git switch",init-tests-after-clone.sh should continue to use "git checkout" toattempt to switch to master. But without "--", this suffers fromthe problem that it's ambiguous if master is a branch (so checkoutbehaves like switch) or a path (so checkout behaves like restore).There are two cases where this ambiguity can be a problem. The mostcommon is on a fork with no master branch but also, fortunately, nofile or directory named "master". Then the problem is just theerror message (printed just before the script proceeds to redothe checkout with -b): error: pathspec 'master' did not match any file(s) known to gitThe real cause of the error is the branch being absent, as happenswhen a fork copies only the main branch and the upstream remote isnot also set up. Adding the "--" improves the error message: fatal: invalid reference: masterHowever, it is possible, though unlikely, for a file or directorycalled "master" to exist. In that case, if there is also no masterbranch, git discards unstaged changes made to the file or (muchworse!) everywhere in that directory, potentially losing work.This commit adds "--" to the right of "master" so git neverregards it as a path. This is not needed with -b, which is alwaysfollowed by a symbolic name, so I have not added it there.(Note that the command is still imperfect because, for example, inrare cases there could be a master *tag*--and no master branch--inwhich case, as before, HEAD would be detached there and the scriptwould attempt to continue.)1 parente973f52 commitbe53823
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
13 |
| - | |
| 13 | + | |
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
|
0 commit comments
Comments
(0)