question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Git clone stops if changeset is rename

See original GitHub issue

If a tfs checkin contains a deletion or rename of a directory (= is a rename checkin) the clone operation stopps at that changeset and doesn’t fetch newer changesets. Only workaround is to use the quick-clone command.

I think I identified the code that causes that bug but I am not sure, if there is some purpose behind this block. The following return causes the code to not fetch any newer commits than the one with the rename:

GitTfsRemote.cs Line 361

if (changeset.IsRenameChangeset && !isFirstCommitInRepository)
{
    if (renameResult == null || !renameResult.IsProcessingRenameChangeset)
    {
        fetchResult.IsProcessingRenameChangeset = true;
        fetchResult.LastParentCommitBeforeRename = MaxCommitHash;
        return fetchResult;
    }

    renameResult.IsProcessingRenameChangeset = false;
    renameResult.LastParentCommitBeforeRename = null;
}

Version used: current master branch Reproduction: Clone a repository with a changeset that contains a rename checkin. Command: clone (fetch should be affected too but I didn’t tested that) Output: see attachment CloneDebugOutput.txt

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lafecommented, Sep 20, 2016

We have the same issue. In our case, the commit in question was an extensive change in the project architecture and we basically moved everything. The ChangeType value of the changes in the changeset all have a value that starts with 2000 and the root folder with git-Path “” has the value 2080. This causes the method RenameBranchCommmit of the ChangeSieve class to return true, because the value 2080 encodes the delete flag:

0000 1000 0010 0000     Value stored in changeset (2080; 0x0820)
0000 0000 0001 0000     Rename (0x0010)
0000 0000 0010 0000     Delete (0x0020)
0000 1000 0000 0000     SourceRename (0x0800)

As you can see, the other flag is set for SourceRename which is mentioned in Microsoft’s documentation of the ChangeType but is not yet included in the ChangeType enumeration of git tfs. The value 0x800 has been determined by looking into the Microsoft.TeamFoundation.VersionControl.Client assembly using dotPeek.

I temporarily modified the code of the RenameBranchCommmit class to this:

public bool RenameBranchCommmit
        {
            get
            {
                if (!_renameBranchCommmit.HasValue)
                {
                    _renameBranchCommmit = NamedChanges.Any(c =>
                        c.Change.Item.ItemType == TfsItemType.Folder
                            && c.GitPath == string.Empty
                            && c.Change.ChangeType.IncludesOneOf(TfsChangeType.Delete, TfsChangeType.Rename)
                            && !c.Change.ChangeType.IncludesOneOf(TfsChangeType.SourceRename));
                }
                return _renameBranchCommmit.Value;
            }
        }

(I also added SourceRename to the TfsChangeTypeEnum)

With this change, I was able to check out everything, however the changes performed in this problematic commit are not applied (so in our case, we have new and old code folders in the same directory).

I performed the analysis with the current master branch. The aforementioned pull request did not resolve the issue.

0reactions
MrBigDog2Ucommented, Jun 8, 2017

We have encountered this same (or at least a related) issue. In our case, we moved several folders between TFS folders but made no other changes to the files. Git tfs clone did not pick up the folders that got moved into the new area.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git - Does renaming remote repo affect cloned repo?
2 Answers. Renaming shouldn't have an impact on the connection between your local and the remote repository.
Read more >
Git - git-clone Documentation
Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch -- ......
Read more >
How to rename a Git repository's folder on my computer ...
Looks like you are asking about folder where git maps your branches if that is the case then you can clone another branch...
Read more >
Git happens! 6 Common Git mistakes and how to fix them
When working on an existing project, you can use the clone command to create a copy of your remote rep in GitLab and...
Read more >
Change a directory name in a Github repository remotely ...
So let's start by cloning the git repository first: ... then push these changes to the remote copy of the repository, in this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found