Skip to content

Commit b633aa1

Browse files
committed
Merge pull request git-lfs#1248 from github/full-remote-r
Return a fully remote ref to reduce chances of ref clashes
2 parents ac1a109 + 04db420 commit b633aa1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

git/git.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ func RemoteForCurrentBranch() (string, error) {
116116
return remote, nil
117117
}
118118

119-
// RemoteRefForCurrentBranch returns the full remote ref (remote/remotebranch) that the current branch is tracking
119+
// RemoteRefForCurrentBranch returns the full remote ref (refs/remotes/{remote}/{remotebranch})
120+
// that the current branch is tracking.
120121
func RemoteRefNameForCurrentBranch() (string, error) {
121122
ref, err := CurrentRef()
122123
if err != nil {
@@ -134,7 +135,7 @@ func RemoteRefNameForCurrentBranch() (string, error) {
134135

135136
remotebranch := RemoteBranchForLocalBranch(ref.Name)
136137

137-
return remote + "/" + remotebranch, nil
138+
return fmt.Sprintf("refs/remotes/%s/%s", remote, remotebranch), nil
138139
}
139140

140141
// RemoteForBranch returns the remote name that a given local branch is tracking (blank if none)

git/git_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestCurrentRefAndCurrentRemoteRef(t *testing.T) {
6666

6767
refname, err := RemoteRefNameForCurrentBranch()
6868
assert.Equal(t, nil, err)
69-
assert.Equal(t, "origin/someremotebranch", refname)
69+
assert.Equal(t, "refs/remotes/origin/someremotebranch", refname)
7070

7171
remote, err := RemoteForCurrentBranch()
7272
assert.Equal(t, nil, err)

0 commit comments

Comments
 (0)