Comment 6 for bug 1024073

Revision history for this message
Per Olausson (per-olauzzon-h) wrote :

This is quite a troublesome issue. It is not 100% reproducible because this issue depends on where the user is standing when he is invoking git-review.

(1) If the user is standing at the root of a Git repository, then git-review will work fine.

(2) If the user is standing anywhere else, then git-review will fail.

The reason for this is:

(1)

The path of git_dir will resolve to ".git" and when the path for the commit-msg hook is computed using os.path.join, the resulting path will be: ".git\\hooks\\commit-msg"

If python or scp is given this path, it will work.

Eg. "scp mylocalfile '.git\\hooks\\bla'
works.

(2)

If the user is in any sub directory of the Git repository, then rev-parse --show-toplevel --git-dir will generate a full path, eg.

c:/bla/bla/myrepo/.git

If this is then later used in an os.path.join() then '\\hook\\commit-msg' will be added to the full path.

Neither python nor scp will recognise any such path as being valid. And the hook will fail to be installed.

The solution for this is fairly trivial.

At the outset in main(), chdir to "git rev-parse --show-toplevel" and from there on I imagine that every and all operations will function properly, since everything coming out of git will be with relative paths.

Do you guys agree or have I missed any other functionality in git-review that will break as a result of altering the working directory at the outset?