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

Fixes checkout not possible with (untracked) files under gitignore #444

Merged
merged 2 commits into from
Jun 21, 2017
Merged

Fixes checkout not possible with (untracked) files under gitignore #444

merged 2 commits into from
Jun 21, 2017

Conversation

osklyar
Copy link

@osklyar osklyar commented Jun 20, 2017

This is a follow up for #429. The original implementation was based on the assumption that Worktree.Status is used to check differences between the index and the worktree. However, the Worktree.Checkout uses Worktree.diffStagingWithWorktree (via Worktree.cointainsUnstagedChanges), which is also used by the Status. This has prevented a checkout of a branch due to "unstaged changes" even when the status shows clean.

In this PR the application of ignores is moved from Status directly into diffStagingWithWorktree, so the Status logic remains unchanged, but now the same logic applies to Checkout. With this change Checkout proceeds as there are no unstaged changes any longer (listed in ignores).

@mcuadros
Copy link
Contributor

can you provide a test?

@osklyar
Copy link
Author

osklyar commented Jun 20, 2017

The Status test is still covered by the original one. A test for Checkout is added below

@codecov
Copy link

codecov bot commented Jun 20, 2017

Codecov Report

Merging #444 into master will decrease coverage by 0.58%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
- Coverage   78.01%   77.43%   -0.59%     
==========================================
  Files         127      127              
  Lines        9171     9173       +2     
==========================================
- Hits         7155     7103      -52     
- Misses       1236     1305      +69     
+ Partials      780      765      -15
Impacted Files Coverage Δ
worktree_status.go 71.36% <100%> (+0.26%) ⬆️
plumbing/transport/ssh/common.go 0% <0%> (-50.91%) ⬇️
plumbing/transport/ssh/auth_method.go 33.33% <0%> (-24.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65bf694...81dbc6a. Read the comment docs.

@osklyar osklyar changed the title Fixes gitignore ignored on checkout Fixes checkout not possible with (untracked) files under gitignore Jun 20, 2017
@mcuadros
Copy link
Contributor

You should provide a test where the checkout has ignored files.

@osklyar
Copy link
Author

osklyar commented Jun 21, 2017

This is exactly what the test does: (1) checkout on an empty repo -- no errors, (2) file file added and checkout produces an error, (3) .gitignore added and checkout still produces an error (file is no more a problem, but .gitignore itself is, (4) .gitignore staged and now checkout produces no error because file is excluded from unstaged by .gitignore. Well, this was the intention. Do you see a mistake in this reasoning?

@mcuadros mcuadros merged commit ad02bf0 into src-d:master Jun 21, 2017
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