Code

Merge branch 'jk/send-pack'
[git.git] / sha1_file.c
index 83a06a7aed84715db191b703e529d3501df0a8f2..560c0e0d0881d77829d508ca28577f4b452906c6 100644 (file)
@@ -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) {
@@ -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;
@@ -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);
@@ -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 {
@@ -521,13 +521,15 @@ static int check_packed_git_idx(const char *path,  struct packed_git *p)
                        munmap(idx_map, idx_size);
                        return error("wrong index v2 file size in %s", path);
                }
-               if (idx_size != min_size) {
-                       /* make sure we can deal with large pack offsets */
-                       off_t x = 0x7fffffffUL, y = 0xffffffffUL;
-                       if (x > (x + 1) || y > (y + 1)) {
-                               munmap(idx_map, idx_size);
-                               return error("pack too large for current definition of off_t in %s", path);
-                       }
+               if (idx_size != min_size &&
+                   /*
+                    * make sure we can deal with large pack offsets.
+                    * 31-bit signed offset won't be enough, neither
+                    * 32-bit unsigned one will be.
+                    */
+                   (sizeof(off_t) <= 4)) {
+                       munmap(idx_map, idx_size);
+                       return error("pack too large for current definition of off_t in %s", path);
                }
        }