• mikethescott

    Todd, this turned out to be a*very* timely post for us. I’ve pulled down the source, built it, and can perform a dry run, but running it I get an error (sorry for the wall of text):

    Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.NullReferenceException: Object reference not set to an instance of an object.

    at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult)

    at LibGit2Sharp.Index.RemoveFromIndex(String relativePath)

    — End of inner exception stack trace —

    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)

    at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)

    at LibGitUnite.UniteRepository.Unite(IEnumerable`1 sourcePaths, IEnumerable`1 destinationPaths) in c:Projectsgit-unitesrcLibGitUniteUniteRepository.cs:line 69

    at LibGitUnite.UniteRepository.Unite(String sourcePath, String destinationPath) in c:Projectsgit-unitesrcLibGitUniteUniteRepository.cs:line 43

    at LibGitUnite.GitUnite.Process(String path, Boolean dryrun) in c:Projectsgit-unitesrcLibGitUniteGitUnite.cs:line 64

    at Git.Unite.Program.c__DisplayClass4.b__3(String p) in c:Projectsgit-unitesrcGit.UniteProgram.cs:line 44

    at System.Collections.Generic.List`1.ForEach(Action`1 action)

    at Git.Unite.Program.Main(String[] args) in c:Projectsgit-unitesrcGit.UniteProgram.cs:line 44

    Any insight you could provide would be greatly appreciated!

    • http://www.woodcp.com/ Todd A. Wood

      What command line invocation are you using to specify the working dir? I will clone down the repo and try to reproduce.


      • mikethescott

        Hi. You’re correct. After a dry run picked out the changes it would make, I ran it from the bin/Debug directory with no parameters other than the directory containing the repository:

        C:Projectsgit-unitesrcGit.UnitebinDebug> git.unite C:Projectsmatlab

        and got the stack trace above. Sorry if that wasn’t clear from my description.

        • http://www.woodcp.com/ Todd A. Wood

          It looks like there might be one or more files that simply changing case causes unintended limitations. I pushed up a change to wrap the LibGit2Sharp remove/add to index calls in a try catch. Pull down the changes and see if it identifies the file(s) causing problems with a simple rename.



          • mikethescott

            Sure enough, there’s some files matching that description:

            C:Projectsgit-unitesrcGit.UnitebinDebug>Git.Unite C:Projectsmatlab

            Git.Unite c:Projectsmatlab

            error changing: third_partyapplication_componentsMATLABpmtk3-1nov12demoscatFAdemoAuto.m~ -> Third_PartyApplication_ComponentsMATLABpmtk3-1nov12demoscatFAdemoAuto.m~ [Exception has been thrown by the target of an invocation.]

            … and several (dozen) more…

            they appear to be artifacts of one of my cow-orkers using emacs or the like to edit some of their files;

            The rest of the changes applied, and all of the simple moves were successful. I should be able to manually remove these stragglers on one of our linux machines.

          • http://www.woodcp.com/ Todd A. Wood

            Excellent. Glad I could help you out, and I will try to track down that edge case. By chance, does the catFAdemoAuto.m~ file exist in both directory locations?

          • mikethescott

            It does indeed exist in both locations.

            Thanks for the help!

    • http://www.woodcp.com/ Todd A. Wood

      The error ‘at LibGitUnite.GitUnite.Process(String path, Boolean dryrun) in c:Projectsgit-unitesrcLibGitUniteGitUnite.cs:line 64′ suggets it was not a –dry-run.

      I cloned it down, did a ‘build.bat’ and ran a dry run against the repo itself i.e.

      C:Projectsgit-unite [master]> .srcGit.UnitebinDebugGit.Unite.exe C:Projectsgit-unite –dry-run

      Let me know your command line parms and thanks for looking into the util. Hope it helps.

  • http://twitter.com/andrewwlane Andrew Lane

    Helped us out a ton!

    • http://www.woodcp.com/ Todd A. Wood

      Thanks for the feedback and glad I could help out. All Win.

  • philipoakley

    Hi in http://stackoverflow.com/questions/16863012/how-safely-remove-entry-from-git-tree a user reports that the script can create an extra ‘.’ directory, which is then hidden. Probably a special case, but worth noting.

    • http://www.woodcp.com/ Todd A. Wood

      Thanks for the heads up and I am looking into this.

  • vchandru


  • SkippyDuck

    Thanks. This helped me a lot.

    It would be even better for me if unite had the ability to determine casing from a branch in git instead of the local filesystem.

    In my workplace our only “official” repository is TFS. I use git-tf (from Microsoft) to initially clone TFS repositories to git, and fetch periodically to keep my git repositories up to date.

    The latest TFS shows up as a remote branch origin_tfs/tfs.

    I do all of my work on a different branch and periodically merging from the origin_tfs/tfs into my local branch.

    When I have changes to go back to TFS, I push to a shelve set in TFS, then merge to TFS from there.

    It causes grief when casing is changed in the TFS repository.

    If I could base casing on the origin_tfs/tfs branch it should eliminate most if not all of my issues. I’ve been looking at the git-unite sources (well done) and may take it on myself, but I have a bit of a learning curve on libgit2 to get over first.

    • http://www.woodcp.com/ Todd A. Wood

      Git.Unite is basically comparing the git index casing with the Windows OS file system casing. You could try a –dry-run on the git repository with the origin_tfs/tfs branch checked out. Git maintains the index with each branch and changes it when you switch between branches.

      Hope this helps.

Back to top
mobile desktop