diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-04-04 18:18:45 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-04-05 13:49:31 +0200 |
commit | 8242cc1a23aba94c4a4d1082fc993ab5306814b6 (patch) | |
tree | 43507004a29edff28a41f46b009637b9be28e916 | |
parent | 5b65ac25780cc4c18c965e3202e2e882bd25d941 (diff) | |
download | libgit2-8242cc1a23aba94c4a4d1082fc993ab5306814b6.tar.gz |
repository: set error message if trying to set HEAD to a checked out one
If trying to set the HEAD of a repository to another reference, we have
to check whether this reference is already checked out in another linked
work tree. If it is, we will refuse setting the HEAD and return an
error, but do not set a meaningful error message. Add one.
-rw-r--r-- | src/repository.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/repository.c b/src/repository.c index 425ef796f..900a15dc7 100644 --- a/src/repository.c +++ b/src/repository.c @@ -2562,6 +2562,8 @@ int git_repository_set_head( if (ref && current->type == GIT_REF_SYMBOLIC && git__strcmp(current->target.symbolic, ref->name) && git_reference_is_branch(ref) && git_branch_is_checked_out(ref)) { + giterr_set(GITERR_REPOSITORY, "cannot set HEAD to reference '%s' as it is the current HEAD " + "of a linked repository.", git_reference_name(ref)); error = -1; goto cleanup; } |