FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

checkout: use empty baseline when no index file exists by ethomson · Pull Request #3823 · libgit2/libgit2 · GitHub

Repository navigation

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

Merged
carlosmn merged 1 commit into
masterfrom
ethomson/checkout_no_index
Jun 17, 2016
Merged

carlosmn merged 1 commit into
masterfrom
ethomson/checkout_no_index

Conversation

Copy link
Copy Markdown
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`.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Member

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

carlosmn merged commit 69c71f2 into master Jun 17, 2016
ethomson deleted the ethomson/checkout_no_index branch January 13, 2017 12:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL