Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] creating a new branch fails with LOCK_FAILURE if branch already exists

Hi,

this is how we create a new branch:

final RefUpdate u = repo.updateRef(refname);
u.setExpectedOldObjectId(ObjectId.zeroId());
u.setNewObjectId(object.copy());
u.setRefLogIdent(refLogIdent);
u.setRefLogMessage("some message", false);
final RefUpdate.Result result = u.update(rw);
switch (result) {
  case FAST_FORWARD:
  case NEW:
  case NO_CHANGE:
    // branch creation was successful
    ...
    break;
  default: {
    throw new IOException(result.name());
  }
}

When the branch creation fails because a branch with the name already exists LOCK_FAILURE is returned as result.
Is this the intended behavior? Is LOCK_FAILURE only returned if the branch already exists or can it have other causes?
If there are also other possible causes, wouldn't it be better to rather have an explicit result for this case, e.g. ALREADY_EXISTS?
Then it would be easier to handle this case (e.g. to print out an appropriate error message).

Thanks and best regards,
Edwin



Back to the top