0

When I check out for example the git repository https://github.com/rust-lang/stdarch.git (taken at random from github) and then do

git diff eaee02ffdf5d820729ccdf2f95fa08b08c7d24d2^ eaee02ffdf5d820729ccdf2f95fa08b08c7d24d2

to view a commit, I get something starting with

diff --git a/crates/core_arch/src/core_arch_docs.md b/crates/core_arch/src/core_arch_docs.md
index 58b7eda9..eddd1fc0 100644
--- a/crates/core_arch/src/core_arch_docs.md
+++ b/crates/core_arch/src/core_arch_docs.md
@@ -194,18 +194,18 @@ others at:
 * [`nvptx`]
 * [`wasm32`]
 
-[`x86`]: x86/index.html
-[`x86_64`]: x86_64/index.html
-[`arm`]: arm/index.html
-[`aarch64`]: aarch64/index.html
-[`riscv32`]: riscv32/index.html
-[`riscv64`]: riscv64/index.html
-[`mips`]: mips/index.html
-[`mips64`]: mips64/index.html
-[`powerpc`]: powerpc/index.html
-[`powerpc64`]: powerpc64/index.html
-[`nvptx`]: nvptx/index.html
-[`wasm32`]: wasm32/index.html
+[`x86`]: ../../core/arch/x86/index.html
+[`x86_64`]: ../../core/arch/x86_64/index.html
+[`arm`]: ../../core/arch/arm/index.html
+[`aarch64`]: ../../core/arch/aarch64/index.html

I'm wondering about the text after the second @@ in the fifth line (in this case others at:). From other examples I had the impression that most of the time it's the line immediately preceding the quoted text block, but in this specific case, looking at the file shows us that it's not the line immediately preceding the block, in fact 14 lines further up.

What's the point of the text after the @@ in general? Is it maybe to have something easily fulltext-searchable in a large file? Is it maybe documented somewhere?

user313032
  • 604
  • 1
  • 7
  • 18
  • 1
    I think it's specific to whatever program `git diff` uses to generate the diff. `git help diff` only documents what the *number* of `@` bracketing the chunk header means; it doesn't say anything about text following it. – chepner Feb 09 '22 at 22:01
  • 1
    "*The optional header shows the C function where each change occurs, if it is a C file, … or the equivalent, if any, for other types of files.*" – phd Feb 09 '22 at 22:10
  • @phd thanks for your answer. I wouldn't have minded some more details if the question hadn't been closed ... – user313032 Feb 09 '22 at 22:21
  • 1
    There *is* documentation for how to tell Git how to create the text-after-@@. It is buried in [the gitattributes documentation](https://git-scm.com/docs/gitattributes); search for "custom hunk-header". – torek Feb 10 '22 at 00:13
  • Thanks @torek! Now that I know that it's called "hunk header", it's easier to google for [more info](https://stackoverflow.com/questions/28111035/where-does-the-excerpt-in-the-git-diff-hunk-header-come-from) – user313032 Feb 10 '22 at 00:22
  • I still think this should be reopened. The cited question is more general and doesn't ask my specific issue, and the top answer doesn't address it either. Only a later answer has a side remark giving a hint. I'm sure more people are wondering about the same thing, and having an easily googleable explanation would help – user313032 Feb 10 '22 at 17:19

0 Answers0