Live data from Hacker News

Jujutsu for busy devs

maddie.wtf

451–460 of 552 posts

Re: Jujutsu for busy devs

#451

Earlier quoted context omitted.

> My concern isn't just about pushing upstream. What I'm saying is that the typical change to a file shouldn't be committed to my local repo until I indicate that it's ready Since you brought this up, I've noticed some people seem to work this way but I've never found anyone to ask why they do this. I get the idea behind clean, readable git logs with nice consistent messages, but isn't that what rebase/amend is for?…

I also work this way. A commit is really about, well, committing that these are exactly the right lines of code I intended to write. I also read them in another program, so it gets easier to not think that I already know the code and skip over. I basically start from the clean state (no changes) again and approve the changes line-by-line according to whether they fit the domain model of the program, whether they are…

> I also don't use MS GitHub -style merges, I find them inferior. (I also don't use MS GitHub, but that's for another reason.) I think they try to make merges the actual unit of change, which is stupid, because that is what a commit is for. To me merges are about semantic grouping of commits, i.e. maintaining a tree of commits representing the logical evolution of the code.

Thank you for going into details, you helped me understand a few more details.

Let me describe how I think about it and why it might possibly conflict with your ideas.

I think the best way to describe it is as a series of approvals, each one being more important than the previous one.

The absolute lowest level of approval, writing the file to disk. You've made some changes and you're happy enough with them to at least save them in case you have a power outage or something.

The next level of approval is committing to your local git repo. This is code you're fairly confident you want later, even if it might not be perfect yet.

The next level is pushing your branch to the origin repo. Now you're saying that this is code you're willing to let other people look at.

The last level is merging this code into main/trunk/whatever. This is the final level of approval, this code passes all of our checks, it shouldn't need any more improvement.

Given this system, adding another level in there, for staging commits, feels pretty unnecessary.

I agree that merge commits tend to make for ugly git history, but I don't think that's particularly inherent to any of these systems of code integration, it's more a function of how much the developers care about the git log.

> change commits, but this has a danger of creating a version that was never there or mixing history,

I'm not sure what the benefit here is. I think I've basically ended up in a situation where I treat 'git commit' the same way I treated "save file" 20 years ago. My local commits/saves/edits aren't important, what's meaningful is the final unit of change I'm sending to the remote, and that unit needs to be deliberately constructed somehow. Whether that involves rebasing or amending or careful usage of git stage, it's an artificial unit you're creating just as much as the actual code changes.

Re: Jujutsu for busy devs

#452
post #444

Earlier quoted context omitted.

Yes not using bisect, seams like you do all the work to record information, but then never use that information to save work?

May I use how often and why you use bisect? I don't remember the last time I needed bisect. Well, I also don't work in linux kernel sized repos, so there is that.

> May I use

Was that 'may I ask'?

Not that often, but not seldom. Its useful if you have a bug, that isn't obvious where it comes from, but easily testable. Then you just write a test and let git figure out where it comes from. The test doesn't need to be automatable. I also used it for firmware that needs to be flashed and the bug effected in an LED blinking incorrectly. I still saved a lot of time.

Re: Jujutsu for busy devs

#453

Earlier quoted context omitted.

What is the "right" way to do it then? Also probably most of us are stuck with whatever git*.com supports anyways...

Basically see how the LKML works. Individual commits are typically expected to be self-contained to the best extent possible, with patch sets or patch series being used when that's not feasible. Patches are usually sent over email, but there are a lot of ways to do it. It's not an ideal way to operate for most shops, but there's really no reason you can't have a PR/MR/changelist/whatever that is a single branch with…

> Basically see how the LKML works. Individual commits are typically expected to be self-contained to the best extent possible, with patch sets or patch series being used when that's not feasible. Patches are usually sent over email, but there are a lot of ways to do it.

What is the advantage to this, other than maybe being easier to send over email?

To me, the important part is you have a logical "unit of change" that you're proposing to the codebase, whether that's a single commit or a branch or a jj bookmark or whatever seems more an artifact of the underlying transport layer (email or github or whatever) than any kind of intended functionality of the design.

Re: Jujutsu for busy devs

#454

Earlier quoted context omitted.

I do mean suspending the rebase and going to do something else, yes. It's a weird thing to do in git , because the conditions that git creates makes it weird. It is completely natural with jj, because jj doesn't have any modal states at all. (This is one of the key reasons jj is both simpler and more powerful than git — no modal states.)

You can absolutely do that in git: git checkout master git rebase [whatever] [rebasing stuff] git tag rebasing git checkout --detach master [do random other stuff] git tag todo git checkout rebasing [continue rebasing] When you are not trying to modify the same branch you're rebasing, you can omit --detach and also git tag todo. (To clarify, it has never occurred to me that I even want to do that, so I didn't knew ho…

As far as I know you can't start another rebase -i while you're in this situation. But it's been almost two years since I last used rebase -i so I might be wrong.

Re: Jujutsu for busy devs

#455
post #289

Earlier quoted context omitted.

Can you go into some detail on how you do this? I use jj but it sounds like you make a change and then split it up into more changes after the fact, which I'm not familiar with yet.

I have a bad habit, even still, of just working in one monster commit. It took me a few months to realize that I could use jj split to move specific files to a different commit. And then I'd sometimes squash them into related commits, rebase to move them around etc... But I just discovered interactive split, which lets you move specific lines and sections from different files in a commit to a different commit. So I'v…

One really nice trick you can do is:

- Create multiple topic branches, one for each thing you're working on.

- Now you probably want to work on item A while having B and C all available, so make a single merge commit (jj new a b c) to build on top of.

- Create further commits on top of that, while you're working.

- When you're cleaning up (ideally often), use squash --to or rebase --after to move those commits back the branch they belong on. This does not invalidate the merge commit; you will, effectively, have multiple branches checked out at once.

EDIT: This is apparently called the 'megamerge workflow'.

Re: Jujutsu for busy devs

#456
post #358

Earlier quoted context omitted.

> to reset or view the repo at a previous state What about `git reflog`?

That lets you see previously checked out revisions. Jujutsu keeps track of all previous repo state. In git, you can pull a new remote branch, delete that branch, and push the deletion. If you want to get that branch back, git reflog will only save you if you checked out that commit. If you didn't, you're SOL. Jujutsu will let you undo the delete operation, restore the repo to a state where the branch existed, or view…

What if you commit secrets to the repo by accident?

Re: Jujutsu for busy devs

#457

Earlier quoted context omitted.

That lets you see previously checked out revisions. Jujutsu keeps track of all previous repo state. In git, you can pull a new remote branch, delete that branch, and push the deletion. If you want to get that branch back, git reflog will only save you if you checked out that commit. If you didn't, you're SOL. Jujutsu will let you undo the delete operation, restore the repo to a state where the branch existed, or view…

What if you commit secrets to the repo by accident?

Just edit it out and don't push it to upstream?

Re: Jujutsu for busy devs

#458
Hands down one of the best features in jj is undo. In Git, undoing things is always a bit of an open heart surgery, with different commands depending on what you fucked up. In jj? Just a simple jj undo, done. That alone is a killer feature.

Then having the whole thing being kinda agnostic by design to the backend system, that is also a sweet spot.

I can comfortably use jj locally without any of my teammates knowing that I use jj instead of git.

Re: Jujutsu for busy devs

#459
post #384

Earlier quoted context omitted.

I think `git add -p` and its friends are another thing I'd point to for this. I've never really struggled too hard to get git commits into different branches for review, but if you've put unrelated changes into the same working dir, you'll want `git add -p` to sort them out into multiple commits. Note there are corresponding `-p` flags for things like git-restore and git-reset as well.

Let’s say you’ve checked out a new branch and done a bunch of work over the course of the last two hours. You’ve added a new feature. In doing that, you’ve also fixed four unrelated bugs, clarified the documentation for a method you needed to use, and rewritten another function to be more performant. You could push this all as six commits on one branch. PR reviewers will now have to figure out what parts are related…

> You could push this all as six commits on one branch.

No, I'd probably put them all as individual branches to be reviewed, assuming they're truly independent changes. As long as they don't actually conflict it's not very hard to do this in git.

But this is kind of what I mean when I say that git fits my needs, because I wouldn't come across 4 unrelated tasks like this in the course of implementing a single commit's worth of features, unless I was having the world's biggest attack of ADD.

And if these things did need to get done to properly implement the feature to our team's quality standards, it would be appropriate to be included in that feature's PR as well.

I'm sure it's a nice tool, especially for those who work in domains where it takes a long time to land your commits into the main branch of development, but a lot of this sounds like solutions to problems that we don't all have.

Re: Jujutsu for busy devs

#460

Earlier quoted context omitted.

Some people love to tinker and fine tune their tools to behave exactly like they want. I am not one of those people. I hate it. It does not spark my joy. Most people use the default for most of their tools. It’s why Google pays Apple over $20 billion per year to be the default search engine. Because defaults matter.

But you can't make a default that everyone will like. The best overall interface will have someone hating it. If you want to always use defaults, you're basically guaranteeing that you'll hate some genuinely great software one day.

I can’t spend a dozen hours fine tuning every single piece of software I come across because it might maybe possibly be great if I do.

If I used Git as part of a large team I’d perhaps spend more time with jj. But for solo projects it adds even more complexity to Git rather than reduce. So I don’t feel strongly inclined to spend that time.

Post reply on HN