[PATCH 7/8] pseudo-merge.c: do not generate empty pseudo-merge commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 pseudo-merge.c                  | 11 +++++++----
 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 &&
-- 
2.46.0.54.gc9a64b1d2a





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux