]> git.proxmox.com Git - libgit2.git/commitdiff
Fix bug in dir_for_path
authorRussell Belfer <arrbee@arrbee.com>
Thu, 12 Jan 2012 01:28:25 +0000 (17:28 -0800)
committerRussell Belfer <arrbee@arrbee.com>
Thu, 12 Jan 2012 01:28:25 +0000 (17:28 -0800)
The last checkin accidentally broke dir_for_path by propogating
the dirname return code even when there was no error.

src/fileops.c

index 1d991b36dda876fc3e61b87cbfd3c8289c3c2285..3412a47e214f4cef1602632b3d808bd6fc1e7673 100644 (file)
@@ -551,7 +551,8 @@ int git_futils_dir_for_path(git_buf *dir, const char *path, const char *base)
 
        /* call dirname if this is not a directory */
        if (error == GIT_SUCCESS && git_futils_isdir(dir->ptr) != GIT_SUCCESS)
-               error = git_path_dirname_r(dir, dir->ptr);
+               if (git_path_dirname_r(dir, dir->ptr) < GIT_SUCCESS)
+                       error = git_buf_lasterror(dir);
 
        if (error == GIT_SUCCESS)
                error = git_path_to_dir(dir);