Recently this was added to post-review:
git_dir = execute(["git", "rev-parse", "--git-dir"],
ignore_errors=True).strip()
if git_dir.startswith("fatal:") or not os.path.isdir(git_dir):
return None
# post-review in directories other than the top level of
# of a work-tree would result in broken diffs on the server
os.chdir(os.path.dirname(git_dir))
The problem with this is that if you're in the root of your repo, git_dir
is set to ".git", and dirname returns an empty string, resulting in this
error when chdir is called:
File "/home/sandy/bin/post-review", line 1596, in get_repository_info
os.chdir(git_dir_name)
OSError: [Errno 2] No such file or directory: ''
I'm not a python or git expert, so I fixed this locally by changing that
last part to:
# post-review in directories other than the top level of
# of a work-tree would result in broken diffs on the server
git_dir_name = os.path.dirname(git_dir)
if git_dir_name != '':
os.chdir(git_dir_name)