Fix handling of old commits as new ones in new branches

If a new branch is pushed in Git without new commits (the branch
is created on a commit that already exists in the SCM-Manager repository
and pushed without any further commit), all ancestors of the commit
the branch points to have been treated as if they were new by the
hook changeset provider. This led to severe errors like wrong
push logs (by the pushlog plugin) or re-evaluated commit messages
by the commit message checker plugin.

This fixes this wrong behaviour. If new commits are not provided by
the pack parser, no commit will be treated as a new one.
This commit is contained in:
René Pfeuffer
2022-10-11 18:25:40 +02:00
parent 1e72eb52bd
commit 168d708906
2 changed files with 9 additions and 18 deletions

View File

@@ -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))

View File

@@ -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 --------------------------------------------------------------