]> asedeno.scripts.mit.edu Git - git.git/blobdiff - read-cache.c
gitweb: Add links to blobdiffs in from-file/to-file header for merges
[git.git] / read-cache.c
index e04e99112d4c4b19dc1b6e1dcab89600bb30b57a..4362b11f475748e89e9deaf6257fb0c411948105 100644 (file)
@@ -92,7 +92,7 @@ static int ce_compare_gitlink(struct cache_entry *ce)
 
        /*
         * We don't actually require that the .git directory
-        * under DIRLNK directory be a valid git directory. It
+        * under GITLINK directory be a valid git directory. It
         * might even be missing (in case nobody populated that
         * sub-project).
         *
@@ -115,7 +115,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
                        return DATA_CHANGED;
                break;
        case S_IFDIR:
-               if (S_ISDIRLNK(ntohl(ce->ce_mode)))
+               if (S_ISGITLINK(ntohl(ce->ce_mode)))
                        return 0;
        default:
                return TYPE_CHANGED;
@@ -142,7 +142,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
                    (has_symlinks || !S_ISREG(st->st_mode)))
                        changed |= TYPE_CHANGED;
                break;
-       case S_IFDIRLNK:
+       case S_IFGITLINK:
                if (!S_ISDIR(st->st_mode))
                        changed |= TYPE_CHANGED;
                else if (ce_compare_gitlink(ce))
@@ -166,7 +166,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
                changed |= MTIME_CHANGED;
        if (ce->ce_ctime.nsec != htonl(st->st_ctim.tv_nsec))
                changed |= CTIME_CHANGED;
-#endif 
+#endif
 
        if (ce->ce_uid != htonl(st->st_uid) ||
            ce->ce_gid != htonl(st->st_gid))
@@ -597,7 +597,7 @@ static int has_dir_name(struct index_state *istate,
  * is being added, or we already have path and path/file is being
  * added.  Either one would result in a nonsense tree that has path
  * twice when git-write-tree tries to write it out.  Prevent it.
- * 
+ *
  * If ok-to-replace is specified, we remove the conflicting entries
  * from the cache so the caller should recompute the insert position.
  * When this happens, we return non-zero.
@@ -864,16 +864,15 @@ int read_index_from(struct index_state *istate, const char *path)
                die("index file open failed (%s)", strerror(errno));
        }
 
-       if (!fstat(fd, &st)) {
-               istate->mmap_size = xsize_t(st.st_size);
-               errno = EINVAL;
-               if (istate->mmap_size >= sizeof(struct cache_header) + 20)
-                       istate->mmap = xmmap(NULL, istate->mmap_size,
-                                           PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
-               else
-                       die("index file smaller than expected");
-       } else
+       if (fstat(fd, &st))
                die("cannot stat the open index (%s)", strerror(errno));
+
+       errno = EINVAL;
+       istate->mmap_size = xsize_t(st.st_size);
+       if (istate->mmap_size < sizeof(struct cache_header) + 20)
+               die("index file smaller than expected");
+
+       istate->mmap = xmmap(NULL, istate->mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
        close(fd);
 
        hdr = istate->mmap;
@@ -971,8 +970,8 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
                write_buffer_len = buffered;
                len -= partial;
                data = (char *) data + partial;
-       }
-       return 0;
+       }
+       return 0;
 }
 
 static int write_index_ext_header(SHA_CTX *context, int fd,
@@ -1038,7 +1037,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
                 * size to zero here, then the object name recorded
                 * in index is the 6-byte file but the cached stat information
                 * becomes zero --- which would then match what we would
-                * obtain from the filesystem next time we stat("frotz"). 
+                * obtain from the filesystem next time we stat("frotz").
                 *
                 * However, the second update-index, before calling
                 * this function, notices that the cached size is 6