FR: Make `jj file untrack` work with files that are not ignored
Is your feature request related to a problem? Please describe.
Currently, if you do jj file untrack on a file that is not being ignored, the command is effectively a "no op" since the files are immediately, automatically and silently tracked again. This is extremely surprising and also makes keeping files outside of the repo (but in the working directory) harder than it could be.
Describe the solution you'd like
When the using jj file untrack on a file is not already gitignored, jujutsu should store the fact that the user explicitly requested to untrack that file, and not track it automatically until the user used jj file track to track it again.
How to store that information is debatable. I think it should not be added to the "public" .gitignore, to avoid sharing with others the existence of that untracked file. It could perhaps be stored in .git/info/exclude (which IMHO would be a much better solution than storing it in the public gitignore). But given that .git does not automatically track any files, maybe it would make more sense to store this info in an "jujutsu specific", local ignore file (e.g. .jj/info/exclude)?
Describe alternatives you've considered
I think this behavior should be automatic, but an alternative would be to require the user triggering this behavior by adding a flag to jj file untrack (e.g. jj file untrack --save). I think this might only make sense if jj updated the git exclude file (but not if it created it's one jj specific file to store the list of untracked files). Also, this would still result in jj file untrack (without the flag) having surprising "no op" behavior.
Additional context This is related to #323.
One alternative could be to save a negative pattern to the sparse checkout rather than modify any ignore files.
- I didn't seriously think through the implications.
- Currently, sparse checkouts can only have positive patterns, but the v2 design document discusses negative patterns.
Maybe dup of https://github.com/jj-vcs/jj/issues/3493 ?
iirc, there were other related discussion about newly-unignored files on jj new <REV> somewhere. If it's addressed in a way that working copy remembers cumulative list of temporary untracked files and directories (as we do for Git submodules right now), jj file untrack could update the list.
Maybe dup of https://github.com/jj-vcs/jj/issues/3493 ?
It's very similar. The only difference is that I think it'd be best to not use a git ignore file, since the list of files that have been "jj untracked" is jujutsu specific so I don't think it should change the git config (since git does not auto-track any files). Maybe both could be combined? e.g. jj file untrack could keep track of the untracked files in jujutsu, but if you also add --ignore (as #3493 suggests) it could then also add the files to the closes git ignore file? Not sure if that'd be useful though...
the list of files that have been "jj untracked" is jujutsu specific
That probably depends on user's workflow. I would add it to .gitignore or global ignore if the file isn't supposed to be version controlled.
Maybe both could be combined?
+1
Another use case for this is ignoring local changes to a tracked file, which would be helpful to have this not be tied to .gitignore. I know it is generally a code smell, but several legacy projects I've worked on have had environment files that had to be edited to work locally and we didn't have the time to refactor.
Another use case would be ignoring local environment/configuration files that differ from the specification of the repository.
For example, I like to use the uv environment manager for python projects, but many public python repositories do not use it, and if I want to make a pull request for an unrelated feature it does not make sense to update their .gitignore to exclude configuration files like uv.lock which only I use and that were not included in their tested and recommended way of installing the program.
For example, I like to use the
uvenvironment manager for python projects, but many public python repositories do not use it, and if I want to make a pull request for an unrelated feature it does not make sense to update their.gitignoreto exclude configuration files likeuv.lockwhich only I use and that were not included in their tested and recommended way of installing the program.
you also can use a private commit for this workflow, see this FAQ answer https://jj-vcs.github.io/jj/latest/FAQ/#how-can-i-avoid-committing-my-local-only-changes-to-tracked-files
For example, I like to use the uv environment manager for python projects, but many public python repositories do not use it, and if I want to make a pull request for an unrelated feature it does not make sense to update their .gitignore to exclude configuration files like uv.lock which only I use and that were not included in their tested and recommended way of installing the program.
For now try this:
jj config set --repo snapshot.auto-track "~uv.lock"
If its already tracked you'll also need to untrack it:
jj file untrack uv.lock
@PhilipMetzger @tekumara Thank you, both these solution works!