git's –end-of-options Flag

(nesbitt.io)

100 points | by Erenay09 1 day ago

12 comments

  • metadat 2 hours ago
    Does anyone know why git broke the long standing convention of "--" early on? Kind of a nightmare for humans to use.

    Remembering app-specific one-offs is kind of the worst!

    • dmurray 1 minute ago
      It sounds like they didn't need (at the time) to separate arguments from options, but they did need to separate revisions from pathspecs. So they repurposed "--" as the most familiar separator.

      Probably they were trying to use familiar conventions, but when they later needed to separate arguments from options, that was a closer match for what other people were using "--" for, but it was too late.

    • doctoboggan 2 hours ago
      git's data model is incredibly powerful and flexible, but its UX is famously... interesting:

      https://stevelosh.com/blog/2013/04/git-koans/

      • peheje 33 minutes ago
        These are great
    • userbinator 1 hour ago
      The Single UNIX Specification mentions the "--" convention in 1997 (at which point it was already in widespread use): https://pubs.opengroup.org/onlinepubs/7908799/xbd/utilconv.h...

      The first release of git was in 2005, and Torvalds' Linux was clearly UNIX-inspired, so it's not like this was due to considerations for some other OS like DOS/Windows.

      • j16sdiz 57 minutes ago
        The practice was there before the spec
        • setopt 35 minutes ago
          Which the parent poster said in their comment?
    • epistasis 2 hours ago
      Since it separates out the pathspec, doesn't that match the long standing convention?
    • p-e-w 2 hours ago
      When something appears to be poorly designed, then the deeper explanation is often that it’s indeed poorly designed.
    • TZubiri 1 hour ago
      One of the undeniable benefits of LLMs is that the end of guessing and remembering commands is now optional.

      Now we can all run important CLI programs like Zork without a 'command doesn't exist' to command ratio of 1:4

      • xg15 1 hour ago
        Yeah, now the LLMs are guessing the commands...
    • vips7L 32 minutes ago
      Flags for Unix tools have never been friendly.
  • yobert 2 hours ago
    So I should name my next branch ‘--‘ is what I'm hearing :)
    • fragmede 2 hours ago
      [flagged]
      • randunel 2 hours ago
        That's still the default in my localhost, but I get a warning that it'll change.
      • 4gotunameagain 1 hour ago
        One of the most stupid virtue signaling changes of the industry.
        • oneeyedpigeon 36 minutes ago
          There are advantages beyond avoiding the use of a charged term.
          • jchw 32 minutes ago
            It wasn't a charged term and there are not.
          • 4gotunameagain 9 minutes ago
            It's only charged if you are a white upper middle class american. The rest of the world understands the difference between a term used in a software version control tool and slavery. The rest of the world also does not change a word on git while simultaneously fostering extremist far right views.

            The whole thing makes absolutely no sense whatsoever.

          • fragmede 32 minutes ago
            to be fair, I like typing less, and main is shorter than master.
        • tcfhgj 19 minutes ago
          Why?
  • Chinjut 1 hour ago
    The "Everything is text, do everything via text" philosophy has its advantages, and also its disadvantages.
    • usr1106 1 hour ago
      Like the von Neumann architecture. Your data can be misused as code.

      Don't see that we get rid of either command lines in text or von Neumann any time soon.

  • bradley13 2 hours ago
    As with almost any successful system: more and more special features and edge cases get added. Git has become ridiculously complex.

    I wonder: would it not be better to tell users with those edge cases to fix their problems some other way? To take an example from the article: why does someone have a filename beginning with a dash? Maybe don't do that.

    • zanecodes 2 hours ago
      Sometimes you're using git in a context where you don't control the filenames, or where a potential attacker could influence or fully control them, at which point edge cases like this can easily turn into exploits.

      I also chafe whenever I run into artificial restrictions on things like characters in names of things, because there's no good reason for them besides the laziness of developers or the limitations and inertia of existing systems that might be used under the hood, like DNS for instance.

      • vips7L 29 minutes ago
        An attacker has access to your git??? You’re fucked. Give up.
  • xyzsparetimexyz 5 minutes ago
    What a mess. Just use jj instead.
  • epistasis 2 hours ago
    Perhaps I'm missing something (it's been a long day), but couldn't "--" be used for both?

        git cmd --options -- rev -- pathspec
    
    would be the fully specified revspec and pathspec

        git cmd --option -- rev --
    
    would be just the revspec, excluding accidental options, without a pathspec

        git cmd --option revspec -- pathspec
    
    and the single "--" would work as it currently does.
    • gene91 1 hour ago
      Currently, git log -- a -- prints all commits that affects the files whose name is a or two dashes.
  • _blk 2 hours ago
    > git log --end-of-options "$rev" -- "$path",

    Argh, that's when I wished for object oriented shells. Powershell sure isn't perfect but objects encoding their own meaning really helps differentiate those cases (but it may not always help the user if types aren't clear to the reader)

    • eru 2 hours ago
      I don't think you need object orientation for that. Haskell and Rust solve these problems also just fine, without any OOP in sight.
      • desmaraisp 1 hour ago
        In this specific case, the oop nature of powershell doesn't actually matter, just the fact it uses structured input instead of raw string.

        It's like passing a struct to a function instead of a badly serialized representation of a value

      • _blk 2 hours ago
        Hmm, not sure I understand. How are those shell based?

        I agree that rust and haskell are not your typical OO (or not OO at all in a traditional sense) I guess my poorly worded claim was less focused on the OO nature of psh than on the typization (which both of these also do) - if you knew what type $rev and $path are, it's easier to distinguish intent, whether objects or not.

        • eru 16 minutes ago
          > Hmm, not sure I understand. How are those shell based?

          A shell is just a programming language that's well suited for interactive repl use. Compare https://en.wikipedia.org/wiki/Scsh

          Of course, Rust and Haskell aren't typically thought of as shells. Though if you wanted to and felt brave enough, you could use ghci as a shell.

          > I guess my poorly worded claim was less focused on the OO nature of psh than on the typization (which both of these also do) - if you knew what type $rev and $path are, it's easier to distinguish intent, whether objects or not.

          Agreed!

  • ButlerianJihad 2 hours ago
    https://m.xkcd.com/1597/

    By the way, something munched the article title. An endash is incorrect command-line usage. It’s supposed to be a double hyphen.

    • sheept 1 hour ago
      It is an en dash, not an em dash, since it's about as wide as an n.

      Some software substitutes a double hyphen -- with an en dash rather than em, and use the triple hyphen --- for the em dash. Perhaps Hacker News' title formatter is one of them.

      • ButlerianJihad 1 hour ago
        Okay, edit submitted, but that is extra weird, because the double hyphen is a convention or placeholder for an emdash. When a transformation takes place, it becomes an emdash.

        There is no reason to transform it to an endash. I don't know any software that would do that. Checked with an LLM, too. That makes no sense at all!

        • dasyatidprime 1 hour ago
          TeX uses -- (double hyphen) for producing an en dash and --- (triple hyphen) for an em dash, and that's pretty darn longstanding and well-established. And FWIW, the English writing conventions that I learned use em dashes as punctuation without an adjoining space—like this—but allow en dashes surrounded by spaces as an alternative – like this – so I frequently see spaced double hyphen used as the ASCII equivalent of dash punctuation and interpret it as the latter. I've never personally heard of double hyphen for em specifically, only either as en specifically or as a sort of ambiguous whatever-dash.
          • chowells 40 minutes ago
            Double dash -> emdash is a default autoreplacement in OSX. That's why a lot of people think it's the default everywhere.
        • cubefox 44 minutes ago
          Then how do you type in an en dash instead? Also, according to LLMs, the en dash is used in far more languages than the em dash. Many languages don't use the em dash at all. Using the em dash for sentence interruptions seems to be specifically an US American English tradition: Most languages which use dashes for sentence interruptions use spaced en dashes instead.
    • wafflemaker 2 hours ago
      From the title I've learned that git uses an em-dash instead of double dash as options delimiter. Thanks for pointing out that the title was wrong -- I've never had a need to use -- with git, so didn't know that it doesn't work.
    • Erenay09 1 hour ago
      I'm sure I typed double-hyphen when submitting the post, but probably HN auto-formatted the title. IDK really.
  • luciana1u 17 minutes ago
    [dead]
  • usr1106 1 hour ago
    Copilot CLI (we get that at work) often uses slightly low-level and cryptic git commands. Never noticed that it would use --end-of-options though.

    Should check what it does with branch names starting with a dash.

    Of course that wouldn't be a security vulnerability, but a user error. It asks user approvals to execute those things and has disclaimers to check results. Which of course every user does all the time... /s

    • vips7L 27 minutes ago
      Absolute another level of lazy if you need an LLM to git for you.