Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Pull after Fetch does not update HEAD #198

Closed
skyflyer opened this issue Jan 3, 2017 · 6 comments
Closed

Pull after Fetch does not update HEAD #198

skyflyer opened this issue Jan 3, 2017 · 6 comments
Labels

Comments

@skyflyer
Copy link

skyflyer commented Jan 3, 2017

When running Pull or Fetch on a FileSystemRepository, they both return an error when there is nothing new to fetch. (should this be a separate issue?)

Also, when doing Fetch to update repository and then Pull, I would expect to update my references, but the HEAD does not get updated.

In other words, I see that Pull is also performing a Fetch operation, but Fetch is not updating my head. And it is strange that Fetch and Pull return errors when nothing is to be pulled/fetched.

Steps to reproduce:

  1. Clone a repo using go-git
  2. Print Head: (i.e.: 3897b83b17306309fa8bb570c0404e1403d503bf)
  3. Using the git tool, push a new commit to the repo
  4. Perform Fetch followed by Pull
  5. Print Head (the result will be the same as in step 2)

If I don't perform a fetch, the head gets updated to the latest commit. I am calling Fetch and Pull methods on a *Repository instance.

After playing with it for some time, I managed to get it into a state, where it would not update the HEAD ref anymore: 2017/01/03 15:37:57 unknown channel ACK a0b3bee218aefd7f10ea45b12efd169edd128cab

Now, even though I perform just a Pull operation, the HEAD stays at some earlier commit. If I list the commits, I don't see all of them (the newer ones are missing). Note that the current HEAD is at the value in the error above (a0b3bee218aefd7f10ea45b12efd169edd128cab).

I was testing this on a master branch.

@smola
Copy link
Collaborator

smola commented Jan 9, 2017

@skyflyer Thank you for the report. We'll look into this.

With respect to the errors when there is no update, that is the current behavior. NoErrAlreadyUpToDate is returned if there is nothing to update (see: https://godoc.org/gopkg.in/src-d/go-git.v4#pkg-variables). This was not documented in the Pull and Fetch methods, so I'm updating the docs.

@skyflyer
Copy link
Author

skyflyer commented Jan 9, 2017

Thanks for the heads up on that error, that's very useful.

@skyflyer
Copy link
Author

skyflyer commented Jan 10, 2017

@smola, I started getting another error from Pull: ErrEmptyUploadPackRequest

I'm calling it like this: err = r.Pull(&git.PullOptions{RemoteName: remotes[0].Config().Name}) where remotes, err := r.Remotes() and r is *git.Repository;

I'm testing this with a master branch (commit 92d3de7255e3c92673c7e3f0298c26450d09dd98). Should I be adding something to the PullOptions struct?

Note that I am getting this error only when there are no updates; if there are updates in the repo, all is fine. Even if changes are on some branch.

@mcuadros
Copy link
Contributor

@skyflyer I just made a PR #207, fixing the main issue of this ticket.

Can you create another issue, with the second problem? And you provide a repository or something more detailed?

Thanks for your bug report is highly appreciated

@skyflyer
Copy link
Author

Maximo, sure. I'll create another issue in an hour or so.

@skyflyer
Copy link
Author

Created #208 to track no upload pack error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants