News for hackers. Stuff that matters.
Re: by arxanas on Tuesday November 15, 2022 @03:17PM (#33614427)
Instead of `git add -p`, you would use `sl commit -i` (whose interface I much prefer). To amend into a previous commit, I prefer to switch to it and then just use `sl amend` (+ `sl restack` if necessary), but you can also use `sl fold` IIRC. Instead of `git rebase -i`, you can use `sl histedit` (not a direct replacement for autosquashing, but worth mentioning).

To split a single commit, you can use `sl split`, which is quite difficult in Git. (I miss that feature in Git quite a lot.) You can also use the `sl absorb` command to automagically merge local changes into the previous patches where they seem to belong (roughly speaking, commute changes backwards until they would cause a merge conflict, but it's a little smarter about avoiding certain merge conflicts).

Re: by ArchOversight on Tuesday November 15, 2022 @03:22PM (#33614500)
If I switch to a previous commit to amend it, then I would temporarily lose all the other changes I made, and means I can't easily run tests on that particular commit to validate nothing else broke.

It sounds like I would need to:

- switch - amend the commit - restack? - switch back to the HEAD?

Fold based upon the documentation seems to move older commits into the current commit? vs the other way around? https://sapling-scm.com/docs/commands/fold

This doesn't seem analogous to git rebase --autosquash which merges the mixup into the old commit.

Re: by arxanas on Tuesday November 15, 2022 @03:31PM (#33614598)
Yes, in my preferred workflow, I usually create a temporary commit and then switch away. Sapling also has `sl shelve` as `git stash`.

If you want to run tests on commits without checking them out, you might want to try my `git test` command: https://github.com/arxanas/git-branchless/discussions/643

You can use `sl fold --exact` to combine arbitrary commits without including the current one. (To be honest, I just always used `sl histedit`.)

Re: by mitrandir77 on Tuesday November 15, 2022 @04:23PM (#33615210)
`sl histedit` is very similar to `git rebase -i` if you're famiilar with that interface which works just fine.

Other commands useful for amending changes to previous commits: * `sl goto --merge <hash>` - if theres no conflicts you can just switch commits with pending changes and those pending changes would be applied on top of other commit. If there are conflicts this command would fail https://sapling-scm.com/docs/commands/goto * `sl absorb` - this automagically finds the last commit that touched the lines that are pending and amends that commit with them https://sapling-scm.com/docs/commands/absorb

Re: by tchebb on Tuesday November 15, 2022 @04:47PM (#33615488)
`sl absorb` can turn that workflow into a single command in many cases: it automatically looks at what hunks you've changed and tries to propagate them back to earlier commits in the stack that touched those same hunks. It's not perfect, but in my experience using this at Meta, it does what you want 90% of the time.
Re: by andrewshadura on Tuesday November 15, 2022 @05:01PM (#33615671)
Consider also trying git-crecord, which is a port of he's curses-based partial commit interface.
Re: by andrewshadura on Wednesday November 16, 2022 @02:32AM (#33620040)
Oh, I didn’t notice a typo — hg’s.
Re: by charcircuit on Wednesday November 16, 2022 @12:13AM (#33619196)
sl record is another shorthand for an interactive commit.