Merge branch 'ms/patch-id-with-overlong-line' into maint
* ms/patch-id-with-overlong-line: patch-id.c: use strbuf instead of a fixed buffer
This commit is contained in:
commit
f5fcb59034
@ -56,13 +56,13 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
|
static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx, struct strbuf *line_buf)
|
||||||
{
|
{
|
||||||
static char line[1000];
|
|
||||||
int patchlen = 0, found_next = 0;
|
int patchlen = 0, found_next = 0;
|
||||||
int before = -1, after = -1;
|
int before = -1, after = -1;
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), stdin) != NULL) {
|
while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
|
||||||
|
char *line = line_buf->buf;
|
||||||
char *p = line;
|
char *p = line;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -133,14 +133,16 @@ static void generate_id_list(void)
|
|||||||
unsigned char sha1[20], n[20];
|
unsigned char sha1[20], n[20];
|
||||||
git_SHA_CTX ctx;
|
git_SHA_CTX ctx;
|
||||||
int patchlen;
|
int patchlen;
|
||||||
|
struct strbuf line_buf = STRBUF_INIT;
|
||||||
|
|
||||||
git_SHA1_Init(&ctx);
|
git_SHA1_Init(&ctx);
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
while (!feof(stdin)) {
|
while (!feof(stdin)) {
|
||||||
patchlen = get_one_patchid(n, &ctx);
|
patchlen = get_one_patchid(n, &ctx, &line_buf);
|
||||||
flush_current_id(patchlen, sha1, &ctx);
|
flush_current_id(patchlen, sha1, &ctx);
|
||||||
hashcpy(sha1, n);
|
hashcpy(sha1, n);
|
||||||
}
|
}
|
||||||
|
strbuf_release(&line_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char patch_id_usage[] = "git patch-id < patch";
|
static const char patch_id_usage[] = "git patch-id < patch";
|
||||||
|
Loading…
Reference in New Issue
Block a user