Skip to content

Commit

Permalink
Fixed error updating HEAD when cloning a repo.
Browse files Browse the repository at this point in the history
GetHeadBranch() used to return a string of the Branch name, but now
returns a type Branch (which is the Refspec, not the name.) The
reset call wasn't updated, and was duplicating the refs/heads/ portion of
the filename.

Fixes #5
  • Loading branch information
driusan committed Jan 3, 2017
1 parent b122b7c commit 3410cd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Reset(c *git.Client, args []string) {
// git reset [mode] commit
// First, update the head reference for all modes
branchName := c.GetHeadBranch()
err := c.GitDir.WriteFile(git.File("refs/heads/"+branchName),
err := c.GitDir.WriteFile(git.File(branchName.String()),
[]byte(fmt.Sprintf("%s", commitId)),
0644,
)
Expand Down
4 changes: 4 additions & 0 deletions git/refspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func (r RefSpec) Value(c *Client) (string, error) {
// Use GetBranch to get a valid branch from a branchname, don't cast from string
type Branch RefSpec

// Implements Stringer on Branch
func (b Branch) String() string {
return RefSpec(b).String()
}
// Returns a valid Branch object for an existing branch.
func GetBranch(c *Client, branchname string) (Branch, error) {
b := Branch("refs/heads/" + branchname)
Expand Down

0 comments on commit 3410cd9

Please sign in to comment.