bugGNU patch - Bugs: bug #28367, NEW filename always used even when...

 
 

bug #28367: NEW filename always used even when not best name

Submitted by:  Tim Waugh <twaugh>
Submitted on:  Mon 21 Dec 2009 04:39:25 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Andreas Gruenbacher <agruen>
Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 24 Dec 2009 02:07:03 PM UTC, comment #2:

Thanks, that fixes it.

Tim Waugh <twaugh>
Tue 22 Dec 2009 11:26:54 PM UTC, comment #1:

Could you please have a look at patch-2.6-4-ge2218ac.tar.gz in ftp://alpha.gnu.org/gnu/patch/? This version does not exhibit the bug anymore.

(Disclaimer: this part of the code is horrible, and I may have broken something else this time without noticing.)

Andreas Gruenbacher <agruen>
Project AdministratorIn charge of this item.
Mon 21 Dec 2009 04:39:25 PM UTC, original submission:

When a patch adds a new file, the NEW (+++) filename is always used even if it is not the "best" name as defined by the POSIX algorithm.

Original bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=549122

How to reproduce:
rm -rf a b
mkdir a b
touch a/file
echo content > b/file.new
diff -u a/file b/file.new > test.patch
mkdir c
cd c
patch -p1 -i ../test.patch
ls

Actual result:
file.new

Expected result:
file

Here's what the patch header looks like:

--- a/file
+++ b/file.new

Let's walk through the algorithm:

  • both names have sufficient pathname components to satisfy '-p1', so both are considered
  • there is no Index: line
  • none either OLD nor NEW file exists
  • there are no RCS files around
  • we aren't conforming to POSIX so don't have to prompt to find out the name
  • both OLD and NEW have the same number of pathname components so both are considered
  • the OLD filename has the shortest basename

We're left with only one candidate: OLD, i.e. "a/file". But patch is using NEW i.e. "b/file.new".

Tim Waugh <twaugh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by agruen (Posted a comment)
  • -unavailable- added by twaugh (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 28 Dec 2009 02:45:05 PM UTCagruenStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Tue 22 Dec 2009 11:26:54 PM UTCagruenStatusNone=>In Progress
      Assigned toNone=>agruen

    Back to the top


    Powered by Savane 3.1-cleanup