int fd;
long wrote;
- switch (ntohl(ce->ce_mode) & S_IFMT) {
- char *buf, *new;
+ switch (ce->ce_mode & S_IFMT) {
+ char *new;
+ struct strbuf buf;
unsigned long size;
case S_IFREG:
/*
* Convert from git internal format to working tree format
*/
- buf = convert_to_working_tree(ce->name, new, &size);
- if (buf) {
+ strbuf_init(&buf, 0);
+ if (convert_to_working_tree(ce->name, new, size, &buf)) {
+ size_t newsize = 0;
free(new);
- new = buf;
+ new = strbuf_detach(&buf, &newsize);
+ size = newsize;
}
if (to_tempfile) {
strcpy(path, ".merge_file_XXXXXX");
fd = mkstemp(path);
} else
- fd = create_file(path, ntohl(ce->ce_mode));
+ fd = create_file(path, ce->ce_mode);
if (fd < 0) {
free(new);
return error("git-checkout-index: unable to create file %s (%s)",
unlink(path);
if (S_ISDIR(st.st_mode)) {
/* If it is a gitlink, leave it alone! */
- if (S_ISGITLINK(ntohl(ce->ce_mode)))
+ if (S_ISGITLINK(ce->ce_mode))
return 0;
if (!state->force)
return error("%s is a directory", path);