News for hackers. Stuff that matters.
Re:Flight rules for Git by crooked-v on Tuesday October 16, 2018 @12:25PM (#18230655)
Consider `git checkout` and having a file called `master` at the root level of the repo.
Re:Flight rules for Git by CJefferson on Tuesday October 16, 2018 @03:18PM (#18232328)
Further, what does `git checkout a/b` do?

* Checkout a file called a/b

* Checkout branch b from remote a

* Checkout a local branch called a/b

I've seen people end up with local branches with names like 'upstream/mybranch', then get super-confused about how these branches aren't "upstream". git should really ban local branches with a / in their name.

Re:Flight rules for Git by bicolao on Tuesday October 16, 2018 @01:39PM (#18231405)
It's a bug that "git checkout" does not complain in this case. I'll try to fix or report it.
Re:Flight rules for Git by dfabulich on Tuesday October 16, 2018 @01:43PM (#18231442)
Re:Flight rules for Git by chopin on Wednesday October 17, 2018 @05:31AM (#18237506)
Though I agree with you, a warning could be issued.
Re:Flight rules for Git by booleandilemma on Tuesday October 16, 2018 @12:57PM (#18230980)
Sounds like an edge case. This isn’t really a problem with Git per se.
Re:Flight rules for Git by crooked-v on Tuesday October 16, 2018 @01:05PM (#18231076)
A single command doing two completely different things arbitrarily depending on file matches isn't an "edge case".
Re:Flight rules for Git by lixtra on Tuesday October 16, 2018 @01:31PM (#18231315)
But this very common for many tools:

  touch -- -l
  ls *
Re:Flight rules for Git by mmt on Wednesday October 17, 2018 @11:21AM (#18239941)
However, if you run both commands consistently, nothing untoward occurs:

  touch -- -l
  ls -- *
The fact that you have to use a double-hyphen flag to create a file with a name starting with a hyphen is a strong indication that this situation is an edge case.
Re:Flight rules for Git by lixtra on Wednesday October 17, 2018 @04:11PM (#18243277)
And git handles the edge case the same way. That was my point.

  rm master
  git checkout -- master
  git checkout a1b1
  git checkout master -- master
all works as expected
Re:Flight rules for Git by mmt on Wednesday October 17, 2018 @09:15PM (#18245187)
Not quite. I believe the point is that it's not an edge case, since "master" isn't a particularly unusual name, not in the Unix tradition, nor, AFAIK, on any other OS.

You'll note that, for example, your "rm" didn't require a double-hyphen.

The OC's point (and maybe the GP's point [1]), ultimately, is about git command syntax ambiguity. With traditional Unix commands, there's not much ambiguity. At worst, there's merely no obvious way to pass an argument that's a filename starting with a hyphen. The question "what does 'ls -l' do?" would not plausibly have an answer of "output '-l' if a directory entry with that name exists" in addition to "output a long listing of all directory entries".

[1] Does git actually behave differently based on the existence of a directory entry named "master" or does it merely require extra effort to work with such an entry, which would actually be directly analagous to filenames beginning with a hyphen?

Re:Flight rules for Git by crooked-v on Tuesday October 16, 2018 @02:19PM (#18231781)
That's bad too.