-
Notifications
You must be signed in to change notification settings - Fork 871
Display newly tracked files #8317
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
base: main
Are you sure you want to change the base?
Conversation
| let (file_states_tx, file_states_rx) = channel(); | ||
| let (untracked_paths_tx, untracked_paths_rx) = channel(); | ||
| let (deleted_files_tx, deleted_files_rx) = channel(); | ||
| let (new_tracked_tx, new_tracked_rx) = channel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "new tracked" paths should be included in file_states_tx/rx, I don't think we need separate channel. Perhaps, the list of newly tracked paths can be returned from FileStatesMap::merge_in().
EDIT: we can also diff tree objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am reworking to include a boolean in the file_states_tx/rx channel indicating when a path is newly tracked.
I don't see the advantage regarding merge_in() or including the boolean in FileState at the moment. Feels a bit overkill to overload FileState for an information which, (as i see it from now) is interesting only for snapshot stats.
I haven't looked yet on how diff tree objects would make it simpler / more effective. I'll enhance my comprehension of the code and try things out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code would be more maintainable if we have fewer data sources. Comparing tree objects might be slower than using file states, but the results would be more trusted.
|
|
||
| write!(formatter, "{tracking_str}")?; | ||
|
|
||
| if to_print.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better to print paths in a similar way to jj status output than attempting to print them in one line. If there are many paths to list, it might be good to omit some of them, though.
Newly tracked paths:
bar
foo
...
I think it's also good to collapse paths having the same directory prefix. See visit_collapsed_untracked_files() in status.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's also good to collapse paths having the same directory prefix. See
visit_collapsed_untracked_files()in status.rs
👍
I'll make so the changes on the lib/ side are first correct. Then go back to the printing part. Maybe we will have some more feedback from other users until then.
One other solution would be to have the print style configurable:
all: Print all files:
Newly tracked paths:
foo
bar
foo/foo
bar/bar
...
unsigned int: Print at maximum the number of files configured, for instance2. With the paths collapsed.
Newly tracked paths:
foo
bar
and 1234 other files...
one_line: Currently implemented output, with path collapsed.
Tracking foo, bar and 1234 other files
none: Do not print anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we'll need configuration. If tracking new files is common enough to silence this output, we shouldn't add this feature at all.
BTW, some people enable background snapshots or run GUI/shell prompt. They won't see the status message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok no configuration then.
About watchman / tui /gui, I know they won't see the warning, I am initially aiming at the CLI users. I think we should make so the TUI and GUI can do something with that warning. For watchman, I'll eventually start using it and potentially come with another PR.
So after some thoughts, the requirements for the text displayed would be:
- Easily parsable, so there is an open door for TUI and GUI to parse it
- therefore unique output
- avoid being too verbose. Do something similar to the
visit_collapsed_untracked_files; - limit the number of lines printed (like 10 lines max), so we do not spam. For any tool that would want to parse the output, there could be a
porcelainlike option to print all the files, although I don't plan on doing that in this PR.
Do you agree?
Example:
Tracking 1234 new files:
foo
bar/ (1230 files)
...and 3 other files
b4c3bf5 to
0f8e01d
Compare
|
Converted to draft until a new version is ready to be reviewed. |
Which files the snapshot started auto-tracking is an interesting information to forward to the user. The idea being that doing things automatically is nice, but do not do them secretly.
Tracking file automatically is a neat thing, until you did not want to track the file that just got auto-tracked. This could happen on many jj commands, so you could, easily end-up having unwanted files in your commits, without realizing you have them. We are now printing a message to indicate when jj starts auto-tracking files. With the intent to have a quick response from the user when one of the newly tracked files is not one they want to have tracked. The message to not take more one single line of your terminal, to not spam. It will list the path of as much newly tracked files as possible, and giving the actual number of files it could not print. Hopefully it should trigger the user into running another command (such as `jj status`) to check what is the state of the commit. And take appropriate action to ignore and untrack the unwanted files.
0f8e01d to
595078e
Compare
Tracking file automatically is a neat thing, until you did not want to track a file and it is not ignored yet. This could happen while executing most of the
jjcommand. You can then, easily end-up having unwanted files in your commits, without realizing you have them. I have been working on repositories which does not define the files to ignore properly, or while working on a new feature, I usually think after it has been already tracked to edit the.gitignoreor<git-dir>/info/excludefile.This issue is experienced by many, (see issue #8168, #323 for instance). I think it is best that - at least in the default configuration - we do not do automatic things silently.
We already have a message when auto-rebase is happening, I think it is suited to have one for auto-tracking.
The idea is that the message triggers a potential quick response from the user when one of the newly tracked files is not one they want to be tracked. Helps raise awareness / eyebrows, so newbies get a feedback on what is happening, then get a bit deeper in the feature, what can be the issues and how to work with it properly.
Prior to submitting this PR, I have experienced with different style of display:
jj statuswould do. It felt wrong and very much spam.jj file untrackdoes when attempting to untrack non-ignored files. This was ok, but it was too bad to not display all the files when there was only 2 or 3 that could fit on one line.So the message displays as much files as it can while keeping the message on a single line, based on the terminal width. If there is more, then we say how many more there is.
For instance:

I have another commit, ready to go, which adds a configuration key to disable the message. It felt really necessary when the message was printing all the files, but not so much anymore.
I did not experienced with the
watchmanfeature I do not know if that could have any impact yet.Tests have been updated, I wanted to be sure of any impact this could have. Current tests seems to already cover all the different cases, I still added some dedicated to this feature.
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)