mirror of
https://github.com/git/git.git
synced 2026-02-10 17:57:23 +00:00
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 <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -1804,17 +1804,17 @@ static int prepare_lines(struct scoreboard *sb)
|
||||
static int read_ancestry(const char *graft_file)
|
||||
{
|
||||
FILE *fp = fopen(graft_file, "r");
|
||||
char buf[1024];
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
if (!fp)
|
||||
return -1;
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
while (!strbuf_getwholeline(&buf, fp, '\n')) {
|
||||
/* The format is just "Commit Parent1 Parent2 ...\n" */
|
||||
int len = strlen(buf);
|
||||
struct commit_graft *graft = read_graft_line(buf, len);
|
||||
struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
|
||||
if (graft)
|
||||
register_commit_graft(graft, 0);
|
||||
}
|
||||
fclose(fp);
|
||||
strbuf_release(&buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
10
commit.c
10
commit.c
@@ -196,19 +196,19 @@ bad_graft_data:
|
||||
static int read_graft_file(const char *graft_file)
|
||||
{
|
||||
FILE *fp = fopen(graft_file, "r");
|
||||
char buf[1024];
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
if (!fp)
|
||||
return -1;
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
while (!strbuf_getwholeline(&buf, fp, '\n')) {
|
||||
/* The format is just "Commit Parent1 Parent2 ...\n" */
|
||||
int len = strlen(buf);
|
||||
struct commit_graft *graft = read_graft_line(buf, len);
|
||||
struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
|
||||
if (!graft)
|
||||
continue;
|
||||
if (register_commit_graft(graft, 1))
|
||||
error("duplicate graft data: %s", buf);
|
||||
error("duplicate graft data: %s", buf.buf);
|
||||
}
|
||||
fclose(fp);
|
||||
strbuf_release(&buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user