Skip to content

If No Staged Files, Changed Files are Added to Commit #15613

Closed

Description

@atolken
  • VSCode Version: 1.71
  • OS Version: Windows 10 Enterprise

Steps to Reproduce:

  1. make changes / have changed files
  2. do not stage any files
  3. write commit message
  4. submit commit

problem: all files that were changed (even though none were staged) are added to the commit.
expected: if no files are staged, the commit will not add any files (similar to other git tools).

Activity

  1. siegebell commented on Nov 17, 2016

    @siegebell

    This behavior is likely intentional, but after many revert-last-commit operations, I've come to really hate it.

  2. joaomoreno commented on Nov 17, 2016

    @joaomoreno
    Contributor

    This is intended.

    • when there are no changes, nothing happens
    • when there are no staged changes, all working tree changes are committed
    • when there are staged changes, only those are committed

    Would you like a setting to disable that?

  3. added
    bug
    on Nov 17, 2016
  4. atolken commented on Nov 17, 2016

    @atolken
    Author

    I would definitely like a setting to disable that, please.

  5. maxfie1d commented on Nov 25, 2016

    @maxfie1d

    In the case of Visual Studio, when there are no staged changes, but some changes, the content of the commit button comes "Commit All". So, user can know all changes will be committed even no changes staged.

    vscode doesn't have button to commit (use ctrl+Enter instead), and it is difficult to know what happens when commit done.

    I would like to add a setting to disable the behavior when no changes staged, or add some ingenuity to let user know what will happen.

    image

    image

  6. mikeseese commented on Mar 31, 2017

    @mikeseese
    Contributor

    Despite the fact that this is easily revertible after an accidental mass commit, the git CLI does not allow you to commit without staged files.

    If it's not a setting that disables this functionality, then if there are no staged files, prompt the user that you cannot commit without staged changes and ask if the user would like to stage and commit all changes (with the default option to be No).

    Forcing the user to look at the files and intentionally stage them is good practice.

  7. mozram commented on Apr 20, 2017

    @mozram

    Any progress on this issue? As CJ Bell (@siegebell) said before, I had to revert commit many times already as I either accidentally pressed CTRL+S or forgot to stage file. I'm hating it now.

    Mike Seese (@seesemichaelj) suggestion is very good actually.

  8. added
    good first issue
    help wanted
    on Apr 25, 2017
  9. joaomoreno commented on Apr 25, 2017

    @joaomoreno
    Contributor

    If it's not a setting that disables this functionality, then if there are no staged files, prompt the user that you cannot commit without staged changes and ask if the user would like to stage and commit all changes (with the default option to be No).

    I like the way you're thinking. Let's create a git.enableSmartCommit setting, defaults to false.

    We can then present the following message, in these cases: There are no staged changes to commit. Would you like to stage all changes and commit them?. The options are:

    • Yes
    • Always
    • Cancel

    Always would change that setting to true.

    Anyone cares to submit a PR?

  10. mikeseese commented on Apr 26, 2017

    @mikeseese
    Contributor

    I'll give this a shot

    Edit: I believe the below pull request (#25364) is how this is supposed to be implemented.

  11. ashirley commented on May 3, 2017

    @ashirley

    I have been looking at this and related issues (before I saw you were too Mike Seese (@seesemichaelj) , sorry!) and have attempted a solution from a slightly different direction and I have raised PR #25855. I think there is value in trying to merge our two solutions which I will have a look at tomorrow if I can.

  12. joaomoreno commented on May 4, 2017

    @joaomoreno
    Contributor

    Sorry Andrew Shirley (@ashirley), I've closed your PR. I really liked Mike Seese (@seesemichaelj)'s fix, it's simpler to understand and maintain.

  13. joaomoreno commented on May 4, 2017

    @joaomoreno
    Contributor

    Fixed by #25364

  14. ashirley commented on May 5, 2017

    @ashirley

    No worries. I am a bit concerned that when you press "Always", it changes a file in the directory and then immediately commits it. I wouldn't be expecting this as a user and would want a chance to add the (potentially new) file to .gitignore. Even if I did want to commit this config change, I would want it in a separate commit.

  15. mikeseese commented on May 7, 2017

    @mikeseese
    Contributor

    Andrew Shirley (@ashirley) I agree and verified what you said. I have opened Issue #26169 to address this

    EDIT: #26169 was closed because it is no longer an issue (I verified your issue using an outdated rebase of master). João Moreno (@joaomoreno) changed the function to use global settings instead of workspace settings in commit b31c1e1. Therefore, the project's settings.json file will not be created/edited upon clicking Always.

  16. joaomoreno commented on May 8, 2017

    @joaomoreno
    Contributor

    Good detective work Mike Seese (@seesemichaelj) 😉

  17. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggitgood first issuehelp wantedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions