aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msubprojects.py
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2023-03-04 21:28:46 +0100
committerXavier Claessens <xclaesse@gmail.com>2023-03-04 20:35:30 -0500
commit8da060706c2c34fbea91898509123cb190894f3e (patch)
treeca722f2dacdd7e041791ef7d568866c4bf6403df /mesonbuild/msubprojects.py
parent93c11f249495c4af4a88206cebefef3ecf0f3228 (diff)
downloadmeson-8da060706c2c34fbea91898509123cb190894f3e.zip
meson-8da060706c2c34fbea91898509123cb190894f3e.tar.gz
meson-8da060706c2c34fbea91898509123cb190894f3e.tar.bz2
msubprojects: fix potential error when resetting a git checkout
Untracked files need to be stashed too, or resetting may fail when trying to (re-)apply a patch that adds one of those untracked files.
Diffstat (limited to 'mesonbuild/msubprojects.py')
-rwxr-xr-xmesonbuild/msubprojects.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py
index 1be8543..091f1eb 100755
--- a/mesonbuild/msubprojects.py
+++ b/mesonbuild/msubprojects.py
@@ -207,13 +207,16 @@ class Runner:
self.log(self.git_output(cmd))
def git_stash(self) -> None:
- # That git command return 1 (failure) when there is something to stash.
+ # That git command return some output when there is something to stash.
# We don't want to stash when there is nothing to stash because that would
# print spurious "No local changes to save".
- if not quiet_git(['diff', '--quiet', 'HEAD'], self.repo_dir)[0]:
+ if quiet_git(['status', '--porcelain', ':!/.meson-subproject-wrap-hash.txt'], self.repo_dir)[1].strip():
# Don't pipe stdout here because we want the user to see their changes have
# been saved.
- self.git_verbose(['stash'])
+ # Note: `--all` is used, and not `--include-untracked`, to prevent
+ # a potential error if `.meson-subproject-wrap-hash.txt` matches a
+ # gitignore pattern.
+ self.git_verbose(['stash', 'push', '--all', ':!/.meson-subproject-wrap-hash.txt'])
def git_show(self) -> None:
commit_message = self.git_output(['show', '--quiet', '--pretty=format:%h%n%d%n%s%n[%an]'])