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

Different behavior on Fetch and Pull #470

@calvn

Description

@calvn

I am getting different error behavior on Fetch() and Pull() for a fresh repository that I have created. The repository has one initial commit, and two branches, both on the same commit. The repository object is created via PlainClone().

$ mkdir -p test-repo && cd test-repo
$ git init .
$ echo $(date) > test
$ git add . && git commit -am "Initial commit"
$ git checkout -b "test"
...
	// This returns git.NoErrAlreadyUpToDate
        err := repo.Fetch(&git.FetchOptions{
		RefSpecs: []gconfig.RefSpec{"+refs/heads/master:refs/remotes/origin/master", "+refs/heads/test:refs/remotes/origin/test"},
	})
	if err == git.NoErrAlreadyUpToDate {
		fmt.Println("No changes detected on fetch")
		return nil
	} else if err != nil {
		return err
	}

	// This returns nil
	err := repo.Pull(&git.PullOptions{
		RemoteName:    "origin",
		ReferenceName: refName, // This is either refs/heads/master or refs/heads/test
	})
	if err == git.NoErrAlreadyUpToDate {
		fmt.Println("No changes detected on pull")
		return nil
	} else if err != nil {
		return err
	}
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions