Thanks to visit codestin.com
Credit goes to github.com

Skip to content

checkout: use empty baseline when no index file exists #3823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2016

Conversation

ethomson
Copy link
Member

When no index file exists and a baseline is not explicitly provided, use an empty baseline instead of trying to use HEAD as the baseline.

This is for compatibility with git:

% git status
On branch master
nothing to commit, working directory clean
% rm .git/index
% git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    README
    deleted:    branch_file.txt
    deleted:    link_to_new.txt
    deleted:    new.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    README
    branch_file.txt
    link_to_new.txt
    new.txt
% git checkout HEAD
error: The following untracked working tree files would be overwritten by checkout:
    README
    branch_file.txt
    link_to_new.txt
    new.txt
Please move or remove them before you can switch branches.
Aborting
% git checkout --force HEAD
% git status
On branch master
nothing to commit, working directory clean

Our previous behavior was to try to load HEAD when the index does not exist, which would simply do a diff between the baseline (HEAD) and the target (again, HEAD), which would be a noop.

Fixes #3811

When no index file exists and a baseline is not explicitly provided, use
an empty baseline instead of trying to load `HEAD`.
@ethomson
Copy link
Member Author

Note that this is still not completely correct: the "is this dirty" checkout conflict handling is not correctly taking the index into account but that's a different (and bigger) issue and I will follow up with a related pull request.

@carlosmn
Copy link
Member

Seems legit. Or at least we're doing mostly what git does.

@carlosmn carlosmn merged commit 69c71f2 into master Jun 17, 2016
@ethomson ethomson deleted the ethomson/checkout_no_index branch January 13, 2017 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants