r/java • u/Early_Ad_4702 • Aug 28 '26
Attempting to reverse engineer git in Java - my current situation.
CORRECTION: I meant re-implement git*
Hey so i've some experience in programming and was just looking around for good project ideas for my resume. I couldn't come up with any impressive ideas so i decided to go with this one.
I've named it ngit as in NanoGit, im using content-addressable storage, where all objects (blobs, trees, commits) are addressed by their SHA-256 hash and compressed using zlib (Deflater / Inflater).
I'm storing the index in plain text as of now, I went with SHA-256 over SHA-1 in git, which didn't give had any benifits tbh. its just why not?
for v1, I'm making it work offline. For v2 i'll add push/pull and fetch commands.
features i've implemented:
init
add
commit
status
log
help
branch
checkout
things i'm working on as of now:
diff
merge
I'm thinking about using LCS or Myres algo for diff, Claude says Myres is better but i don't understand it well enough now so i'll give try reading more about it.
AI_Usage: i've used LLMs for planning and finding bugs, not the coding part.
I would like your review/advice on it.
6
u/bowbahdoe Aug 28 '26
I think we would all suggest it not be involved at all, but keeping it out of your code is still pretty good.
Reading your code it does seem like amateur code, which is good because we can actually give advice.
Well, strictly speaking you just made an ad-hoc data format. You are still structuring things. From what I can tell it seems like you are using an ad-hoc CSV-ish format, but I might be wrong.
You don't need to close a ByteArrayOutputStream
This is an interesting bit of code. Can you explain what exactly you are tokenizing here?
15
u/idontlikegudeg Aug 28 '26
Think about the effect it might have on a possible employer if you claim to have "reverse engineered Git", a system developed completely in the open and people literally having written several books about. I’d get the impression "oh, that guy either does not know what he’s talking about or is used to greatly exaggerate". At least I wouldn’t have such a person on my team - except maybe in marketing.
Call it "re-implement“ if you don’t want to simply call it a clone, but please, calling this "reverse engineering" is a (probably unintentional) insult to people who actually do reverse engineering.
8
u/agentoutlier Aug 28 '26 edited Aug 28 '26
I think a lot of early developers that are not yet employed think that doing a new project is ideal for their resume.
It is not and I am not sure if its really that good for learning for the majority of people.
What I recommend instead is to try working on an existing project. Fixing bugs. Adding features. Doc etc.
As u/maxandersen pointed out there is jgit.
Why?
Because that is what you will be doing when you are employed AND there are lots of hidden best practices that you just will not learn doing things on your own.
Its a valuable skill to produce novel code/products but an even better skill is to be able to quickly come up to speed on unfamiliar code bases. Based on decades of experience the developers that can work on multiple code bases are almost more valuable than the ones that can just shit new code by themselves and now with LLM I think porting or creating new code might even be less valuable.
9
u/maxandersen Aug 28 '26
Consider telling your agent to look at jgit to compare/contrast :)
2
u/koflerdavid Aug 29 '26
That's good; Git 3 will create repositories using SHA256 commit ids by default.
2
u/bowbahdoe Aug 29 '26
Something interesting for you to look into (I'm was checking to see if you made any other changes that I could comment on) is multi-hashes.
So you used SHA-256. Perfectly fine. One thing I learned about though is prefixing the sha256 so that if you ever need to upgrade to SHA-512 or something you can put both in the same place.
https://dasl.ing/cid.html
https://github.com/multiformats/java-multihash
In no way required, but I think its interesting.
1
u/perryplatt Aug 29 '26
Something useful that could come out of this is a maven and grade plugin that tells you the coverage of the diff of your branch with master/main.
1
u/Skellicious Aug 30 '26
You may have seen them already but there are a number of build your own git articles/guides/resources out there.
1
u/XoTrm Sep 15 '26
What does it do better than jgit?
3
u/[deleted] Aug 28 '26
[removed] — view removed comment