Repository: commitizen-tools/commitizen
Issue: File stage checker not working as expected

## Description
<!-- A clear and concise description of what the bug is. -->

If we have changed files not staged, and not staged files, then I don't get the "No files added to staging!".

## Steps to reproduce
<!-- Steps to reproduce the behavior:
1. Run ...
2. ...
3. ... -->

Assuming you have a project with commitizen installed and the project is tracked by git, then we can do:
1. Edit an existing file
2. Run `cz commit`

## Current behavior

The questionnaire will pop up **without** erroring out with `No files added to staging!` since no files are yet added to stage.

## Desired behavior
<!--
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
-->

The desired behaviour should be what the error says ("No files added to staging!"), so if no files are added to the stage, then the error should pop.

## Environment
<!--
cz version
python --version
python3 -c "import platform; print(platform.system())"
-->

- commitizen version: 2.17.11
- python version: Python 3.7.9
- operating system: Linux

This is an application bug, so it happens with any Python version and OS.

## Extra

This issue is related to #45 (fixed in #49), which was the original issue related to this problem, but in my opinion, was never fixed the right way. I am not randomly opening this issue, I am doing it because I bumped into this frustrating problem all the time where:

- I run `cz commit`
- Fill the questionnaire (~1 minute)
- Pre-commit runs (~1 minute)
- Get an error because the stage is empty
- Then, I have to stage the files, and run `cz commit --retry`

It seems that this was deliberately done in the [code](https://github.com/commitizen-tools/commitizen/blob/ec38ce3dcf19b4c0f704079e8ca8b0f1e3555b8e/commitizen/git.py#L159) since just this command is needed:

```
git diff --no-ext-diff --cached --name-only
```

The no-cached one will pick up files that are unstaged. In fact, in the more recent versions of  `git` one can use `--staged` flag which is an alias for `--cached`.

I understand if this was picked up from [here](https://github.com/commitizen/cz-cli/blob/62fc778a6207ec73a999e10fe7d1452a5f5dc05a/src/commitizen/staging.js#L9-L9) in [cz-cli](https://github.com/commitizen/cz-cli), but it has the same problem in there, and [this PR](https://github.com/commitizen/cz-cli/pull/818) is a proposal for the fix in that repo (not yet merged).

If this is a recognized bug, and we are willing to fix it, I offer myself to open the PR if needed.

Thank you for the great work and this amazing tool!

Regards,
Xavi M.


Changed files:
commitizen/git.py, tests/test_git.py

diff --git a/commitizen/git.py b/commitizen/git.py
index 2904d6cb..b196f151 100644
--- a/commitizen/git.py
+++ b/commitizen/git.py
@@ -154,10 +154,9 @@ def find_git_project_root() -> Optional[Path]:
 
 
 def is_staging_clean() -> bool:
-    """Check if staing is clean."""
-    c = cmd.run("git diff --no-ext-diff --name-only")
-    c_cached = cmd.run("git diff --no-ext-diff --cached --name-only")
-    return not (bool(c.out) or bool(c_cached.out))
+    """Check if staging is clean."""
+    c = cmd.run("git diff --no-ext-diff --cached --name-only")
+    return not bool(c.out)
 
 
 def is_git_project() -> bool:
diff --git a/tests/test_git.py b/tests/test_git.py
index dc8023b9..c764a6d6 100644
--- a/tests/test_git.py
+++ b/tests/test_git.py
@@ -70,7 +70,7 @@ def test_get_commits_author_and_email():
     create_file_and_commit("fix: username exception")
     commit = git.get_commits()[0]
 
-    assert commit.author is not ""
+    assert commit.author != ""
     assert "@" in commit.author_email
 
 
@@ -176,12 +176,30 @@ def test_get_latest_tag_name(tmp_commitizen_project):
         assert tag_name == "1.0"
 
 
-def test_is_staging_clean(tmp_commitizen_project):
+def test_is_staging_clean_when_adding_file(tmp_commitizen_project):
+    with tmp_commitizen_project.as_cwd():
+        assert git.is_staging_clean() is True
+
+        cmd.run("touch test_file")
+
+        assert git.is_staging_clean() is True
+
+        cmd.run("git add test_file")
+
+        assert git.is_staging_clean() is False
+
+
+def test_is_staging_clean_when_updating_file(tmp_commitizen_project):
     with tmp_commitizen_project.as_cwd():
         assert git.is_staging_clean() is True
 
         cmd.run("touch test_file")
         cmd.run("git add test_file")
+        cmd.run("git commit -m 'add test_file'")
         cmd.run("echo 'test' > test_file")
 
+        assert git.is_staging_clean() is True
+
+        cmd.run("git add test_file")
+
         assert git.is_staging_clean() is False