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: template method for number of added files in commit #5272

Open
scott2000 opened this issue Jan 6, 2025 · 1 comment
Open

FR: template method for number of added files in commit #5272

scott2000 opened this issue Jan 6, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@scott2000
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I think this feature could alleviate some of the issues discussed in #323. The problem is that sometimes you might not notice that a commit starts tracking a new file that wasn't present in the parent, and you might accidentally push it to the remote. This is also related to #4154, but I think it's a different feature (since these file counts are different from the --shortstat counts).

Describe the solution you'd like
If there were a template method or chain of methods (e.g. commit.diff().added_files().len()) that returned the number of new files in the commit, then it would be possible to use the template to display commits which add files differently in the log. For instance, a +N could be added to the log for commits which add new files, and then a user could review the added files to make sure there's nothing that they added accidentally (since for many repos, it's relatively rare to add a new file):

@  ppnpzvyl scott.g.taylor 10 seconds ago a364b1b2 +1
│  (no description set)
◆  skmnsovu Christian.Stoitner 6 hours ago main bcfa2b17
│  added changelog entry for showing untracked files in `jj status`
~

For consistency, we could add the following methods to TreeDiff:

  • added_files() -> List<String>
  • modified_files() -> List<String>
  • deleted_files() -> List<String>
  • renamed_files() -> List<String>
  • copied_files() -> List<String>

Describe alternatives you've considered
Instead of being a template method, it could just be a revset for commits which add any new files. Then it would be necessary to use the contained_in(revset) commit template method to show it in a template. I think this isn't ideal, because it wouldn't be possible to show the count of files in the template, and showing the count could be useful (for instance, if a commit adds 500 files, it's often going to be a mistake).

We could add a fileset for added files, and then use commit.diff("added()").files().len() instead. I think this is a bit more complicated though, since it's unclear in what contexts added() would be a valid fileset, and currently all filesets are valid in all contexts I believe.

We could also decide that this isn't necessary, and that the user should use jj status or jj log --summary to check for added files.

@scott2000 scott2000 added the enhancement New feature or request label Jan 6, 2025
@yuja
Copy link
Contributor

yuja commented Jan 6, 2025

Maybe dup of #4154?

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

2 participants