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

git: remove potentially duplicate check for unstaged files #1081

Conversation

meinto
Copy link
Contributor

@meinto meinto commented Mar 5, 2019

When you checkout a branch, you already look in the Reset method for unstaged files
(https://github.com/meinto/go-git/blob/master/worktree.go#L272-L281).

if opts.Mode == MergeReset {
	unstaged, err := w.containsUnstagedChanges()
	if err != nil {
		return err
	}

	if unstaged {
		return ErrUnstagedChanges
	}
}

That's why I think the check in the Checkout method is not necessary.

This would also increase the performance of the Checkout method, because containsUnstagedChanges contains a method call of merkletrie.DiffTree which takes very long on large projects:
#758 (comment)

Signed-off-by: Tobias Meinhardt <tobias.meinhardt89@gmail.com>
@mcuadros mcuadros merged commit 948b0c9 into src-d:master Mar 11, 2019
kunickiaj pushed a commit to kunickiaj/beer that referenced this pull request Jul 10, 2019
After src-d/go-git#1081 was merged,
the performance seems to be significantly better (usable).

Even if a slight bit slower, this means theres no more CGO dependency
making it much more portable.
kunickiaj pushed a commit to kunickiaj/beer that referenced this pull request Jul 10, 2019
* Switch to go-git for a pure golang implementation

After src-d/go-git#1081 was merged,
the performance seems to be significantly better (usable).

Even if a slight bit slower, this means theres no more CGO dependency
making it much more portable.

* Format cmd/brew.go

Co-Authored-By: fixmie[bot] <44270338+fixmie[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants