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

FR: Support git status-based working copy snapshotting #2920

Open
arxanas opened this issue Feb 3, 2024 · 4 comments
Open

FR: Support git status-based working copy snapshotting #2920

arxanas opened this issue Feb 3, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@arxanas
Copy link
Collaborator

arxanas commented Feb 3, 2024

Currently, jj status crawls the filesystem itself or uses an fsmonitor (currently only Watchman). We could add another fsmonitor that calls git status to get status information. Advantages:

@ilyagr
Copy link
Collaborator

ilyagr commented Feb 3, 2024

Do you just mean running git -C git_repo_path status in a non-colocated repo? In other words, would this be any different from running git status in a colocated repo?

It's not yet implemented, but I think it'd be nice if something like git -C $(jj root --git) status worked.

@arxanas
Copy link
Collaborator Author

arxanas commented Feb 3, 2024

In other words, would this be any different from running git status in a colocated repo?

If jj status (and working tree snapshotting in general) itself calls git status, then we get e.g. Git LFS support for free, and jj status won't report logically-unchanged files as dirty.

@arxanas arxanas changed the title FR: Support git status-based jj status FR: Support git status-based working copy snapshotting Feb 3, 2024
@arxanas
Copy link
Collaborator Author

arxanas commented Feb 3, 2024

would this be any different from running git status in a colocated repo?

Well, I guess it depends on what you mean by "running git status".

  • git status doesn't really have side effects, so I assumed you meant "would the output of jj status be logically different from the output of git status", for which the answer would be "it was before, and after this, it wouldn't be (in many cases)".
  • But you might have meant something about the implementation of jj status calling into ("running") git status and whether it would be substantially complicated beyond just running git status. You have to pass --porcelain=v2 or something, but it should be straightforward.
    • The main problem would be handling tree entries that have hashes for objects that jj hasn't seen and that it can't procure itself, such as new Git LFS files. We'd have to warn or error on that case and require that the user resolve the issue using Git.

@ilyagr
Copy link
Collaborator

ilyagr commented Feb 3, 2024

I think I see what you mean now. I read the part of your original post about the fsmonitor, but then forgot about it.

What do you mean by "Would handle submodules (if unchanged)."? I'm guessing you want to have a line in jj status that mentions that a submodule was changed and tells the user to use Git to work with it? That would be nice :).

Some disorganized first thoughts:

libgit2 has some support for this: https://libgit2.org/libgit2/#v0.20.0/group/status. I'm not sure whether it can handle LFS or submodules, and it wouldn't help with custom fsmonitors.

I think we'd still want to do a snapshot on jj status, but we could do it after running git status. The snapshot would go into the descendant of HEAD, so git status would still report the same diffs after it happens. Or perhaps we can call this jj status --no-snapshot.

One situation where this wouldn't work at all (I think) is if the repo has conflicted files. I suppose we could fall back to normal jj behavior in that case.

The problem of be handling tree entries that have hashes for objects that jj hasn't seen will have to be handled eventually, it'd be needed for any kind of large file support.

Currently, jj status shows the output of jj diff -s. Would we also change how diff works?

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

No branches or pull requests

3 participants