Ignore unstaged/uncommitted submodule changes

When checking for unstaged or uncommitted changes to avoid the test
rebase (which could cause data loss for users of git.autostash),
it's still fine if there are unstaged or uncommitted changes in
submodules since those won't be rebased. Have the git diff
invocations explicitly ignore submodules, and also add regression
tests which demonstrate it's working.

This fixes a regression originally introduced by change
Iabb8387c9db59a7d02ebfd43b688e7bb93d3159f.

Change-Id: I20d602e86537b573ac1f9788221215047a594f83
This commit is contained in:
Jeremy Stanley
2021-07-07 15:54:29 +00:00
parent 04786cd9ea
commit 6c3f134ac3
4 changed files with 56 additions and 2 deletions

View File

@@ -888,13 +888,13 @@ def rebase_changes(branch, remote, interactive=True):
# Either the rebase will fail with a similar message, or if the user
# has turned on rebase.autostash then the subsequent reset will
# silently discard those changes.
cmd = "git diff --quiet"
cmd = "git diff --ignore-submodules --quiet"
(status, output) = run_command_status(cmd)
if status != 0:
printwrap("You have unstaged changes. Please commit or stash them "
"first, and then try again.")
sys.exit(1)
cmd = "git diff --cached --quiet"
cmd = "git diff --cached --ignore-submodules --quiet"
(status, output) = run_command_status(cmd)
if status != 0:
printwrap("You have uncommitted changes. Please commit or stash them "