Xit: a version control system

Hi guys, I’m working on a version control system. Nothing big and professional like git :^)

24 Likes

In case anyone missed the nice big and professional reference: Linux announcement

15 Likes

Sounds like a fun but daunting challenge! The code looks very readable, thanks for sharing. How have you found Zig for network / HTTP stuff?

Your writing style is hilarious, I’ve learned a bunch from xit/docs/patch.md at master · radarroark/xit · GitHub, and had a good laugh, because CRDT, thanks!

6 Likes

And possibly a fabulous waste of my time, but it’s been a fun ride anyway lol.

Zig’s http client has worked pretty great for me so far. It supports everything I need, like chunked encoding. The only issue right now is that on linux, when you clone/fetch from github, you’ll see an ugly stack trace with unexpected errno: 1 even though it actually succeeds (this happens on both 0.13 and 0.14). I’ve found similar issues already made so I’m not sure it’s worth reporting.

SSH is certainly the most important transport anyway, and it was actually the easiest to implement. Just spawn the process and send the right pktline format, letting ssh do the rest.

Thank you :^D Working on version control is often incredibly dull, so I need to do that just to maintain my sanity.

3 Likes

I’ve done my git from scratch thingy and I found it very rewarding. Not dull at all.

Yes, your notes on design are really fun to read. You should start a blog :slight_smile:

On TUIs. I’ve used libvaxis, and I’m curious as to why you didn’t you use that. One UI style you might want to explore for short cuts is how wordstar/wordperfect used to do it, where there was a menu always visible. Or there’s the way that editors like doom emacs, helix, etc do it - where pressing a common key (space) opens up a menu that shows available short cuts. I’ve always found that a good compromise, as it makes it easy to discover learn shortcuts, while also giving the speed efficiencies once you’ve learned them.

Also, have you seen GitHub - jj-vcs/jj: A Git-compatible VCS that is both simple and powerful ?

2 Likes

fyi jj is discussed in xit’s compat document

As for libvaxis (which I also use and really like), the readme makes a point about avoiding 3rd party dependencies.

2 Likes

How does one pronounce ‘xit’?

My guess: Like Xi in Jinping, but with a t at the end. Git is also not a “nice” word so that would fit :grin:

1 Like

Oh fair, I’d forgotten that you’re avoiding third party dependencies.

I didn’t think to read the compat document, but that does answer my question.
I like your approach to this a lot. For my purposes at the moment obviously Jujitsu is more practical, but I’m definitely going to follow your progress. This feels right.

You’re in luck!

In addition to the no third party libraries thing, I also made xitui due to actual design differences. I think libvaxis differs on these points, but correct me if I’m wrong:

  1. I don’t like how these UI libraries always use dynamic dispatch. You already know the widget types in advance, so why not have a user-defined union type? Here’s what it looks like in xitui. Union types avoid unnecessary indirection / pointer chasing, and are more readable IMO. Since it is user-defined, you can still add custom widgets.
  2. In xitui, widgets always render to a buffer, rather than directly to the terminal. Their parent widget then can decide to use that buffer (or not). This is really important for complex layouts and responsive design.
  3. There is a generic system for tracking focus and selection. Every widget knows which (if any) of its child widgets are selected, and which widget in the entire graph currently has focus. Most TUIs just don’t provide a good indication of either focus or selection. Those that do often only use color to indicate it, which is bad for accessibility.

I’m not claiming xitui is perfect or production-ready though. It’s doing a lot of inefficient stuff right now. I still have a lot of work to do before I can claim it’s a good alternative to libraries like that.

I pronounce it like “zit”. In fact that’s how it used to be spelled (for zig + git), but I changed the spelling to make it more searchable since zit is a common english word.

Feel free to pronounce it this way if you run into any bugs :^D I’m looking forward to the day someone makes an ohshitxit.com actually.

5 Likes

If you made the announcement as a reply in other’s topic, just like what the git author did for his another fun project, that would be even more hilarious. :rofl:

This is a design consideration I’m not particularly pleased with in the vxfw portion of libvaxis…Right now everything is an *anyopaque for the widgets, which has been working well but also is very annoying when you need to allocate small widgets just to have them work in the framework. That said, this only exists in that portion of the library. The core doesn’t use any dynamic dispatch and (if you wanted a dep) you could build off the underlying library. One design consideration that is nice about the dynamic dispatch (and defining your own VTable) is that I can define separate widgets for the same pointer just by providing a different Vtable (IE an IRC channel can have a widget to draw the name of the channel, a widget to draw the members of the channel, a widget to draw the message view, a widget to draw the text field, etc…all with the same pointer, just a different VTable).

So far, the main reason I haven’t implemented Widgets as a tagged union is because of memory - I’ve been hesitant to have an individual widget take up the space of the largest - and they can get large. I have a ghostty widget in the works for an embedded terminal-in-a-terminal, and the memory of a single ghostty widget is at least an order of magnitude more than a Text widget.

If you haven’t looked at the vxfw portion of libvaxis, it does essentially the same thing. Each widget returns a Surface which is a buffer of Cells, a size, and a reference to the Widget that drew it. It’s all inspired by flutter so that I could get to a single pass layout. I’ve been pretty happy with how that layout style works (Parent gives Child size constraints, child draws within those constraints and tells parent it’s final size, parent sets location). The referenced widget is then used for directing events…since we have a tree of widgets we can accurately send events up and down the tree until someone consumes it. (This gets to your third point about focus and selection, which is also implemented in the framework).

Anyhow - there are a few ways you could use the library without getting into the widgets:

  • bork uses the input parsing and tty stuff, but implements it’s own rendering
  • flow uses the input parsing, tty stuff, and rendering, but implements it’s own event loop and widgets
  • ghostty +show-themes uses input, tty, rendering, and event loop, but implements it’s own drawing / widget logic
  • comlink uses the full out vxfw framework (input, tty, rendering, event loop, and widgets)

All of that said - terminal handling isn’t that complicated and it looks like you’ve done a great job so far :). Excited to see where xit goes!

8 Likes

Fair enough. In that case I would just put that particular widget’s state behind a pointer though, rather than adding that indirection to all widgets.

Ah gotcha, it sounds like my last two points are not actually differences then. That actually gives me comfort…I second guess myself a lot so if we’re doing something similar then that’s good :^D

4 Likes

Is that my dream project?
I pretty sure I want to use it and help you developing it.

My story how I tried and failed with jj-vcs

Long story first => they just have failed (as for my needs completely) with supporting one ever thing they must be supporting => git push (80/20 rule) so business will never care about inner if 20% just failed

And TUI! I really want working with all that (I remember creating my first website on Nokia small screen phone with php, html, css) and now I pretty sure the TUI must support Android and Iphone

So, what are in current priority to implement?

@radarroark By the way, could we move on organization? I pretty sure it helps on maintaining things right way more than forking several repositories.

I’m sure it’s pretty awesome you’re doing

Things are moving fast. I added symlink support today and fixed a bunch of windows issues. Yesterday I made the TUI waaaay faster. The day before that I added force pushing. I’m all over the place.

As for my to-do list, it’s pretty long. A lot of it is just catching up with git: submodule support, rebase, revert, stash, etc. I also need to implement universal undo, a big feature enabled by xitdb. It’s gonna kick ass.

I’m not sure what you’re asking, can you rephrase it?

2 Likes

Organization is about GitHub Organization with a name like “xit-vcs” and all related repositories in it.

hello,
can we do that please.

git commit -m  "maj_20250313-12:15"