0

I've cloned a git repo in a new build folder with phing. Now I try to delete the .git-folder from my cloned repo with

<target name="clean">
    <delete dir="${builddir}" failonerror="true"/>
</target>

But when I do that the task fail with this error message. I'm using Win 7 with xampp 1.8.3

build.xml:39:26: Unable to delete file C:\xampp\htdocs\build\xxx\.git\objects\00\0ffcba3ef0570b9ca0a89214e25c8e762427ff: FileSystem::unlink() FAILED. Cannot unlink 'C:\xampp\htdocs\build\xxx\.git\objects\00\0ffcba3ef0570b9ca0a89214e25c8e762427ff'.

Has anybody an idea?

Thanks!

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
Gerrit
  • 2,515
  • 5
  • 38
  • 63

1 Answers1

1

The solution is to change file permissions inside .git subdirectories By default files .git/objects/pack have read-only permissions (ls -l from cygwin showing -r--r--r-- permissions for *.idx and *.pack files)

Next piece of code worked for me

<target name="clean">
    <chmod mode="0777">
        <fileset dir="${targetdir}" defaultexcludes="false">
            <include name="**/.git/**" />
        </fileset>
    </chmod>
    <delete includeemptydirs="true">
        <fileset dir="${targetdir}" defaultexcludes="false">
            <include name="**/*" />
        </fileset>
    </delete>
</target>