[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [jgit-dev] creating a new branch fails with LOCK_FAILURE
- From: Shawn Pearce <spearce@xxxxxxxxxxx>
- Date: Wed, 4 Jan 2012 18:59:06 -0800
- Delivered-to: firstname.lastname@example.org
On Wed, Jan 4, 2012 at 10:19, <james.moger@xxxxxxxxxxx> wrote:
>>I.e do not call setExpectedOldObjectId() at all to create the
>>branch regardless of whether it is new or not.
> For my previous question on how to create an orphan branch I had tried
> that approach:
> That seemed logical to me, but it didn't work.
> I'm still wondering if there is a way to create an orphan branch with
> the JGit API... that would be very useful.
>From the API package, maybe not.
Creating an orphan branch is about building a commit with no parents,
and then setting some branch to point to that commit. The latter can
be done easily with any RefUpdate command, either create a new branch,
or force update an existing branch to the new commit's ObjectId.
Creating a new commit with no parents probably requires using the
CommitBuilder class directly. The CommitCommand only supports HEAD and
creates a new commit on top of that.
You may be able to relink HEAD to a non-existant branch name, then run
CommitCommand to make an orphan branch.