The git plugin is making the mistaken assumption that the list of branches in the build is not empty. That is an incorrect assumption in this case.
The specific line that is throwing the null pointer exception was last modified 3 years ago. It needs a safety check that the list of branches is not null before it attempts to ask for the name of the branch to be included in the list of tags.
I don't know what would cause the list of branches to be empty in a workspace, but I believe that it is acceptable and valid to have a workspace with no active branches. In that case, the git plugin checkout uses the precise SHA-1 for the checkout rather than a branch checkout.
The warning message about JENKINS-19022 is usually an indication that a single Jenkins job is configured to build multiple branches. That is acceptable and valid but it is becoming less common as job definitions are switching from freestyle to pipeline. A single job that builds multiple branches will tend to collect lots of unhelpful entries in the build.xml files for each build. Those entries often include the SHA-1 hashes for each preceding build. Memory use can increase significantly when each build includes data for every preceding build.