Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have prepared a "patch" to my customer who will need to manually apply it to their code. If patch is applied partially due to conflicts then the whole procedure needs to be immediately reversed.

I wonder if there is a argument or a small script I can send them which performs atomic patch application.

Thanks.

share|improve this question
add comment

3 Answers 3

git apply can be used for this. It does not require a Git repository.

share|improve this answer
    
my client has some ridiculous security regulation and extra software may not be installed without authorization, and git is extra. I tried to talk some sense, but it's not up to me. –  romaninsh Jan 17 '12 at 15:37
    
@romaninsh Oh well. But "It's good enough for the kernel developers" might be a convincing argument. (It was made by kernel developers.) –  grawity Jan 17 '12 at 15:38
    
Im quite sure if it would go through security review they would consider it as safe as curl, but they does not want to go through the procedure just because of me. And I deal with people who can't do much about it. –  romaninsh Jan 17 '12 at 15:46
add comment

I don't know what and how many files need to be patched. My favorite doing would be:

  • make a copy of the working project and apply the patch to the copy

  • was the patch successful? does the copy work? then move the working project to project.old and the copy to project

share|improve this answer
    
Instead of "project.old", better use programs designed specifically for that; namely a version control system such as git, hg, svn. –  grawity Jan 17 '12 at 14:29
    
I think that's what is happening right now. I'm supplying list of files and they copy them one by one over the top of old ones. –  romaninsh Jan 17 '12 at 15:38
add comment

I resolved this with the following:

patch -f --dry-run < p  && patch -f < p >/dev/null || echo "Failed to patch"

If patch application is unsuccessful during the dry-run, it does not apply anything and provides user with the output he can send back to me.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.