[git-freeze] Fix error in git-add invocation when not in repo root.
The previous change to git-freeze added an accidental regression
where running `git freeze` from somewhere other than the repo root
would return a mysterious error:
"Failed to index some unindexed files. Nothing to freeze."
This is because `git add` always treats pathspecs as relative to the
current working directory. Fix this by changing `git add` to always
run from the repo root.
R=ajp@google.com
Change-Id: I451f26fe35a5c6e9f3b917a1d90bdadc7065244c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4703128
Commit-Queue: Andy Perelson <ajp@google.com>
Reviewed-by: Andy Perelson <ajp@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
diff --git a/git_common.py b/git_common.py
index 8309225..925f2cd 100644
--- a/git_common.py
+++ b/git_common.py
@@ -496,7 +496,8 @@
'--pathspec-from-file',
'-',
'--ignore-errors',
- indata=b'\n'.join(unindexed))
+ indata=b'\n'.join(unindexed),
+ cwd=root_path)
except subprocess2.CalledProcessError:
add_errors = True