Here is some parts from a diff file generated using git diff HEAD
.
@@ -261,6 +261,13 @@ public class JSONServiceAction extends JSONAction {
return new double[0][0];
}
}
+ /*
+ * Some changes made...
+ */
else if (typeNameOrClassDescriptor.equals("[[F")) {
String[] values = request.getParameterValues(parameter);
@@ -587,4 +594,4 @@ public class JSONServiceAction extends JSONAction {
private Map<String, Object[]> _methodCache =
new HashMap<String, Object[]>();
-}
\ No newline at end of file
+}
I have two problems with this:
- look at the hunk header lines, there is a
public class ...
after the@@
. Sogit diff
is putting the code block name (here is a class defination) in the hunk header. Why isgit diff
doing this? Can I askgit diff
not to put that part in the hunk header? - Look at the second hunk part. It shows the last few lines of the class file, which is not modified at all. Why is
git diff
including this part in the diff file? Can I avoid it? (Actually the only modified part of this class is in the first hunk area, where I added three lines of comments before theelse if
)
I checked the git diff
man page, but now I am still confusing because I don't quite understand some part of the manual; I also checked some related questions that SO recommended, but they are all about "HOW TO SHOW A METHOD NAME HERE INSTEAD OF A CLASS NAME", like this: Is there a way to ask git diff to show the method name instead of the class name?.
If there is not a method to disable the custom hunk head, please tell me as well so that I can try with some scripting.
Update: The reason why I want the hunk description off
In my job, the benchmark test, one step in the build script is to automatically collect the codebase info of the source folder if it is a svn working copy -- the info includes a diff file. Now we want it to support git. Of course we will save a pure-git diff file, however, we have to generate a svn-compitable diff at the same time. This is because the developers use git and the QAs (testers) use svn (the manager migrates reviewed code only from git to svn).
For the SVN client, (SmartSVN, which is not smart at all) in my work environment, it doesn't matter whether the diff file has certain SVN information lines. It does matter that the file path doesn't have a prefix, and the hunk header doesn't have a description...