shithub: libgit

ref: 073882f6a2a8c065375b94dc77c59eb7d8b2091f
dir: /test/gtest.c/

View raw version
#include <u.h>
#include <libc.h>
#include "../git.h"

char *dir = "/tmp/repo";
char *addfile = "test";

#define test(A, B) if (!A) { sysfatal("%s: %r\n", B); }

void
main(void)
{
	int fd;
	char buf[128];
	
	if (!initgit("/tmp/repo"))
		sysfatal("gitinit: %r");
	
	snprint(buf, sizeof(buf), "%s/%s", dir, addfile);
	
	fd = create(buf, OWRITE, 0666);
	if (fd < 0)
		sysfatal("%r");
	fprint(fd, "hello world\n");
	close(fd);
	
	test(gitadd(addfile, nil), "add file");
	test(gitcommit("add file", addfile, nil), "commit add");
	test(gitrm(addfile, nil), "rm file");
	test(gitcommit("remove file", addfile, nil), "commit rm");
}