diff options
author | Taylor Blau <me@ttaylorr.com> | 2024-08-15 19:31:17 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-08-15 20:29:15 +0200 |
commit | 25b78668de62ac2f503ee5957e174474bd51ae6c (patch) | |
tree | a22ab1b81e3e6f088695ce266c5e0b791e9699c2 | |
parent | t/t5333-pseudo-merge-bitmaps.sh: demonstrate empty pseudo-merge groups (diff) | |
download | git-25b78668de62ac2f503ee5957e174474bd51ae6c.tar.xz git-25b78668de62ac2f503ee5957e174474bd51ae6c.zip |
pseudo-merge.c: do not generate empty pseudo-merge commits
The previous commit demonstrated it is possible to generate empty
pseudo-merge commits, which is not useful as such pseudo-merges carry no
information.
Ensure that we only generate non-empty groups by not pushing a new
commit onto the bitmap_writer when that commit has no parents.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | pseudo-merge.c | 11 | ||||
-rwxr-xr-x | t/t5333-pseudo-merge-bitmaps.sh | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/pseudo-merge.c b/pseudo-merge.c index f0fde13c47..6422be979c 100644 --- a/pseudo-merge.c +++ b/pseudo-merge.c @@ -357,8 +357,10 @@ static void select_pseudo_merges_1(struct bitmap_writer *writer, p = commit_list_append(c, p); } while (j % group->stable_size); - bitmap_writer_push_commit(writer, merge, 1); - writer->pseudo_merges_nr++; + if (merge->parents) { + bitmap_writer_push_commit(writer, merge, 1); + writer->pseudo_merges_nr++; + } } /* make up to group->max_merges pseudo merges for unstable commits */ @@ -398,8 +400,9 @@ static void select_pseudo_merges_1(struct bitmap_writer *writer, p = commit_list_append(c, p); } - bitmap_writer_push_commit(writer, merge, 1); - writer->pseudo_merges_nr++; + if (merge->parents) { + bitmap_writer_push_commit(writer, merge, 1); + writer->pseudo_merges_nr++; } if (end >= matches->unstable_nr) break; } diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh index 0288691340..aa1a7d26f1 100755 --- a/t/t5333-pseudo-merge-bitmaps.sh +++ b/t/t5333-pseudo-merge-bitmaps.sh @@ -390,7 +390,7 @@ test_expect_success 'pseudo-merge reuse' ' ) ' -test_expect_failure 'empty pseudo-merge group' ' +test_expect_success 'empty pseudo-merge group' ' git init pseudo-merge-empty-group && ( cd pseudo-merge-empty-group && |