Skip to content

Commit

Permalink
Use is_absolute_path() in sha1_file.c.
Browse files Browse the repository at this point in the history
There are some places that test for an absolute path. Use the helper
function to ease porting.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Nov 14, 2007
1 parent 25482a3 commit 85dadc3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)
char *pos = path;
struct stat st;

if (*pos == '/')
if (is_absolute_path(path))
pos++;

while (pos) {
Expand Down Expand Up @@ -253,7 +253,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
int entlen = pfxlen + 43;
int base_len = -1;

if (*entry != '/' && relative_base) {
if (!is_absolute_path(entry) && relative_base) {
/* Relative alt-odb */
if (base_len < 0)
base_len = strlen(relative_base) + 1;
Expand All @@ -262,7 +262,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
}
ent = xmalloc(sizeof(*ent) + entlen);

if (*entry != '/' && relative_base) {
if (!is_absolute_path(entry) && relative_base) {
memcpy(ent->base, relative_base, base_len - 1);
ent->base[base_len - 1] = '/';
memcpy(ent->base + base_len, entry, len);
Expand Down Expand Up @@ -333,7 +333,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
while (cp < ep && *cp != sep)
cp++;
if (last != cp) {
if ((*last != '/') && depth) {
if (!is_absolute_path(last) && depth) {
error("%s: ignoring relative alternate object store %s",
relative_base, last);
} else {
Expand Down

0 comments on commit 85dadc3

Please sign in to comment.