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

Skip to content

Missing checkout option to not overwrite existing files? #2701

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

Closed
swisspol opened this issue Nov 13, 2014 · 1 comment
Closed

Missing checkout option to not overwrite existing files? #2701

swisspol opened this issue Nov 13, 2014 · 1 comment

Comments

@swisspol
Copy link
Contributor

I'm working on a proper implementation of git stash apply (see #2636) based on the shell script implementation in Git (see https://github.com/git/git/blob/master/git-stash.sh#L440).

The shell script handles the commit from the stash for untracked files (if present) by calling git checkout-index --all which according to the documentation does not overwriting existing files (since -f is not passed).

I'm therefore assuming that git checkout-index --all is not touching the index at all and not modifying any files nor deleting any files from the work tree, but only adding new files.

How do you reproduce this behavior using git_checkout_tree()? If you pass GIT_CHECKOUT_SAFE_CREATE | GIT_CHECKOUT_DONT_UPDATE_INDEX, it will still update and delete files in the worktree (which is bad since the tree for the untracked commit in the stash only contains the untracked files and nothing else).

@ethomson
Copy link
Member

Sorry for the delay. In making a pass through bug reports, I think that this does exist, my reading of checkout options suggests that GIT_CHECKOUT_DONT_REMOVE_EXISTING will prevent existing files from being removed (either to delete them because they don't exist anymore or to rewrite them.

Please reopen if this is incorrect and this is an option that you require.

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

No branches or pull requests

2 participants