Instead of testing that the short name is master... I would test the full name:

  if (target.getName().equals(Constants.R_HEADS + Constants.MASTER))

That way we don't accidentally use the "merge into master format" if someone manages to make us merge into a branch called "refs/mynames/master".