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

GitTfsRemote: Make --changeset keep already commited files #1382

Merged

Conversation

boogisha
Copy link
Contributor

On git tfs clone ... with both --changeset=VALUE and --gitignore=VALUE, --changeset option causes "git-tfs" to start with "a clean sheet" (an empty tree), probably expecting it to be the changeset to clone from into initial/root commit, thus not paying attention if there are any files commited already, ending up loosing them (like ".gitignore" one, in case of --gitignore=VALUE).

That might make sense by itself, if initial changeset would always be cloned into initial/root commit - yet, while not caring about the tree to start from, CopyTree() build logic does actually care about possibly existing commits, last one being added as cloned initial changeset commit parent. But because its already existing tree is disregarded, cloned initial changeset commit additionally removes all previously existing files, making the resulting tree appear as if history started with cloned initial changeset commit only, instead of whichever commit(s) preceded it.

To get the --changeset logic in sync, caring both about already existing commit(s) and corresponding tree(s), when present, let's make sure to start cloning into an existing (last commit) tree, instead of an empty one.

Resolve #1381

On `git tfs clone ...` with both `--changeset=VALUE` and `--gitignore=VALUE`, `--changeset` option causes "git-tfs" to start with "a clean sheet" (an empty tree), probably expecting it to be the changeset to clone from into initial/root commit, thus not paying attention if there are any files commited already, ending up loosing them (like ".gitignore" one, in case of `--gitignore=VALUE`).

That might make sense by itself, if initial changeset would always be cloned into initial/root commit - yet, while not caring about the tree to start from, `CopyTree()` build logic does actually care about possibly existing commits, last one being added as cloned initial changeset commit parent. But because its already existing tree is disregarded, cloned initial changeset commit additionally removes all previously existing files, making the resulting tree appear as if history started with cloned initial changeset commit only, instead of whichever commit(s) preceded it.

To get the `--changeset` logic in sync, caring _both_ about already existing commit(s) _and_ corresponding tree(s), when present, let's make sure to start cloning into an existing (last commit) tree, instead of an empty one.
@siprbaum
Copy link
Member

The change looks reasonable and I did test it locally and it fixes the problem.

@siprbaum siprbaum merged commit 41183f4 into git-tfs:master Jun 17, 2021
@siprbaum
Copy link
Member

@boogisha Thank you for your contribution!

@siprbaum
Copy link
Member

For reference, I also pushed a change to the release notes in 3512c31

@boogisha boogisha deleted the clone-changeset-keep-commited-files-1381 branch June 17, 2021 08:53
@boogisha
Copy link
Contributor Author

@boogisha Thank you for your contribution!

@siprbaum You're welcome, "git-tfs" being my ticket to starting with Git early and using it for a few years, it's the least I can do, time permitting :)

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.

On clone with --changeset .gitignore deleted on first commit
2 participants