> Date: Mon, 06 Jan 2014 17:31:39 +0000
> From: lf...@cruziero.com (akhiezer)
> To: LFS Support List <lfs-support@linuxfromscratch.org>
> Subject: Re: [lfs-support] Patch delete a directory
>
> > From: "Parmenides" <mobile.parmeni...@gmail.com>
> > To: <lfs-support@linuxfromscratch.org>
> > Date: Tue, 7 Jan 2014 01:10:55 +0800
> > Subject: [lfs-support] Patch delete a directory
> >
> >
> >
> > Hi,
> >
> >     I am not sure whether I should ask this quesiton here. I am trying 
> > 'diff' and 'patch', and have encounter a problem.
> >
> >     I have create two directories as follows:
> >
> > old
> > |-- musician
> > |   `-- name
> > `-- writer
> >
> > new
> > |-- musician
> > |   `-- name
> > `-- writer
> >     `-- name
> >
>
>
> Is writer/name an empty file, or what? Can you post:
> $ tree -apugsDF old new 
>
>
> > Then,  'diff' is used to compare the two directories and generated a diff.
> >
> >                             diff -Nru old new > patch.diff
> >
>
>
> Can you post what patch.diff contains?
>
>
> Any particular reason why you don't include '-a' flag? (e.g.
> 'LC_ALL=C TZ=UTC0 diff -Naur old new' per recommended format in patch 
> man-page. )
>
>
> > Then, 'patch' is used to make 'old' identical to 'new'.
> >
> >                             patch -p1 --dir old < patch.diff
> >
> > In the following, I want to 'old' revert to its origin:
> >
> >                             patch -p1 -R --dir old < patch.diff
> >
> > The structruct of 'old' has turn to the following:
> >
> >
> > old
> > `-- musician
> >     `-- name
> >
> > It obvious that a subdirectory 'writer' has disappeared. I wonder some way 
> > to keep 'writer' from being deleted. Thx.
>


If you're hitting patch's '-E' behaviour (
" -E  or  --remove-empty-files
Remove output files that are empty after the patches have been applied.
Normally this  option  is unnecessary,  since  patch  can  examine the 
time stamps on the header to determine whether a file should exist after 
patching.  However, if the input is not a context diff or if patch is  
conform-ing  to  POSIX, patch does not remove empty patched files unless 
this option is given.  When patch removes a file, it also attempts to 
remove any empty ancestor directories. "
),
then I s'ppose a really gross hack could be to use mktemp to create a 
temp-file inside old/writer/ dir, perhaps shovelling some dummy data 
into it (so that it's not an empty file), and remove it later (having 
captured the name/path of the temp-file from the output of mktemp earlier).


However, I'd first check for a better way - perh involving the above 
man-page stuff re time-stamps &/or patch-format &/or posix.



rgds,
akh







--
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to