]> git.ipfire.org Git - thirdparty/git.git/commit - setup.c
properly keep track of current working directory
authorClemens Buchacher <drizzd@aon.at>
Thu, 12 Apr 2012 23:11:36 +0000 (01:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Apr 2012 20:28:02 +0000 (13:28 -0700)
commit2565b43bd2634ffd6bda06236d664288aeb8eb6a
treec7f09bea843450064e21caa3ff5906c20af12629
parente8dde3e5f9ddb7cf95a6ff3cea6cf07c3a2db80d
properly keep track of current working directory

Various failure modes in the repository detection code path currently
quote the wrong directory in their error message. The working directory
is changed iteratively to the parent directory until a git repository is
found. If the working directory cannot be changed to the parent
directory for some reason, the detection gives up and prints an error
message. The error message should report the current working directory.

Instead of continually updating the 'cwd' variable, which is actually
used to remember the original working directory, the 'offset' variable
is used to keep track of the current working directory. At the point
where the affected error handling code is called, 'offset' already
points to the end of the parent of the working directory, rather than
the current working directory.

Fix this by explicitly using a variable 'offset_parent' and update
'offset' concurrently with the call to chdir.

In a similar fashion, the function get_device_or_die() would print the
original working directory in case of a failure, rather than the current
working directory. Fix this as well by making use of the 'offset'
variable.

Lastly, replace the phrase 'mount parent' with 'mount point'. The former
appears to be a typo.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c