spr icon indicating copy to clipboard operation
spr copied to clipboard

spr diff uses jujutsu to amend?

Open sunshowers opened this issue 2 years ago • 6 comments

Hi everyone,

I've been using spr for the last year or so and really love it so far. As an ex-Meta source control person I've always preferred the stacked diff workflow and spr is the best tool of the lot.

I've been trying out Jujutsu version control with a colocated Git repository, and that works pretty well in conjunction with spr (since jj and spr are both about amend/rebase-based workflows). But there's a little nit I ran into, which is that spr diff, spr amend etc use git commit --amend to amend commit messages. This is okay, but essentially creates a separate commit with its own identity in jj -- jj cannot link the identities of the old and new commits.

Ideally spr would be able to run jj describe @- --stdin and feed in the message over stdin, which would avoid this problem. Would it be okay to extend spr's amending logic to use jj describe if a jujutsu repository is found?

sunshowers avatar Nov 08 '23 03:11 sunshowers

Some ideas on the jj side of things:

  • If there is a branch attached to the commit, then jj will correctly track the rewrite the next time it imports refs. I don't know what your workflow looks like, exactly, but if you could attach a branch to help jj out, then everything should work fine.
  • It might be possible to create a post-rewrite hook that notifies jj about rewrites performed outside of its scope of knowledge. For example, if it piped the rewritten commits to a hypothetical jj util record-rewritten command, then neither you nor spr would have to make any architectural changes to support this use-case (if I understand it correctly).

arxanas avatar Nov 10 '23 00:11 arxanas

If there is a branch attached to the commit, then jj will correctly track the rewrite the next time it imports refs. I don't know what your workflow looks like, exactly, but if you could attach a branch to help jj out, then everything should work fine.

Ahh part of the point of me using jj is that I really want the anonymous heads workflow :)

sunshowers avatar Dec 11 '23 21:12 sunshowers

I wrote some very basic support using the jj cli -- it likely needs more polish, but it works okay: https://github.com/getcord/spr/compare/master...sunshowers:spr:master

sunshowers avatar Feb 09 '24 01:02 sunshowers