Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@whereistejas
Copy link

@whereistejas whereistejas commented Oct 10, 2025

Closes #6556.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@whereistejas whereistejas requested a review from a team as a code owner October 10, 2025 14:07
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following commits do not follow our format for subject lines:

  • a98a670: Use print_unmatched_explicit_paths in cmd_status.
  • 14e7bbd: Update CHANGELOG

Commits should have a subject line following the format <topic>: <description>. Please review the commit guidelines for more information.

@whereistejas whereistejas changed the title jj status should throw an error when the fileset does not exist jj status should throw a warning when the fileset does not exist Oct 10, 2025
@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch from 14e7bbd to 84fb867 Compare October 10, 2025 14:11
@github-actions github-actions bot dismissed their stale review October 10, 2025 14:11

All commits are now correctly formatted. Thank you for your contribution!

@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch from 84fb867 to bea6920 Compare October 10, 2025 14:15
@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch 3 times, most recently from fb17003 to d6a7b86 Compare October 13, 2025 16:30
@whereistejas whereistejas changed the title jj status should throw a warning when the fileset does not exist jj commands should throw a warning when the fileset does not exist Oct 13, 2025
@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch 3 times, most recently from 0eeeaac to 0c2a608 Compare October 13, 2025 17:30
@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch 3 times, most recently from 5e3fd26 to 55ab0d8 Compare October 21, 2025 15:46
@glehmann
Copy link
Contributor

IMO, you should merge the revision that changes the command and the revision that adds the test for each command. It would be easier to review.
And it's a bit strange, given how the revisions are organized, that the number of revisions in the PR is odd :)

@whereistejas
Copy link
Author

whereistejas commented Oct 22, 2025

IMO, you should merge the revision that changes the command and the revision that adds the test for each command. It would be easier to review.

I want to make sure that the warning is shown in a consistent manner across all commands. That's why the commands and tests are one after another. I would be happy to split the PR in whatever way is more convenient for the reviewer when ready :)

And it's a bit strange, given how the revisions are organized, that the number of revisions in the PR is odd :)

I didn't have to add tests for all the commands. Some of them already had tests capturing this behaviour, for example, split.

@martinvonz
Copy link
Member

nit: Could you squash the tests into the commit they're testing? See https://jj-vcs.github.io/jj/latest/contributing/#commit-guidelines

@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch 4 times, most recently from ccb9689 to 0d8298b Compare October 29, 2025 16:10
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines 2832 to 2835
// If there are no explicit paths to show then return early.
if explicit_paths.is_empty() {
return Ok(());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of this check? That should ideally be mentioned in the commit description (if it's not obvious, and it's not obvious to me at least).

Is this just an optimization? But if explicit_paths is empty, then explicit_paths.retain() will be very cheap anyway. So I don't think it's a worthwhile optimization.

Or is it about correctness when explicit_paths is empty and trees is also empty? It makes sense to not print the warning in such cases. Are you going to add callers that may pass an empty list of trees in a later commit? Could you update the commit description to explain that that's the reason if it is?

Actually, if the second thing is what it's about, I would suggest just moving the early return out of the loop. As mentioned above, I don't think it's useful as an optimization anyway. If we move it after the loop, then it will handle the case of an empty list of trees. If you do that, I would suggest actually not making it an early return but instead make the output conditional on the list being non-empty.

Copy link
Author

@whereistejas whereistejas Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the latter. Some scenarios when a fileset_expression may evaluate to valid explicit paths but we may not have any trees to compare them against are:

  • Squashing a commit into itself.
  • Running jj log -r "none()"

I will add an explanation to the commit message.

@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch 5 times, most recently from ddc8109 to 484bd5f Compare October 31, 2025 17:02
let commit = store.get_commit(&key.0)?;
let tree = commit.tree()?;
// TODO: propagate errors
explicit_paths.retain(|&path| tree.path_value(path).unwrap().is_absent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should also remove paths that are in the parent tree. Otherwise jj log <deleted file> -r <revision where file was deleted> will print the warning. However, it's expensive to calculate the parent tree for merge commits. Perhaps we can remove paths that are in any parent tree instead. That's slightly incorrect because if a file was removed on one of the parent branches of a merge commit then we won't print the warning for the merge commit even though the file wasn't changed or present in the commit. That's probably fine because the point of the warning is to detect typos and such, and if the file did exist at some point, then it's probably not a typo.

It might be good to have tests for these two cases too. To clarify, here's the second case:

$ jj log
D (empty)
|\
C| (empty)
| |
| B delete foo
|/
A add file foo
$ jj log -r D foo
# Since foo isn't present or modified in D, we should ideally print a warning but I don't think we can because it's slow

Btw, jj log is also an exception because the user can do either jj log <fileset> or jj log -r 'files(<fileset>)' (or something more complex). We will only show the warning if the fileset was passed as a positional argument, not if it was part of the revset. Not asking for any changes here, just noting this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my suggestion is to leave it as is for now. It should be pretty rare to run into it, and the alternatives have their drawbacks too.

@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch from 484bd5f to de355eb Compare November 3, 2025 10:20
@whereistejas whereistejas force-pushed the warn-when-fileset-is-missing branch from de355eb to 30fe9ed Compare November 3, 2025 10:29
visit_collapsed_untracked_files(
snapshot_stats.untracked_paths.keys(),
tree,
tree.clone(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is this change necessary? OTOH, perhaps it's better to move print_unmatched_explicit_paths() later? it seems easier to spot the unmatched paths if we print the after the list of matched paths. (Also see my comment about caching on the jj log commit because I think that's also relevant here.)

Comment on lines +247 to +249
let tree = commit.tree()?;
// TODO: propagate errors
explicit_paths.retain(|&path| tree.path_value(path).unwrap().is_absent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could you move these lines after graph.add_node() block? That should be better for caching because diff_renderer is able to read many trees concurrently (if the backend is slow like at Google) but explicit_paths.retain() doesn't process the paths concurrently. So by moving the serial part after the concurrent part, we can take advantage of the trees read by the concurrent code being in the cache so it's fast to read them serially.

let commit = store.get_commit(&key.0)?;
let tree = commit.tree()?;
// TODO: propagate errors
explicit_paths.retain(|&path| tree.path_value(path).unwrap().is_absent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my suggestion is to leave it as is for now. It should be pretty rare to run into it, and the alternatives have their drawbacks too.

Comment on lines +143 to +145
let _ = work_dir.run_jj(["edit", "right"]);
work_dir.remove_file("file1");
let _ = work_dir.run_jj(["new"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: replace let _ = by .success()

Comment on lines +92 to +98
print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
[&source_commit.tree()?],
)?;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe better to print the message after later, around line 131?

.block_on()
});

print_unmatched_explicit_paths(ui, tx.base_workspace_helper(), &fileset_expression, &trees)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe better to print this a bit later, after any warning from formatters etc., so between lines 190 and 191?

Comment on lines +82 to +93
print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
// We check the parent commits to account for deleted files.
[
&from.parent_tree(repo.as_ref())?,
&from.tree()?,
&to.parent_tree(repo.as_ref())?,
&to.tree()?,
],
)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe better to print this after the diffs?

@martinvonz
Copy link
Member

Thanks again for working on this. We have a release scheduled for Wednesday. I think it's better to get this merged after the release so we get a chance to test it a bit before it's released. I'm not particularly worried about bugs, but I would like to see that there is no significant performance impact (including at Google) and that we feel that we print the warnings at the right time relative to other output so we don't release it on Wednesday and then change the behavior in some way in the very next release.

@whereistejas
Copy link
Author

whereistejas commented Nov 4, 2025

... I would like to see that there is no significant performance impact (including at Google)...

Sounds reasonable.

that we feel that we print the warnings at the right time relative to other output so we don't release it on Wednesday and then change the behavior in some way in the very next release.

I've ensured the warning about unmatched paths is always displayed first, before any other warning. I've kept this ordering consistent across all the commands. Does this address your concern about the warning placement?

@martinvonz
Copy link
Member

I've ensured the warning about unmatched paths is always displayed first, before any other warning. I've kept this ordering consistent across all the commands. Does this address your concern about the warning placement?

My guess was actually that it's better to display it quite late (see some of the comments I left). I'm not sure which is better, but the fact that we have different intuition for it seems suggest that we should test it on ourselves before releasing it to users :)

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

Successfully merging this pull request may close these issues.

FR: jj status should throw an error when the fileset does not exist

3 participants