Merge changes Ib4cb4207,I64b967c9

* changes:
  Avoid opening the branch twice during submit
  Fix potential race in MergeOp caused by two reads