7.5. Patches Generated with Subversion
If you read
Chapter 4, Getting the Code about source control management, you may recall seeing a similar diff displayed by using the
svn diff
command. If you make changes to your working copy of a Subversion repository, you are able to see those changes compared to the latest revision you have checked out by running the
svn diff
command. The format output by
svn
is similar to what the
diff -u
command generates, however,
svn
is comparing revisions of the same file instead of two different files. If you were using Subversion in the first example above, the output from
svn diff
would look similar to this:
$ svn diff
Index: hello.c
===================================================================
--- hello.c (revision 1)
+++ hello.c (working copy)
@@ -5,6 +5,6 @@
#include <stdio.h>
int main() {
- printf("Hello, World.\n");
+ printf("Hello, World!\n");
return 0;
}
Notice that the lines representing the file names in the svn diff
output appear slightly different than what you saw from the diff -u
command. In this case, you are comparing your current working copy to revision 1 of the repository. Other than that, the output should look very similar. As with the diff
command, you can redirect the output of svn diff
to create a patch file.
$ svn diff > hello-excitement.patch
When using Subversion or another SCM, you generally want to create patches against the latest HEAD
code from the repository. This means that you should run svn update
or similar before creating your patch. This makes it easier for the project's maintainers to include your patch once you submit it.