{"thread":{"id":"8937","subject":"[PATCH] Document custom hunk header selection","startedAt":"2007-07-09T00:14:19Z","lastAt":"2007-07-09T01:09:29Z","messageCount":2,"participants":["Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"46808","messageId":"7vir8uzb50.fsf@assigned-by-dhcp.cox.net","threadId":"8937","inReplyTo":null,"subject":"[PATCH] Document custom hunk header selection","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-09T00:14:19Z","receivedAt":"2007-07-09T00:14:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Since the external interface seems to have stabilized for this\nnew feature, let's document it properly.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/gitattributes.txt |   55 ++++++++++++++++++++++++++++++++++++---\n 1 files changed, 51 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex d3ac9c7..810df07 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -72,8 +72,8 @@ EFFECTS\n -------\n \n Certain operations by git can be influenced by assigning\n-particular attributes to a path.  Currently, three operations\n-are attributes-aware.\n+particular attributes to a path.  Currently, the following\n+operations are attributes-aware.\n \n Checking-out and checking-in\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n@@ -199,7 +199,9 @@ Generating diff text\n ~~~~~~~~~~~~~~~~~~~~\n \n The attribute `diff` affects if `git diff` generates textual\n-patch for the path or just says `Binary files differ`.\n+patch for the path or just says `Binary files differ`.  It also\n+can affect what line is shown on the hunk header `@@ -k,l +n,m @@`\n+line.\n \n Set::\n \n@@ -224,7 +226,8 @@ String::\n \tDiff is shown using the specified custom diff driver.\n \tThe driver program is given its input using the same\n \tcalling convention as used for GIT_EXTERNAL_DIFF\n-\tprogram.\n+\tprogram.  This name is also used for custom hunk header\n+\tselection.\n \n \n Defining a custom diff driver\n@@ -249,6 +252,50 @@ parameters, just like `GIT_EXTERNAL_DIFF` program is called.\n See gitlink:git[7] for details.\n \n \n+Defining a custom hunk-header\n+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n+\n+Each group of changes (called \"hunk\") in the textual diff output\n+is prefixed with a line of the form:\n+\n+\t@@ -k,l +n,m @@ TEXT\n+\n+The text is called 'hunk header', and by default a line that\n+begins with an alphabet, an underscore or a dollar sign is used,\n+which matches what GNU `diff -p` output uses.  This default\n+selection however is not suited for some contents, and you can\n+use customized pattern to make a selection.\n+\n+First in .gitattributes, you would assign the `diff` attribute\n+for paths.\n+\n+------------------------\n+*.tex\tdiff=tex\n+------------------------\n+\n+Then, you would define \"diff.tex.funcname\" configuration to\n+specify a regular expression that matches a line that you would\n+want to appear as the hunk header, like this:\n+\n+------------------------\n+[diff \"tex\"]\n+\tfuncname = \"^\\\\(\\\\\\\\\\\\(sub\\\\)*section{.*\\\\)$\"\n+------------------------\n+\n+Note.  A single level of backslashes are eaten by the\n+configuration file parser, so you would need to double the\n+backslashes; the pattern above picks a line that begins with a\n+backslash, and zero or more occurences of `sub` followed by\n+`section` followed by open brace, to the end of line.\n+\n+There are a few built-in patterns to make this easier, and `tex`\n+is one of them, so you do not have to write the above in your\n+configuration file (you still need to enable this with the\n+attribute mechanism, via `.gitattributes`).  Another built-in\n+pattern is defined for `java` that defines a pattern suitable\n+for program text in Java language.\n+\n+\n Performing a three-way merge\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n"},{"id":"46810","messageId":"Pine.LNX.4.64.0707090209060.4248@racer.site","threadId":"8937","inReplyTo":"7vir8uzb50.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Document custom hunk header selection","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-09T01:09:29Z","receivedAt":"2007-07-09T01:09:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 8 Jul 2007, Junio C Hamano wrote:\n\n> Since the external interface seems to have stabilized for this\n> new feature, let's document it properly.\n\nAcked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nCiao,\nDscho\n"}]}