Skip to content

Commit

Permalink
Merge branch 'js/lift-parent-count-limit' into maint
Browse files Browse the repository at this point in the history
There is no reason to have a hardcoded upper limit of the number of
parents for an octopus merge, created via the graft mechanism, but
there was.

* js/lift-parent-count-limit:
  Remove the line length limit for graft files
  • Loading branch information
Junio C Hamano committed Feb 5, 2014
2 parents ee5788e + e228c17 commit 3c86474
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
8 changes: 4 additions & 4 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,19 @@ struct commit_graft *read_graft_line(char *buf, int len)
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;
}

Expand Down
21 changes: 21 additions & 0 deletions t/annotate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ test_expect_success 'blame evil merge' '
check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1
'

test_expect_success 'blame huge graft' '
test_when_finished "git checkout branch2" &&
test_when_finished "rm -f .git/info/grafts" &&
graft= &&
for i in 0 1 2
do
for j in 0 1 2 3 4 5 6 7 8 9
do
git checkout --orphan "$i$j" &&
printf "%s\n" "$i" "$j" >file &&
test_tick &&
GIT_AUTHOR_NAME=$i$j GIT_AUTHOR_EMAIL=$i$j@test.git \
git commit -a -m "$i$j" &&
commit=$(git rev-parse --verify HEAD) &&
graft="$graft$commit "
done
done &&
printf "%s " $graft >.git/info/grafts &&
check_count -h 00 01 1 10 1
'

test_expect_success 'setup incomplete line' '
echo "incomplete" | tr -d "\\012" >>file &&
GIT_AUTHOR_NAME="C" GIT_AUTHOR_EMAIL="C@test.git" \
Expand Down
16 changes: 15 additions & 1 deletion t/t6101-rev-parse-parents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ test_expect_success 'setup' '
test_commit start2 &&
git checkout master &&
git merge -m next start2 &&
test_commit final
test_commit final &&
test_seq 40 |
while read i
do
git checkout --orphan "b$i" &&
test_tick &&
git commit --allow-empty -m "$i" &&
commit=$(git rev-parse --verify HEAD) &&
printf "$commit " >>.git/info/grafts
done
'

test_expect_success 'start is valid' '
Expand Down Expand Up @@ -79,6 +89,10 @@ test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' '
test_cmp expect actual
'

test_expect_success 'large graft octopus' '
test_cmp_rev_output b31 "git rev-parse --verify b1^30"
'

test_expect_success 'repack for next test' '
git repack -a -d
'
Expand Down

0 comments on commit 3c86474

Please sign in to comment.