git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] .gitattributes: set file type for C files

From
René Scharfe <l.s.r@web.de>
Date
Jul 7, 2016, 20:11 UTC
Message-ID
<577EB786.7020806@web.de>

Set the diff attribute for C source file to "cpp" in order to improve git's ability to determine hunk headers. In particular it helps avoid showing unindented labels in hunk headers. That in turn is useful for git diff -W and git grep -W, which show whole functions now instead of stopping at a label.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 .gitattributes | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitattributes b/.gitattributes
index 5e98806..320e33c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,3 @@
 * whitespace=!indent,trail,space
-*.[ch] whitespace=indent,trail,space
+*.[ch] whitespace=indent,trail,space diff=cpp
 *.sh whitespace=indent,trail,space
-- 
2.9.0
Message 1 of 1 in “.gitattributes: set file type for C files”
  1. .gitattributes: set file type for C filesRené Scharfe, Jul 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.