From e86d02f92de2c446b370e4711dcfe2ea5ce75166 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Mon, 3 Apr 2017 00:10:47 +0100 Subject: git_repository_set_head: use remote name in reflog 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`. --- src/repository.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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, -- cgit v1.2.1