Revision 5f42ac921fe06bbb80df82d8fa5cb15701ec2f60 authored by J. Bruce Fields on 05 August 2007, 23:16:09 UTC, committed by J. Bruce Fields on 05 August 2007, 23:18:05 UTC
It was a neat trick to show that you could introduce the git-add manual
page without using the word "index", and it was certainly an improvement
over the previous man page (which started out "A simple wrapper for
git-update-index to add files to the index...").

But it's possible to use the standard terminology without sacrificing
user-friendliness.  So, rewrite to use the word "index" when
appropriate.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
1 parent 4e0b2bb
Raw File
strbuf.c
#include "cache.h"
#include "strbuf.h"

void strbuf_init(struct strbuf *sb) {
	sb->buf = NULL;
	sb->eof = sb->alloc = sb->len = 0;
}

static void strbuf_begin(struct strbuf *sb) {
	free(sb->buf);
	strbuf_init(sb);
}

static void inline strbuf_add(struct strbuf *sb, int ch) {
	if (sb->alloc <= sb->len) {
		sb->alloc = sb->alloc * 3 / 2 + 16;
		sb->buf = xrealloc(sb->buf, sb->alloc);
	}
	sb->buf[sb->len++] = ch;
}

static void strbuf_end(struct strbuf *sb) {
	strbuf_add(sb, 0);
}

void read_line(struct strbuf *sb, FILE *fp, int term) {
	int ch;
	strbuf_begin(sb);
	if (feof(fp)) {
		sb->eof = 1;
		return;
	}
	while ((ch = fgetc(fp)) != EOF) {
		if (ch == term)
			break;
		strbuf_add(sb, ch);
	}
	if (ch == EOF && sb->len == 0)
		sb->eof = 1;
	strbuf_end(sb);
}

back to top