https://github.com/git/git
Revision c54c7b376d73d2b3780475b18a6039721019aaba authored by Panagiotis Astithas on 11 June 2015, 14:37:25 UTC, committed by Junio C Hamano on 12 June 2015, 22:33:39 UTC
The output of "pmset -g batt" changed at some point from "Currently
drawing from 'AC Power'" to the slightly different "Now drawing from
'AC Power'". Starting the match from "drawing" makes the check work
in both old and new versions of OS X.

Signed-off-by: Panagiotis Astithas <pastith@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fdf96a2
Raw File
Tip revision: c54c7b376d73d2b3780475b18a6039721019aaba authored by Panagiotis Astithas on 11 June 2015, 14:37:25 UTC
hooks/pre-auto-gc: adjust power checking for newer OS X
Tip revision: c54c7b3
varint.c
#include "git-compat-util.h"
#include "varint.h"

uintmax_t decode_varint(const unsigned char **bufp)
{
	const unsigned char *buf = *bufp;
	unsigned char c = *buf++;
	uintmax_t val = c & 127;
	while (c & 128) {
		val += 1;
		if (!val || MSB(val, 7))
			return 0; /* overflow */
		c = *buf++;
		val = (val << 7) + (c & 127);
	}
	*bufp = buf;
	return val;
}

int encode_varint(uintmax_t value, unsigned char *buf)
{
	unsigned char varint[16];
	unsigned pos = sizeof(varint) - 1;
	varint[pos] = value & 127;
	while (value >>= 7)
		varint[--pos] = 128 | (--value & 127);
	if (buf)
		memcpy(buf, varint + pos, sizeof(varint) - pos);
	return sizeof(varint) - pos;
}
back to top