Skip to content

Instantly share code, notes, and snippets.

View lushzero's full-sized avatar

Lush Zero lushzero

View GitHub Profile
@lushzero
lushzero / gist:6589291
Last active December 23, 2015 05:49
Demonstration of assertion fails when repo is removed
#include <stdio.h>
#include <git2.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main()
{
const char *err = "";
var git = require('./');
var path = require('path');
for(i=0;i<50;i++) {
git.Repo.open('/root/lushzero/node-sgit/.git', function(error, repository) {
if (error) {
throw error;
}
repository.getMaster(function(error, branch) {
if (error) {
==30873== Memcheck, a memory error detector
==30873== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==30873== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==30873== Command: node --nouse_idle_notification --expose_gc test2.js
==30873==
==30873== Syscall param ioctl(arg) contains uninitialised byte(s)
==30873== at 0x4281B79: ioctl (syscall-template.S:82)
==30873== by 0x8306E25: uv__cloexec (in /usr/bin/nodejs)
==30873== by 0x830715A: uv_disable_stdio_inheritance (in /usr/bin/nodejs)
==30873== by 0x81B21B7: node::Init(int, char**) (in /usr/bin/nodejs)
root:~/libgit/oops/libgit2/examples# strace ./init3
execve("./init3", ["./init3"], [/* 21 vars */]) = 0
brk(0) = 0x9972000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb78d1000
mmap2(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb78ce000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=50696, ...}) = 0
mmap2(NULL, 50696, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb78c1000
@lushzero
lushzero / gist:6252358
Created August 16, 2013 18:34
Demonstrate fail of git_index_add_bypath on freshly inited repo
#include <git2.h>
#include <stdio.h>
int main (int argc, char** argv)
{
git_index *index;
git_filebuf file = GIT_FILEBUF_INIT;
git_repository *repo;
const git_index_entry *entry;
git_oid id1;
#include <git2.h>
#include <stdio.h>
static void check_error(int error_code, const char *action)
{
if (!error_code)
return;
const git_error *error = giterr_last();
printf("Error %d %s - %s\n", error_code, action,