Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit a4fa3c5

Browse files
committed
Remove the line length limit for graft files
Support for grafts predates Git's strbuf, and hence it is understandable that there was a hard-coded line length limit of 1023 characters (which was chosen a bit awkwardly, given that it is *exactly* one byte short of aligning with the 41 bytes occupied by a commit name and the following space or new-line character). While regular commit histories hardly win comprehensibility in general if they merge more than twenty-two branches in one go, only a lack of imagination could explain this unnecessary limitation for general use cases: the grafts facility *was* introduced to override regular commit histories. In this particular developer's case, the use case that requires substantially longer graft lines to be supported is the visualization of the commits' order implied by their changes: commits are considered to have an implicit relationship iff exchanging them in an interactive rebase would result in merge conflicts. Thusly implied branches tend to be very shallow in general, and the resulting thicket of implied branches is usually very wide; It is actually quite common that *most* of the commits in a topic branch have not even one implied parents, so that a final merge commit has about as many implied parents as there are commits in said branch. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ccf398b commit a4fa3c5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

builtin/blame.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,17 +1804,17 @@ static int prepare_lines(struct scoreboard *sb)
18041804
static int read_ancestry(const char *graft_file)
18051805
{
18061806
FILE *fp = fopen(graft_file, "r");
1807-
char buf[1024];
1807+
struct strbuf buf = STRBUF_INIT;
18081808
if (!fp)
18091809
return -1;
1810-
while (fgets(buf, sizeof(buf), fp)) {
1810+
while (!strbuf_getwholeline(&buf, fp, '\n')) {
18111811
/* The format is just "Commit Parent1 Parent2 ...\n" */
1812-
int len = strlen(buf);
1813-
struct commit_graft *graft = read_graft_line(buf, len);
1812+
struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
18141813
if (graft)
18151814
register_commit_graft(graft, 0);
18161815
}
18171816
fclose(fp);
1817+
strbuf_release(&buf);
18181818
return 0;
18191819
}
18201820

commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ struct commit_graft *read_graft_line(char *buf, int len)
196196
static int read_graft_file(const char *graft_file)
197197
{
198198
FILE *fp = fopen(graft_file, "r");
199-
char buf[1024];
199+
struct strbuf buf = STRBUF_INIT;
200200
if (!fp)
201201
return -1;
202-
while (fgets(buf, sizeof(buf), fp)) {
202+
while (!strbuf_getwholeline(&buf, fp, '\n')) {
203203
/* The format is just "Commit Parent1 Parent2 ...\n" */
204-
int len = strlen(buf);
205-
struct commit_graft *graft = read_graft_line(buf, len);
204+
struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
206205
if (!graft)
207206
continue;
208207
if (register_commit_graft(graft, 1))
209-
error("duplicate graft data: %s", buf);
208+
error("duplicate graft data: %s", buf.buf);
210209
}
211210
fclose(fp);
211+
strbuf_release(&buf);
212212
return 0;
213213
}
214214

0 commit comments

Comments
 (0)