News for hackers. Stuff that matters.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by diarrhea on Saturday July 29, 2023 @05:20PM (#36924751)
The other day I was trying to work with git LFS. I was very surprised to find out git-lfs, as in the binary, CLI application is the only (open) implementation in existence. There is nothing else. And even it itself does not offer itself up as a library; so even native Go code (the implementation language) has to fall back to shelling out to the CLI git extension! Not even bindings are possible. Such a painful loss of interoperability: IPC via return codes and parsing stdout/stderr.

It seems a similar story with the rest of git. I have hopes for gitoxide aka gix, and think the approach of library-first is correct going into the future. A CLI is then simply a thin wrapper around it, mapping argv to library operations basically.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by 38 on Saturday July 29, 2023 @05:23PM (#36924788)
> it itself does not offer itself up as a library

yeah, it does:

https://godocs.io/github.com/git-lfs/git-lfs/v3

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by diarrhea on Saturday July 29, 2023 @05:34PM (#36924899)
I don’t know what that is, but their docs very prominently and strongly say this:

> However, we do not maintain a stable Go language API or ABI, as Git LFS is intended to be used solely as a compiled binary utility. Please do not import the git-lfs module into other Go code and do not rely on it as a source code dependency.

https://github.com/git-lfs/git-lfs#limitations

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by 38 on Saturday July 29, 2023 @05:57PM (#36925108)
> I don’t know what that is

its a standard output from `go doc`, rendered as HTML. if you dont recognize that, then you aren't really in a position to be commenting on the topic. nothing is stopping anyone from pinning to a tag:

https://github.com/git-lfs/git-lfs/tags

or even a commit and relying on a specific version of the software. yes upgrades might be painful but a module IS available.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by yjftsjthsd-h on Saturday July 29, 2023 @06:28PM (#36925404)
That you technically have the ability to call into an internal module does not in any way constitute it "offering itself up as a library", and doesn't make it effectively useful in that way.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by IggleSniggle on Saturday July 29, 2023 @06:24PM (#36925352)
It is a module. It is available. It does not offer itself up as a library.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by 38 on Saturday July 29, 2023 @06:29PM (#36925410)
> It is a module.

> It does not offer itself up as a library.

in Go code, those are the same thing.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by IggleSniggle on Saturday July 29, 2023 @06:33PM (#36925459)
A library and a module are the same. Having an open and available module does not make it "offered up as a library," was the point I was trying (and failing, evidently), to make.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by Brian_K_White on Saturday July 29, 2023 @06:58PM (#36925687)
You made the point perfectly. So did the docs in the first place. It's not on you that someone decides not to agree the sky is blue because they use their own definition of blue.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by dang on Saturday July 29, 2023 @07:36PM (#36925980)
Please don't cross into personal attack. It destroys what this site is for, and you can easily make your substantive points without it.

If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html and taking the intended spirit of the site more to heart, we'd be grateful.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by dmoy on Saturday July 29, 2023 @09:47PM (#36926912)
Anything's a library if you're sufficiently motivated

- Hyrum Wright, probably

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by jrockway on Sunday July 30, 2023 @01:26AM (#36928116)
I made Kubernetes into a library once. Like the apiserver and default controllers, running in-process. Copying and pasting were involved. I was not expecting support.

If code is out there under a compatible license, you can do whatever you want with it. If it breaks, you get to keep both pieces.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by TkTech on Saturday July 29, 2023 @07:50PM (#36926109)
> It seems a similar story with the rest of git.

Dulwich[1] is a pure-python Git implementation that's been around for many years, meant to be used as a library. I used it a long time ago to make a git-backed wiki. There's also libgit2 which is exactly what it sounds like and it has mature Go bindings[2]. I'm sure there are more implementations.

[1]: https://github.com/jelmer/dulwich [2]: https://github.com/libgit2/git2go

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by coryrc on Saturday July 29, 2023 @08:50PM (#36926516)
> IPC via return codes and parsing stdout/stderr

That's wildly different from Go's method of != nil and error strings.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by benhoyt on Saturday July 29, 2023 @09:46PM (#36926904)
I'm guessing you're being sarcastic. If so, it's not really a fair criticism. Go has properly-typed return values (not just parsing text from stdout) and any type can implement the error interface, allowing for error types with any custom, properly-typed attributes. You use Go's type assertion or errors.Is / errors.As to handle the latter.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by coryrc on Saturday July 29, 2023 @10:39PM (#36927273)
Maybe it's my job, but I don't see a lot of Go code treating errors as anything but strings. Errors I get from Go programs are similarly vague and redundant and lacking context. ("error from RPC: failure making from call: couldn't complete operation: 7 is not a valid flag" ah thanks, so much better than stack trace)

Also it's the weekend and I'm just bitching.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by benhoyt on Saturday July 29, 2023 @10:52PM (#36927346)
I think that's a fair critique. You have to really put thought into good error messages and error handling. When you do, they're nicer and more informative than an ugly stack trace. But a poor error message chain like the one you've shown is significantly less helpful than a stack trace.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by stouset on Saturday July 29, 2023 @11:10PM (#36927432)
Yes, but don’t you value the fact that this error message was painstakingly crafted by hand under the care of skilled golang artisans instead of being mass-produced by an automated exception handler?
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by ttymck on Sunday July 30, 2023 @12:13AM (#36927741)
Yeah because that's the error interface? It's literally a method that returns string.

Unfortunately, I guess after the fact they decided pattern matching was useful, so they did it via reflection (errors.As). But they don't warn you that errors.Is might return false for a true errors.As, it is certainly a mess, but the pedagogy could be improved.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by zaphirplane on Sunday July 30, 2023 @12:30AM (#36927813)
> Also it's the weekend and I'm just bitching

You prefer and in a better mood during the working week ? Interesting

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by Brian_K_White on Monday July 31, 2023 @11:29AM (#36944130)
You jump to a critical interpretation instead of allowing for instance "It's the weekend when I'm off the clock and don't police myself so much"? Interrsting.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by maccard on Sunday July 30, 2023 @04:48AM (#36929213)
I'd like to join the weekend bitching. I do think go's errors are often shitty. Stacktraces are easy to get with [0] and you can always do fmt.Errorf("%s", string(debug.Stack()) to get them in an error. I've not profiled them in go, but in native code they're horribly inefficient to gather so you don't want to be using them unless you really want to I'd bet

That said, other applications have exceptions and people still manage to write functions that return a Boolean to indicate success, and log an equally unhelpful message rather than returning anything I can work with. Maybe we need new programmers.

[0] https://pkg.go.dev/runtime/debug#Stack

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by _ph_ on Sunday July 30, 2023 @05:03AM (#36929300)
The problem with the IPC approach isn't error handling - in the error case a good string is usually fine. The problem is with parsing the output of the sub process. A library can return structured data. Parsing always has the risk of format change or quickly gets very heavyweight. Both in the syntax of the output and the parsing routines. It is another good example of the SVN system, that their commands usually have the "xml" option which creates structured output in xml format. So you can use standard parsers to get robust output. This is also one thing I like about powershell, that commands can produce and pass objects instead of just writing to stdout.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by jacoblambda on Sunday July 30, 2023 @01:25AM (#36928114)
> It seems a similar story with the rest of git. I have hopes for gitoxide aka gix, and think the approach of library-first is correct going into the future. A CLI is then simply a thin wrapper around it, mapping argv to library operations basically.

It's worth noting that there is currently a push to "lib-ify` git internals and it's a gradual process. I'm not actually sure how much of this work has actually made it into the tree yet but I've been seeing patchsets towards that goal on the mailing list since at least January.

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by strogonoff on Sunday July 30, 2023 @03:52AM (#36928871)
Isomorphic Git is a Git implementation purely in JS (no WASM). I wrote a minimal library to handle LFS with it, it’s not that hard, the spec is pretty small.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by adrianmsmith on Sunday July 30, 2023 @04:04AM (#36928939)
I always respected the fact that the authors of Subversion, right from the start, structured their software as a library, with the CLI being a user of that library.

The way IDEs and GUIs interacted with CVS was to shell out to the CLI, which inevitably had problems with filenames with spaces, parsing of error messages, etc. Subversion understood in 2000 that the things were changing, and that the CLI was only one way you'd use a VCS. People were more and more interacting with the VCS via IDEs, or via right-click menus in Windows Explorer, etc.

I felt happy knowing I'd never again have to deal VCSs via tools just shelling out to their CLI ever again. How wrong I was...

Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by diamondo25 on Sunday July 30, 2023 @07:32AM (#36930093)
JetBrains forgot this memo, as it requires you to configure svn.exe in order for it to work. And usually TortoiseSVN is the way to go for subversion...
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t... by alexhornby on Sunday July 30, 2023 @05:28AM (#36929416)
> git-lfs, as in the binary, CLI application is the only (open) implementation in existence. There is nothing else.

There’s at lease one in sapling and Mononoke.

https://github.com/facebook/sapling/tree/main/eden/mononoke/...