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

 
 

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

Submitter:  Tim Waugh <twaugh>
Submitted:  Mon 21 Dec 2009 04:39:25 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  agruen
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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

Thanks, that fixes it.

Tim Waugh <twaugh>
Group Member
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>
Group administrator
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>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-12-28 agruen StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2009-12-22 agruen StatusNone In Progress
        Assigned toNone agruen

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code