-#include <ctype.h>
#include "cache.h"
static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)
if (!memcmp(line, "diff-tree ", 10))
p += 10;
+ else if (!memcmp(line, "commit ", 7))
+ p += 7;
if (!get_sha1_hex(p, n)) {
flush_current_id(patchlen, sha1, &ctx);
- memcpy(sha1, n, 20);
+ hashcpy(sha1, n);
patchlen = 0;
continue;
}
if (!patchlen && memcmp(line, "diff ", 5))
continue;
+ /* Ignore git-diff index header */
+ if (!memcmp(line, "index ", 6))
+ continue;
+
/* Ignore line numbers when computing the SHA1 of the patch */
if (!memcmp(line, "@@ -", 4))
continue;
flush_current_id(patchlen, sha1, &ctx);
}
-static const char patch_id_usage[] = "usage: git-patch-id < patch";
+static const char patch_id_usage[] = "git-patch-id < patch";
int main(int argc, char **argv)
{