16 ms·
Git implemented in Rust
- hannob 8y agoI don't see any info about a license. Strongly recommend using some standard FOSS license before plenty of people add commits and it gets a big mess clearing up the licensing situation later.
- littlestymaar 8y ago> Implementing git in rust for fun and education! Also, not having a license file isn't a messy situation, that means “this project is protected under Berne Convention copyright“: the author is the only one holding every rights on the code and every use that is not explicitly allowed is a copyright infringement (unless it's fair use).
- adrianN 8y agoFair Use doesn't exist in many jurisdictions.
- littlestymaar 8y agoIt isn't called that way and doesn't offer the same amount of protection everywhere, but the Berne convention itself includes copyright exceptions [1] that I included in the broad “fair use” phrase. [1] https://en.wikisource.org/wiki/Convention_for_the_Protection_of_Literary_and_Artistic_Works/Articles_1_to_21#Article_10 https://en.wikisource.org/wiki/Convention_for_the_Protection...
- fulafel 8y agoNot the op, but it seems your linked bit of the BC justsays that countries are allowed to legislate exceptions. The only hardcoded exception is the short citation one.
- CamouflagedKiwi 8y agoThe author doesn't hold copyright on code other people submitted unless they explicitly give ownership via a CLA or similar. A licence would make it clearer, or at least a lot easier for other people to consume.
- littlestymaar 8y agoExactly, but since it's a learning project it's not obvious it's supposed to receive and accept code contribution anyway (so far it didn't receive any, the only two commits are fixes to typos in the README). That being said, it would be nice from the author to put the code under a permissive license to allow other people to play with his code too (at the moment, even forking it is a copyright infringement…).
- slavik81 8y ago> at the moment, even forking it is a copyright infringement Not that it changes much, but from the GitHub Terms of Service: > By setting your repositories to be viewed publicly, you agree to allow others to view and "fork" your repositories https://help.github.com/en/articles/github-terms-of-service#5-license-grant-to-other-users https://help.github.com/en/articles/github-terms-of-service#...
- littlestymaar 8y agoYes you're right, github forking is allowed. Pulling the code on your computer, changing it and contributing changes on your fork is still illegal though.
- GoblinSlayer 8y agoNot illegal, but rather not granted (and not denied either). Only the author decides, as it's his right, not someone's else.
- fxfan 8y agosince you sound knowledgeable- if I go and without any contract "donate" some of my code to the repo- what becomes of the right to that code (the patch I contributed)?
- EwanToo 8y agoYou retain the copyright of the patch and can re-use it somewhere else under a different licence. And in turn, the project you submitted it to cannot re-licence that patched section of code (e.g. become either GPL licenced) without your permission, as it does not belong to them. (Edit for clarity)
- masklinn 8y agoOne issue is under the Berne baseline, even given github's license grant[0], there is no license to make adaptation, arrangement or derivative work. So it's unclear that the patch would even be legal to start with, in the sense that it's either a modification / adaptation of the work or a derivative of it. [0] https://help.github.com/en/articles/github-terms-of-service#5-license-grant-to-other-users https://help.github.com/en/articles/github-terms-of-service#...
- littlestymaar 8y agoYes, the patch would be illegal, but the original author still wouldn't have all the rights on it. And it could also be illegal if the original author distributed the amended code elsewhere. Edit: I edited my comment to say “could” instead of “would” because the original author could argue that the author of the patch implicitly gave him the right to redistribute his patch by contributing it to a public repository. I'm not sure it would stand in court, but I'd say it would have a non-null chance of success. But If the author, who initially claimed the project was a learning project, decided to use it commercially, he clearly wouldn't be allowed to use the patch. (and again, it could be different if the patch author willingly contributed to a commercial product).
- GoblinSlayer 8y agoGit derives patches from files on disk, so the patch inherits the file's license. Logically you commit files or even the whole source tree, a patch is an optimization detail, which is used to rebuild the source tree at a given point, so it's a matter of what license the source tree has at that point.
- mnd999 8y agoArguably by downloading it from github you’ve made an illegal copy.
- louiz 8y agoNo, you copied on your hard drive something that was offered to you for free on github. Hosting that code yourself somewhere else would be illegal though.
- masklinn 8y ago> No, you copied on your hard drive something that was offered to you for free on github. It wasn't offered for free local reproduction since that right was not explicitly granted, and Github's license grant does not grant it either (as far as my reading goes). Though the country you're in may have a private copy exception, in which case you'd be in the clear I think (depending on the specifics of that exception).
- littlestymaar 8y agoIt might depend on the legislation though. In France at least it would fall behind the «Exception de copie privée».
- ndnxhs 8y agoBy making it public to view you agree others can load the page and view the code. Loading the page and viewing it is downloading it.
- kevin_thibedeau 8y agoThat's not how copyright law works. The particulars vary by country but the share everything internet culture doesn't automatically grant permission to make copies.
- Zarel 8y agoThat sounds nice and all but it's wrong in two major ways. First: GitHub has a Terms of Service which was somewhat-recently amended to make this license grant explicit: https://help.github.com/en/articles/github-terms-of-service#5-license-grant-to-other-users https://help.github.com/en/articles/github-terms-of-service#... "Any User-Generated Content you post publicly, including issues, comments, and contributions to other Users' repositories, may be viewed by others. By setting your repositories to be viewed publicly, you agree to allow others to view and 'fork' your repositories (this means that others may make their own copies of Content from your repositories in repositories they control)." (Crucially, it doesn't require an open-source license, though.) Second: even without that, there's such a thing as an implied license: https://en.wikipedia.org/wiki/Implied_license https://en.wikipedia.org/wiki/Implied_license Like, if you write something down on a piece of paper, you can't then sue the owner of the paper for copyright infringement. Similarly, if you upload code to GitHub, and tell it to share your code, you can't then sue them for sharing your code, ToS or no ToS.
- masklinn 8y agoPretty much all the TOS says is there's an implicit reproduction license (other users can see & fork the work) and possibly broadcast (the fork itself has the visibility of the original). Not adaptation, not use, not exploitation, … And that license grant is solely through github as a service, it's unclear that a local clone is even permitted.
- blattimwind 8y ago> And that license grant is solely through github as a service, it's unclear that a local clone is even permitted. That license grant has been added specifically to make GitHub itself waterproof (AIUI), so it makes sense it doesn't extend to user's rights. Look, but don't touch.
- Zarel 8y agoThat's... somewhat true. My main objection is to "the author is the only one holding every rights on the code and every use that is not explicitly allowed is a copyright infringement (unless it's fair use)". The ToS doesn't say there's an implicit reproduction license, though; it says there's an explicit reproduction license. The other licenses can still be argued to be implicit. For instance, you have a decent argument that local clones are an implicit license – GitHub provides a "Clone or download" button directly on the repo page, and it's one of the main use cases of GitHub. (Other arguments exist.)
- devit 8y ago"Use" is allowed, redistribution of the original or derivative works is essentially what is not permitted.
- littlestymaar 8y agoI guess it depends on what you call «use». You can read the code, for sure, probably even save it on your disk (it may depend on your jurisdiction though). But, can you compile it ? I'm not sure… Better ask your lawyer. And what about running the compiled binary ? I don't think you're allowed to do that.
- kevin_thibedeau 8y agoThat's how copyleft licenses work. Base copyright law is more restrictive and possessing an unlicensed copy can be infringing in certain countries. This is why public domain is sometimes problematic.
- josteink 8y agoEasiest way to fix that is often just sending a PR with whatever is the “default” license for that particular eco-system. For Rust that is (afaik) MIT. Why don’t you go try it? ;)
- steveklabnik 8y ago(MIT/Apache2, yes)
- aorth 8y agoAs of a few minutes ago the project now has an MIT license. So that clears that up! https://github.com/chrisdickinson/git-rs/blob/master/LICENSE.md https://github.com/chrisdickinson/git-rs/blob/master/LICENSE...
- e12e 8y agoFwiw license (mit) has been added in the past 7 hour: https://github.com/chrisdickinson/git-rs/commit/2be8314b9b1ce65115aeda49bf33add063a191c7 https://github.com/chrisdickinson/git-rs/commit/2be8314b9b1c...
- akdas 8y agoI love to see people reimplementing existing tools on their own, because I find that to be a great way to learn more about those tools. I started on a Git implementation in Rust as well, though I haven't worked on it in a while: https://github.com/avik-das/gitters https://github.com/avik-das/gitters
- giancarlostoro 8y agoAre you basing it off anything in particular? Like outside of just going through gits own source code?
- kreetx 8y agoJust reading source code is a whole different experience than actually implementing something yourself. Implementing something pretty much forces you to "be right" in your understanding, while reading can be anything from "really studying" to skimming.
- tracker1 8y agoCompletely agree, though sometimes you HAVE to go through existing source when you do something wrong. I've implemented libraries based off of specs and white papers, and even then there's some vagueness that doesn't work in practice when there are holes. Love to see things like this all the same as they tend to solidify protocols/specifications. This of course can have both good and bad results.
- akdas 8y agoI haven't even looked at the git source code. My implementation was based mostly on the official docs. The docs include a section on the internals: https://git-scm.com/book/en/v1/Git-Internals https://git-scm.com/book/en/v1/Git-Internals
- ernst_klim 8y agoAlso a git implementation in pure OCaml, used for irmin git-based kv storage: https://github.com/mirage/ocaml-git https://github.com/mirage/ocaml-git https://github.com/mirage/irmin https://github.com/mirage/irmin
- ioquatix 8y agoHere is an implementation of a Ruby based kv store build on top of rugged, which is built on top of libgit2: https://github.com/ioquatix/relaxo-model https://github.com/ioquatix/relaxo-model It's so much fun, but not that practical for scalable websites.
- ernst_klim 8y ago>It's so much fun, but not that practical for scalable websites. Git based kv has a bit different purpose than the regular kv storage. They are intended for communication between entities, running in parallel, sort of transactional memory. They are not intended for users' data storage.
- seanmcdirmid 8y agoThat sounds more like a tuple space than a KV store?
- ernst_klim 8y agoNot sure, but the idea is that you could not only read and write, but write in parallel so the keys are merged according to the merge rule you've provided.
- empath75 8y agoMan I was thinking last week that something like this based on git or pijul would be a better backend for kubernetes than Etcd is.
- d33 8y agoI like the changelog. Looks like a zero-effort way to publish something other people could make use of.
- chx 8y agoNo, currently they can't as there is no open source license.
- cyborgx7 8y agoI used it anyway. Sue me.
- Chris2048 8y agoTo be honest, I wish there was a movement for something like "literate changelog", where the CL was propely linked with something like a blog post, and specific repo versions. I guess Pull Requests sort of take that role.. But sometimes PR diffs aren't the same as annotated code in a blog post.
- kasbah 8y agoI believe that's done through conventional commits. https://conventionalcommits.org https://conventionalcommits.org
- OpenBSD-supreme 8y ago>rust this >rust that Why re-invent the wheel? Ada is superior. :^)
- k0t0n0 8y agoawsm I was really interested in how could one go about implementing git like system. nice work OP
- johnklos 8y agoLet's port already portable software to non-portable languages! Yay!
- Ygg2 8y agoWhat do you mean by non-portable? Can't run on 32mb RAM?
- beatgammit 8y agoYou can run Rust code on microcontrollers where 32mb of RAM is far beyond the amount available. You won't be able to compile on that platform, but you can certainly target it (but git might not fit).
- giancarlostoro 8y agoRust is pretty darn portable as it is though. It runs on the major platforms. Are you thinking its Assembly or something? Everywhere FireFox is compiled to Rust has to run on, which is a lot of platforms. Maybe it wont run on your toaster but if you are making git commits through your toaster you got other issues.
- nindalf 8y agoI agree with the sentiment behind your comment. Rust is very portable, but isn't portable to all platforms. Obviously it works on the big ones like Windows, macOS, most variants of Linux, BSD etc. but it doesn't on Alpine Linux. IIRC there was an issue compiling it without glibc (which Alpine lacks). Edit - apparently rustc can now be linked to musl instead of glibc in nightly. Cool!
- vbarrielle 8y agoRust can be compiled without glibc, by statically linking to musl, but it looks like it's still experimental as the only distribution of it is on the nightly channel: https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-musl.tar.gz https://static.rust-lang.org/dist/rust-nightly-x86_64-unknow...
- qualsiasi 8y agoAm I the only one who thinks of this article after reading the whole thread? > https://overreacted.io/name-it-and-they-will-come/ https://overreacted.io/name-it-and-they-will-come/ HN discussion: https://news.ycombinator.com/item?id=19485609 https://news.ycombinator.com/item?id=19485609
- jonty 8y agoIf you're interested in this, you may enjoy "Building Git" by James Coglan - a comprehensive book that takes you through reimplementing git in Ruby. https://shop.jcoglan.com/building-git/ https://shop.jcoglan.com/building-git/
- abhijat 8y agoIf you have read this book, would you care to comment about its content and quality? It is something I am interested in buying but I have not been able to find reviews of it.
- kbknapp 8y agoIt's pretty good, I'd recommend it. I haven't finished the book yet, but what I've read thus far has been good. Something I'd wish I'd known (although it wouldn't have changed my decisions to purchase) is that it's not an exploration style book (i.e. "Let's cat this file and find out what it contains and why.") it's more of an explanation (i.e. "When I cat this file, it outputs XYZ which means ABC which I know from my research of the git source."). So the author isn't taking you along on their research, but rather coming back to you after the research is done to explain their findings from the ground up. This means early chapters have a lot of, "You'll just have to trust me XYZ means ABC." But this is also understandable given the complexity of git; there isn't really a square one. I also would have preferred the author use something like Python instead of Ruby for the reference implementation. IMO Python is a little more ubiquitous and easier to install/setup than Ruby. Ruby also leaves Windows devs at a disadvantage. But that's just me being pedantic. Overall I'd give the thumbs up.
- abhijat 8y agoThanks, I bought the book after finding a sample chapter on the author's website.
- steveklabnik 8y agoI haven’t read it yet, but I’m lucky to call the author a friend. I read all of his tweets about it while he was building it. I expect it to be of extremely high quality. I’ve got a lot of respect for his abilities. The only reason I haven’t read it yet is that I think it deserves a lot of attention and I haven’t made time yet.
- ryanolsonx 8y agoI started one in PHP (because why not). It's pretty fun!
- mises 8y agoCan somebody tell me what is behind the recent rewrite-all-the-things-in-rust craze? I get it can have some benefits in terms of security, but it seems rewriting so many things in it just for the sake of it is a bit excessive. I understand some of these are very likely for educational purposes (like this one and others; it's good for getting more familiar with the language), but it still seems to be a bit of a strange trend (especially since people who don't need to learn are doing it, seemingly just because "yay rust").
- emef 8y agoRewriting existing software in a new language is one of the best ways to learn a language. > especially since people who don't need to learn are doing it Don't need to learn?? There's always something to learn.
- adamnemecek 8y agoI support RIIR 100%. It’s much easier for me to contribute to Rust projects. It’s not just the language (but that is definitely a part). I don’t need to worry about shit like “how do I build this project” or "my code might run on platforms x and y but I'm not sure about platform z". With c/cpp, the build process can be potentially very complicated. Missing headers, missing binaries. With Rust, I just run “cargo build”. Furthermore, the resulting code feels just so sturdy. I can also expose it as C and it can be used from the likes of Python.
- josteink 8y ago> With Rust, I just run “cargo build”. The value of simple things like this is immensely underestimated.
- beatgammit 8y agoYeah, I just spent a couple hours configuring CMake when I was porting a Windows app to Linux, and it was a pain tracking down all of the dependencies. I had a similar app in Rust that worked with a `cargo build` out of the box (actually, my friend rewrote my Rust version to C++ because I was lax in updating it). Say what you want about Rust v C/C++, but you cannot tell me that Rust's build process isn't easy. In fact, building for other platforms is pretty trivial, just `rustup add <target>` or wherever and you can target pretty much any common platform and many uncommon ones, and those targets will get updated with everything else. In fact, it's so nice that I have to convince myself to not use it as the way to distribute CLI apps (`cargo install <tool>`).
- sneakernets 8y agoI'm still waiting on a C64 port.
- deleted 8y ago[deleted]
- shafte 8y agoNot really related, but a quick plug for the work that Mercurial is doing to port substantial portions of its main binary to Rust: https://www.mercurial-scm.org/wiki/OxidationPlan https://www.mercurial-scm.org/wiki/OxidationPlan My understanding is that they want to get it fully ported before Python 2 EOL.
- _bxg1 8y agoRust seems like a good language for git given its performance and memory-safety, no?
- aidenn0 8y agoActually any high performance GC'd languages would be fine too because latency is a non-issue for long running git operations (you won't notice if your git clone pauses for 100ms, whereas you will notice if your UI does). Throughput of malloc() and GCd languages tends to be similar when latency isn't a concern.
- sreque 8y agoGC is only part of the equation. I have always found this article informative: https://marc.info/?l=git&m=124111702609723&w=2 https://marc.info/?l=git&m=124111702609723&w=2 Performance for higher-level languages is usually great in-so-far as you're able to essentially write C code in that higher level language. When the language's limitations inhibit you from writing the C code you want to write, performance usually suffers. In java's case, lack of value types and stack allocation can be a major performance hindrance. Boxing is also a problem, although, as the mailing list post notes, this is easily overcome-able via manual specialization.
- _bxg1 8y agoI was speaking more to stability. Rust is designed to be an incredibly safe language without sacrificing any performance; that seems like a good match for a version-control system.
- aidenn0 8y agoMost GC'd languages are also memory safe.
- iknowstuff 8y agoFYI, Rust's safety goes beyond that. Its ownership model keeps you safe from data races, unlike, to my knowledge, GC languages.
- chris_mc 8y agoI would like to see some sources like this that are language agnostic that give you the tools needed to implement your own popular tool. For example, where could I look to find a written description of the way git works from the ground up? Kind of like a "guide to implementing X" type of thing, but without code.
- SilasX 8y agoWhat's with all those posts about "X implemented in Rust" today?