-static int get_old_sha1(const char *refname, unsigned char *sha1)
-{
- int fd, ret;
-
- fd = open(git_path("%s", refname), O_RDONLY);
- ret = -1;
- if (fd >= 0) {
- char buffer[60];
- if (read(fd, buffer, sizeof(buffer)) >= 40)
- ret = get_sha1_hex(buffer, sha1);
- close(fd);
- }
- return ret;
-}
-
-static int check_ref(const char *refname, const unsigned char *sha1)
-{
- unsigned char mysha1[20];
- char oldhex[41];
-
- if (get_old_sha1(refname, mysha1) < 0)
- memset(mysha1, 0, 20);
-
- if (!memcmp(sha1, mysha1, 20)) {
- fprintf(stderr, "%s: unchanged\n", refname);
- return 0;
- }
-
- memcpy(oldhex, sha1_to_hex(mysha1), 41);
- fprintf(stderr, "%s: %s (%s)\n", refname, sha1_to_hex(sha1), oldhex);
- return 1;
-}
-