-#define _XOPEN_SOURCE 500 /* glibc2 and AIX 5.3L need this */
-#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
-#include <time.h>
#include "cache.h"
#include "blob.h"
#include "commit.h"
static struct entry *insert_new(unsigned char *sha1, int pos)
{
struct entry *new = xcalloc(1, sizeof(struct entry));
- memcpy(new->old_sha1, sha1, 20);
+ hashcpy(new->old_sha1, sha1);
memmove(convert + pos + 1, convert + pos, (nr_convert - pos) * sizeof(struct entry *));
convert[pos] = new;
nr_convert++;
while (low < high) {
int next = (low + high) / 2;
struct entry *n = convert[next];
- int cmp = memcmp(sha1, n->old_sha1, 20);
+ int cmp = hashcmp(sha1, n->old_sha1);
if (!cmp)
return n;
if (cmp < 0) {
static void convert_binary_sha1(void *buffer)
{
struct entry *entry = convert_entry(buffer);
- memcpy(buffer, entry->new_sha1, 20);
+ hashcpy(buffer, entry->new_sha1);
}
static void convert_ascii_sha1(void *buffer)
if (!slash) {
newlen += sprintf(new + newlen, "%o %s", mode, path);
new[newlen++] = '\0';
- memcpy(new + newlen, buffer + len - 20, 20);
+ hashcpy((unsigned char*)new + newlen, (unsigned char *) buffer + len - 20);
newlen += 20;
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
continue;
}
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_sha1_file(new, newlen, tree_type, result_sha1);
while (size) {
int len = 1+strlen(buffer);
- convert_binary_sha1(buffer + len);
+ convert_binary_sha1((char *) buffer + len);
len += 20;
if (len > size)
die("corrupt tree object");
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_subdirectory(orig_buffer, orig_size, "", 0, result_sha1);
{
char *new = xmalloc(size + 100);
unsigned long newlen = 0;
-
- // "tree <sha1>\n"
+
+ /* "tree <sha1>\n" */
memcpy(new + newlen, buffer, 46);
newlen += 46;
- buffer += 46;
+ buffer = (char *) buffer + 46;
size -= 46;
- // "parent <sha1>\n"
+ /* "parent <sha1>\n" */
while (!memcmp(buffer, "parent ", 7)) {
memcpy(new + newlen, buffer, 48);
newlen += 48;
- buffer += 48;
+ buffer = (char *) buffer + 48;
size -= 48;
}
- // "author xyz <xyz> date"
+ /* "author xyz <xyz> date" */
newlen += convert_date_line(new + newlen, &buffer, &size);
- // "committer xyz <xyz> date"
+ /* "committer xyz <xyz> date" */
newlen += convert_date_line(new + newlen, &buffer, &size);
- // Rest
+ /* Rest */
memcpy(new + newlen, buffer, size);
newlen += size;
if (memcmp(buffer, "tree ", 5))
die("Bad commit '%s'", (char*) buffer);
- convert_ascii_sha1(buffer+5);
- buffer += 46; /* "tree " + "hex sha1" + "\n" */
+ convert_ascii_sha1((char *) buffer + 5);
+ buffer = (char *) buffer + 46; /* "tree " + "hex sha1" + "\n" */
while (!memcmp(buffer, "parent ", 7)) {
- convert_ascii_sha1(buffer+7);
- buffer += 48;
+ convert_ascii_sha1((char *) buffer + 7);
+ buffer = (char *) buffer + 48;
}
convert_date(orig_buffer, orig_size, result_sha1);
}