]> git.proxmox.com Git - libgit2.git/commit - src/repository.c
Fix directory/path manipulation methods
authorVicent Marti <tanoku@gmail.com>
Sat, 5 Feb 2011 10:42:41 +0000 (12:42 +0200)
committerVicent Marti <tanoku@gmail.com>
Sat, 5 Feb 2011 10:42:41 +0000 (12:42 +0200)
commitf725931b4865317b58c1f1600724cb36e586c332
tree571497dd0b831f683ffa6326014db2549e5a9a21
parentc836c332f17ff2da8bdf6d18fb3d59eac2586ca9
Fix directory/path manipulation methods

The `dirname` and `dirbase` methods have been replaced with the Android
implementation, which is actually compilant to some kind of standard.

A new method `topdir` has been added, which returns the topmost
directory in a path.

These changes fix issue #49:

`gitfo_prettify_dir_path` converts "./.git/" to ".git/", so
the code at src/repository.c:190 goes out of bounds when
trying to find the topmost directory.

The new `git__topdir` method handles this gracefully, and the
fixed `git__dirname` now returns the proper value for the
repository's working dir.

E.g.

/repo/.git/ ==> working dir '/repo/'
.git/ ==> working dir '.'

Signed-off-by: Vicent Marti <tanoku@gmail.com>
src/odb_loose.c
src/repository.c
src/util.c
src/util.h
tests/t00-core.c