Dennis Allen
Dennis Allen

Reputation: 412

Import using GIT-TF - item already has pending changes

I have two instances of TFS, one 2012 and the other 2013. My goal is to export some source code from the 2012 instance and import it into the 2013 instance, preserving the check in history.

The method I'm employing is;

  1. Install GIT for windows from http://msysgit.github.io
  2. Install git-tf from http://gittf.codeplex.com
  3. Create a local folder for my git repository c:\git
  4. Open a GIT Bash prompt in that folder (so it is current)
  5. $ git tf clone http://old-tfs-host:8080/DefaultCollection $/myProject/myBranch --deep
  6. Delete tf folder and git-tf file
  7. Copy in my USERMAP file
  8. $ git tf configure --deep --keep-author --force http://new-tfs-host:8080/DefaultCollection $/myProject/myBranch
  9. $ git tf pull
  10. $ git commit -a -m "Initial import from TFS 2012"
  11. $ git tf checkin --deep

I get an error after processing about 57%

git-tf: failed to pend changes to TFS due to the following errors. Please fix the errors and retry check in. The item $/path-to-file already has pending changes.

Question - how do I resolve pending changes for the file? No one else is in the repository while I am doing this check-in so it would seem that the export may be corrupted?

I have used this same method for two other branches and have been successful.


EDIT I found that the issue is a file was renamed with the only difference being case. So in the same change I have

  1. delete $/source-file
  2. edit $/project-file
  3. add $/Source-File

Obviously I am renaming them, but the file deleted in line 1 is the same as the file in line 3 with the only difference being file name case.

So I have tried $ git config --global core.ignorecase false but that does not resolve the issue of both deleting and adding the same file in the same change.

Upvotes: 2

Views: 1489

Answers (2)

Marcus Classon
Marcus Classon

Reputation: 153

I had the same problem, which occurs when you delete, add and edit the same file in one changeset.

if you do git tf checkin --preview you will see the details.

I solved it by doing:

git tf checkin --deep --renamemode=none

Upvotes: 4

SliverNinja - MSFT
SliverNinja - MSFT

Reputation: 31651

We had a similar issue with Git-TF when running git tf checkin, tinkering with the renamemode did not work:

failed to pend changes to TFS due to the following errors. Please fix the errors and retry check in

The resolution involved bypassing the pendChanges() check in PendDifferenceTask.java to essentially --force it in.

PendDifferenceTask.java - pendChanges()

if (count < deleteSpecs.length)
{
    log.debug("Failed to pend Delete changes...ignoring count mismatch. Expected: " + deleteSpecs.length + ", Actual: " + count);
    //throw new Exception(Messages.getString("PendDifferencesTask.PendFailed")); //$NON-NLS-1$
}

This change will require a rebuild via maven (mvn package -DskipTests) for quick JAR snapshot creation.

BTW..if you want to enable debugging in Git-TF, update your git-tf.cmd to the following, this helped tremendously:

git-tf.cmd - Enable Logging

java -ea -Xmx512M -Dlog4j.configuration=file:///C:\git-tf\log4j.xml -cp %GITTF_CLASSPATH% "-Dcom.microsoft.tfs.jni.native.base-directory=%BASE_DIRECTORY%native" com.microsoft.gittf.client.clc.Main %*

Then just create a log4j.xml that looks like this:

log4j.xml - Logging Config

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %t %c{1}:%L - %m%n"/>
        </layout>
    </appender>
     <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="mycorp.myapp.log"/>
        <param name="MaxFileSize" value="100000KB"/>
    <!-- Keep one backup file -->
        <param name="MaxBackupIndex" value="4"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %l - %m%n"/>
        </layout>
    </appender>
    <root>
        <level value="debug"/>
        <!--<appender-ref ref="stdout"/>-->
        <appender-ref ref="FILE"/>
    </root>
</log4j:configuration>

If you want to graphically view your TF changesets on windows - I suggest installing Atlassian sourcetree - it made troubleshooting much easier than git log.

Sourcetree - Git Branch Visualizer

enter image description here

Upvotes: 1

Related Questions