summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-04-03 00:10:47 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2017-04-03 00:10:47 +0100
commite86d02f92de2c446b370e4711dcfe2ea5ce75166 (patch)
tree716924862cc8be5889e67ddcdffbaa40b62fc1ae /src
parentea3bb5c0bb2be821ef6718ce57899ad5cb7a2d6b (diff)
downloadlibgit2-e86d02f92de2c446b370e4711dcfe2ea5ce75166.tar.gz
git_repository_set_head: use remote name in reflogethomson/set_head_to_tag
When `git_repository_set_head` is provided a remote reference, update the reflog with the tag name, like we do with a branch. This helps consumers match the semantics of `git checkout remote`.
Diffstat (limited to 'src')
-rw-r--r--src/repository.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index 5d54acd94..c26aa3465 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2525,7 +2525,9 @@ static int checkout_message(git_buf *out, git_reference *old, const char *new)
git_buf_puts(out, " to ");
- if (git_reference__is_branch(new) || git_reference__is_tag(new))
+ if (git_reference__is_branch(new) ||
+ git_reference__is_tag(new) ||
+ git_reference__is_remote(new))
git_buf_puts(out, git_reference__shorthand(new));
else
git_buf_puts(out, new);
@@ -2603,7 +2605,7 @@ int git_repository_set_head(
git_reference_name(ref), true, git_buf_cstr(&log_message));
} else {
error = detach(repo, git_reference_target(ref),
- git_reference_is_tag(ref) ? refname : NULL);
+ git_reference_is_tag(ref) || git_reference_is_remote(ref) ? refname : NULL);
}
} else if (git_reference__is_branch(refname)) {
error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, refname,