Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jj absorb is not squashing my file-level changes as expected #5710

Open
zx8 opened this issue Feb 14, 2025 · 3 comments
Open

jj absorb is not squashing my file-level changes as expected #5710

zx8 opened this issue Feb 14, 2025 · 3 comments

Comments

@zx8
Copy link

zx8 commented Feb 14, 2025

Answered by @martinvonz @ #5710 (comment).

I hadn't realised that jj absorb looks for changes at line-level, rather than file-level.

Keeping this open to see if there is appetite for a flag along the lines of --granularity=file, with --granularity=line being the default behaviour. Or perhaps jj absorb could simply fall back to absorbing into the same file if there are no line-level matches?

I appreciate I can do this manually with jj squash, but jj absorb is a lot more convenient!


Original Post

Apologies if PEBCAK and not a bug, but I assumed this would work based on the description of jj absorb...

I can't share the exact commits and repository as they're private, but I'll describe the state of things.

I'm working on a feature, based off my colleague's branch, as follows:

@  psswxrxt [email protected] 2025-02-14 19:23:23 4fbbb337
│  (no description set)
○  wootuxwm [email protected] 2025-02-14 19:04:11 example/my-branch git_head() 7592656d
│  add brand new code in new directory
○  vzrmlxxs [email protected] 2025-02-14 19:04:11 7f69a590
│  update colleague's changes in directory `foo/`
○  nlznywlw [email protected] 2025-02-11 17:37:02 example/colleague-branch 753008a0
│  add some more changes in directory `foo/`
○  qyrunlwq [email protected] 2025-02-11 17:35:27 38bc805d
│  add some changes
◆  ztxrpqqt [email protected] 2025-02-10 19:39:01 main df397142
│  init
~

I've made some changes in @ that modify files in foo/ (most recent change modifying these files was in vzrmlxxs). Now, both my colleague and myself have made changes in these files.

If I run jj absorb with no arguments, the output is:

Absorbed changes into these revisions:
  qyrunlwq 3c3cf48f add some changes
Rebased 3 descendant commits.
Working copy now at: onsmswty 2740eb3e (empty) (no description set)
Parent commit      : wootuxwm 7592656d example/my-branch* | add brand new code in new directory

This is what I would expect.

However, I don't want to modify my colleague's changes. Instead, I want to absorb into my own previous changes, so I run jj absorb --into='mutable() & mine()', and the output is:

Nothing changed.

Why is jj not absorbing the changes into my previous change (vzrmlxxs) when I limit the revisions in this way, but is happy to modify my colleague's changes?

@martinvonz
Copy link
Member

jj absorb will absorb into the closest commit that modified the same line. Maybe your commit didn't modify the same line? What does jj file annotate say about it?

@zx8
Copy link
Author

zx8 commented Feb 14, 2025

Aha, that's the part I missed - modifying the same line! I didn't realise it was that fine-grained. I modified elsewhere in the file.

It would be neat if there was a flag/config option (e.g. --granularity=line|file) to operate at the file level, rather than the line level, even if the default is line.

Is this a feature you might consider adding? If so, would you like me to raise a new issue for it, or shall we track it here?

@zx8 zx8 changed the title jj absorb is not squashing my changes as expected jj absorb is not squashing my file-level changes as expected Feb 14, 2025
@zx8
Copy link
Author

zx8 commented Feb 19, 2025

@yuja As the original author of jj absorb, what are your thoughts here? I'm currently working around this by either jj squash'ing manually, or adding arbitrary whitespace changes around lines I plan to modify, which isn't ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants