diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2011-05-05 16:22:06 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@elego.de> | 2011-05-05 16:22:06 +0200 |
commit | ca8d2dfc0cea0c16e2d6bae16d95d652e292f473 (patch) | |
tree | f98e0c362a388f9a9efe644ac3e38828f5f14807 /src/commit.c | |
parent | 094aaaaee92f4fc98a6c3c3af36183cb217948a8 (diff) | |
parent | cc3b82e376e0216c1af4ad46d24327d61e9efd99 (diff) | |
download | libgit2-ca8d2dfc0cea0c16e2d6bae16d95d652e292f473.tar.gz |
Merge remote-tracking branch 'upstream/development' into config
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/commit.c b/src/commit.c index 9621703c3..0c37ec59b 100644 --- a/src/commit.c +++ b/src/commit.c @@ -224,9 +224,18 @@ int git_commit_create( if (error < GIT_SUCCESS) return error; - if (git_reference_type(head) == GIT_REF_SYMBOLIC) { - if ((error = git_reference_resolve(&head, head)) < GIT_SUCCESS) + error = git_reference_resolve(&head, head); + if (error < GIT_SUCCESS) { + if (error != GIT_ENOTFOUND) return error; + /* + * The target of the reference was not found. This can happen + * just after a repository has been initialized (the master + * branch doesn't exist yet, as it doesn't have anything to + * point to) or after an orphan checkout, so if the target + * branch doesn't exist yet, create it and return. + */ + return git_reference_create_oid_f(&head, repo, git_reference_target(head), oid); } error = git_reference_set_oid(head, oid); |