struct entry *entry;
if (get_sha1_hex(buffer, sha1))
- die("bad sha1");
+ die("expected sha1, got '%s'", (char*) buffer);
entry = convert_entry(sha1);
memcpy(buffer, sha1_to_hex(entry->new_sha1), 40);
}
+static unsigned int convert_mode(unsigned int mode)
+{
+ unsigned int newmode;
+
+ newmode = mode & S_IFMT;
+ if (S_ISREG(mode))
+ newmode |= (mode & 0100) ? 0755 : 0644;
+ return newmode;
+}
+
static int write_subdirectory(void *buffer, unsigned long size, const char *base, int baselen, unsigned char *result_sha1)
{
char *new = xmalloc(size);
if (!path || sscanf(buffer, "%o", &mode) != 1)
die("bad tree conversion");
+ mode = convert_mode(mode);
path++;
if (memcmp(path, base, baselen))
break;
void *orig_buffer = buffer;
unsigned long orig_size = size;
+ if (memcmp(buffer, "tree ", 5))
+ die("Bad commit '%s'", (char*) buffer);
convert_ascii_sha1(buffer+5);
buffer += 46; /* "tree " + "hex sha1" + "\n" */
while (!memcmp(buffer, "parent ", 7)) {
die("unknown object type '%s' in %s", type, sha1_to_hex(sha1));
entry->converted = 1;
free(buffer);
+ free(data);
return entry;
}