Bug 44549 - Delete with an empty includesfile deletes all files
Summary: Delete with an empty includesfile deletes all files
Status: NEEDINFO
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-06 11:04 UTC by andy kriger
Modified: 2016-03-04 08:22 UTC (History)
1 user (show)



Attachments
The patch avoids the inclusion of implicit files that leads to the loss of unexpected files (1.70 KB, patch)
2008-12-13 17:29 UTC, Inta
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description andy kriger 2008-03-06 11:04:43 UTC
If you use a delete task with a fileset using an empty includesfile, Ant deletes all files in the given directory.

<target name="deleteTest">
   <delete>
      <fileset dir="c:\temp" includesfile="c:\temp\empty.txt"/>
   </delete>
</target>

In the above target, empty.txt has no patterns in it and all files in c:\temp are  deleted.

The Ant docs state that 'all files are included when [includes is] omitted'. In this case, since an includesfile is used, the expectation is that only patterns in the includesfile will be applied. Since there are no patterns in the file, nothing should be applied. The default behavior for includes should be treated as a separate case. 

For the sake of the user's data, greedy delete is a bad idea.
I've marked this critical because of the unexpected data loss.
Comment 1 Inta 2008-12-13 17:29:44 UTC
Created attachment 23016 [details]
The patch avoids the inclusion of implicit files that leads to the loss of unexpected files

Attached is a possible patch to the bug.
Comment 2 Pepper LebeckJobe 2016-03-04 08:22:34 UTC
I disagree that this is a bug. It works exactly as I would expect. includesfile is basically just shorthand for a list of <include /> elements. If the file is empty it is as though the user didn't supply any <include /> elements. Therefore, the entire FileSet should be deleted.

What are you trying to achieve by supplying an empty includesfile? I don't understand the use-case at all.