Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8332159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:38:38+00:00 2026-06-09T02:38:38+00:00

how do i create a standard patch using diff -u without using a different

  • 0

how do i create a standard patch using diff -u without using a different name for the “new” file?

when i submitted a patch for an Apache project, the committer advised that i don’t need to rename the file when submitting patches. i can somewhat understand how this breaks patching since the name of the “new” file should somehow match the name of the patch target – however they can’t be in the same directory with the same name.

is it okay (for ease of patching) to rename the “old” file, such that i should have used:

diff -u Source-old.java Source.java

instead of:

diff -u Source.java Source-new.java

?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:38:40+00:00Added an answer on June 9, 2026 at 2:38 am

    Given an existing project ‘a’, copy whole project to ‘b’, make changes in ‘b’. Generate diff between original directory and your copied directory.

    E.g., checkout or download project to directory ‘a’, copy to ‘b’:

    $ tree a
    a
    `-- dir
        |-- Bar.java
        `-- Foo.java
    
    $ cp -r a b 
    
    $ tree b
    b
    `-- dir
        |-- Bar.java
        `-- Foo.java
    

    Make changes to ‘b’ (and only ‘b’):

    $ diff -r -s a b
    Files a/dir/Bar.java and b/dir/Bar.java are identical
    Files a/dir/Foo.java and b/dir/Foo.java are identical
    
    $ sed -i  's/Foo.*$/& \/* Change...*\//' b/dir/Foo.java 
    
    $ diff -ruN  a b  | tee a.patch
    diff -ruN a/dir/Foo.java b/dir/Foo.java
    --- a/dir/Foo.java  2012-08-02 18:41:39.444720785 -0700
    +++ b/dir/Foo.java  2012-08-02 18:46:45.319932802 -0700
    @@ -1,2 +1,2 @@
     package dir;
    -public class Foo {}
    +public class Foo {} /* Change...*/
    
    $ gzip a.patch
    

    Another alternative is to store the original source in a temporary, local git repository, then use git’s built-in diff to generate the patch. Or, better, if the original source is using git, then just clone the repo and work directly in the source tree itself, and (still) using git to generate the patch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok , I know the two standard ways to create a new thread and
i have the following function i wrote to create an XML file using Xerces
I've deconstructed a standard WPF button using Blend and have managed to create a
I've been using Doctrine in my project without explicitly namespacing any of my classes.
I'm trying to create a standard two-column form, where the first column is a
I'm trying to create a standard way of rolling out web applications for our
I'm trying to convert datetime2 to datetime in order to create a standard between
The standard way to share a Haskell library with other programmers is to create
I can create and use dynamic two dimensional array in Fortran (in 77 standard).
Anyone know if there is a standard way to create a List from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.