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 6965127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:00:49+00:00 2026-05-27T16:00:49+00:00

Here is some parts from a diff file generated using git diff HEAD .

  • 0

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:

  1. look at the hunk header lines, there is a public class ... after the @@. So git diff is putting the code block name (here is a class defination) in the hunk header. Why is git diff doing this? Can I ask git diff not to put that part in the hunk header?
  2. 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 the else 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…

  • 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-05-27T16:00:50+00:00Added an answer on May 27, 2026 at 4:00 pm
    1. Git’s putting those block names to make it easier for humans to determine which part of the file a given patch is affecting. In case of C it show a first line of a function definition, which is really useful. Apparently it’s slightly less informative in case of Java. Why does it trouble you?
    2. You have added or removed a newline character at the end of the file. Git treats it as a difference. Hence it’s listed in the diff.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to delete parts from a binary file, using C++. The binary
I'm trying to extract data from a data file that's tab-delimited (in some parts),
Here's some background on what I'm trying to do: Open a serial port from
I'm trying to parse UTF-8 XML file and save some parts of it to
I have a search class that I am using to fetch results from two
Here is some code I could not get to format properly in markdown, this
Here is some simple Perl to count the number of times a value occurs
Here's some Ruby code: puts %x{ pstree #{$$} } # never forks puts %x{
Here's some code I saw once. Can you see what's wrong with it? [updated]
Here is some XAML <HierarchicalDataTemplate DataType={x:Type data:FolderEntity} ItemsSource={Binding Path=FolderEntities,UpdateSourceTrigger=PropertyChanged}> <Label Content={Binding FolderName}/> </HierarchicalDataTemplate> <TreeView/>

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.