Skip to content
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

Stash apply: stage new files even when not updating the index #3259

Merged
merged 4 commits into from
Jun 26, 2015

Conversation

ethomson
Copy link
Member

Stash application should stage new files, even when we're not updating the index.

C:\Temp\stash_apply_sucks>git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   bar
        modified:   foo


C:\Temp\stash_apply_sucks>git stash
Saved working directory and index state WIP on master: 4a6df6d foo
HEAD is now at 4a6df6d foo

C:\Temp\stash_apply_sucks>git status
On branch master
nothing to commit, working directory clean

C:\Temp\stash_apply_sucks>git stash apply
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   bar

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   foo

WHAT A SENSIBLE ARCHITECTURE THIS IS. So we need to do the same thing. We break the actual iterator walking code out of merge to create a new index that has just the new files, which we will set as the new repo's index (unless the user actually specified that they wanted to restore the index).

ethomson added 4 commits June 25, 2015 18:33
Provide `git_iterator_walk` to walk each iterator in lockstep,
returning each iterator's idea of the contents of the next path.
Files that were new (staged additions) in the stash tree should
be staged when unstashing, even when not applying the index.
@ethomson
Copy link
Member Author

Oh, right, it turns out that we should also block stash application if there are any staged changes.

carlosmn added a commit that referenced this pull request Jun 26, 2015
Stash apply: stage new files even when not updating the index
@carlosmn carlosmn merged commit 354268c into libgit2:master Jun 26, 2015
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