https://github.com/git/git
Revision 16cee38ae2bff93a4e4c512550fb4ccac035a3a1 authored by Junio C Hamano on 06 June 2006, 05:36:21 UTC, committed by Junio C Hamano on 06 June 2006, 05:36:21 UTC
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 1d84a60
Raw File
Tip revision: 16cee38ae2bff93a4e4c512550fb4ccac035a3a1 authored by Junio C Hamano on 06 June 2006, 05:36:21 UTC
rev-parse: tighten constness properly.
Tip revision: 16cee38
get-tar-commit-id.c
/*
 * Copyright (C) 2005 Rene Scharfe
 */
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define HEADERSIZE	1024

int main(int argc, char **argv)
{
	char buffer[HEADERSIZE];
	ssize_t n;

	n = read(0, buffer, HEADERSIZE);
	if (n < HEADERSIZE) {
		fprintf(stderr, "read error\n");
		return 3;
	}
	if (buffer[156] != 'g')
		return 1;
	if (memcmp(&buffer[512], "52 comment=", 11))
		return 1;
	n = write(1, &buffer[523], 41);
	if (n < 41) {
		fprintf(stderr, "write error\n");
		return 2;
	}
	return 0;
}
back to top