diff --git a/gradle/changelog/fix_empty_branches.yaml b/gradle/changelog/fix_empty_branches.yaml new file mode 100644 index 0000000000..1bfe7bf549 --- /dev/null +++ b/gradle/changelog/fix_empty_branches.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Handling of old commits as new ones in new branches ([#2130](https://github.com/scm-manager/scm-manager/pull/2130)) diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/CollectingPackParserListener.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/CollectingPackParserListener.java index 11dba9ce83..0cbda8c4ef 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/CollectingPackParserListener.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/CollectingPackParserListener.java @@ -123,21 +123,13 @@ public class CollectingPackParserListener implements PackParserListener if (newObjectIdMap != null) { newObjectIds = ImmutableSet.copyOf(newObjectIdMap); - } - else - { - logger.warn("pack parser returned no newObjectIds"); - newObjectIds = ImmutableSet.of(); - } - - if (newObjectIds.isEmpty()) - { - logger.debug("new object ids are empty, we treat every commit as new"); - } - else - { logger.debug("collected {} new object ids", newObjectIds.size()); } + else + { + logger.warn("pack parser returned no newObjectIds; no commit will be treated as a new one"); + newObjectIds = Set.of(); + } } /** @@ -161,10 +153,7 @@ public class CollectingPackParserListener implements PackParserListener //~--- get methods ---------------------------------------------------------- /** - * Returns {@code true} if the object is a new object. The method will also - * return {@code true}, if the pack parser does not return a list with new - * object ids. - * + * Returns {@code true} if the object is a new object. * * @param object rev object * @@ -174,7 +163,7 @@ public class CollectingPackParserListener implements PackParserListener { ensureAfterWasCalled(); - return newObjectIds.isEmpty() || newObjectIds.contains(object.getId()); + return newObjectIds.contains(object.getId()); } //~--- methods --------------------------------------------------------------