Merge branch 'nd/maint-relative'

* nd/maint-relative:
  get_cwd_relative(): do not misinterpret root path
This commit is contained in:
Junio C Hamano 2010-12-16 12:49:48 -08:00
commit 20cb8e2025

6
dir.c
View File

@ -1033,6 +1033,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
case '/': case '/':
return cwd + 1; return cwd + 1;
default: default:
/*
* dir can end with a path separator when it's root
* directory. Return proper prefix in that case.
*/
if (dir[-1] == '/')
return cwd;
return NULL; return NULL;
} }
} }