I'm trying to create patch a file using diff tool.But facing an issues.The way I am doing is below.
I've created one Directory named a and put original file in to it.
a/original_file.c
Now I have created other Directory named b and put same file with modified content in to it.
b/original_file.c
Now content of b/original_file.c
file I have copied from internet and put it into some text editor.
After giving command: diff -Naur a b > patch_file.patch
, the file patch_file.patch
is generated and it has some unwanted changes (its related to indentation).
For example:
return mg_nw (MG_READY_NOY, &rmsg, seqnr,
- sizeof (struct mg_rdy_notify));
+ sizeof (struct mg_rdy_notify));
Now you can see there are changed related to indentation where sizeof (struct mg_rdy_notify))
is replaced by same sizeof (struct mg_rdy_notify))
but one basis of indentation which is what we don't want.
Best Answer
diff
has more than one option related to whitespace. However, one is less useful for patches. The manual page gives an obscure hint, referring to both GNU:and FreeBSD
Usually one uses
-b
, because that is less likely to overlook significant changes. If you have changed only indentation, then both-b
and-w
give the same result. On the other hand, if you inserted spaces where there were none, or deleted existing spaces (leaving none), that could be a change in your program. Here is an example:In this case, the
-w
option allows you to ignore the change to thesetlocale
parameter (perhaps not what was intended).POSIX diff, by the way, has only the
-b
option.For
patch
, POSIX documents the-l
option: