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

Re: [PATCH] Improve the "diff --git" format documentation

From
AGAndreas Gruenbacher <agruen@suse.de>
Date
Oct 14, 2010, 10:53 UTC
Message-ID
<201010141253.11640.agruen@suse.de>
In-Reply-To
<7v8w21fsgr.fsf@alter.siamese.dyndns.org>
On Thursday 14 October 2010 03:55:48 Junio C Hamano wrote:
> [some more objections]

Okay, here are the changes we seem to be able to agree on. Let's address the rest separately.

Andreas
--
[PATCH] Clarify and extend the "git diff" format documentation

Move the similarity and dissimilarity index header description closer to where those extended headers are described.

Describe and/or clarify the format used for file modes, pathnames, and the index header.

Document that all "old" files refer to the state before applying the *entire* output, and all "new" files refer to the state thereafter.

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
 Documentation/diff-generate-patch.txt |   40 ++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-
generate-patch.txt
index 8f9a241..3ac2bea 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -9,16 +9,15 @@ patch file.  You can customize the creation of such patches 
via the
 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
 
 What the -p option produces is slightly different from the traditional
-diff format.
+diff format:
 
-1.   It is preceded with a "git diff" header, that looks like
-     this:
+1.   It is preceded with a "git diff" header that looks like this:
 
        diff --git a/file1 b/file2
 +
 The `a/` and `b/` filenames are the same unless rename/copy is
 involved.  Especially, even for a creation or a deletion,
-`/dev/null` is _not_ used in place of `a/` or `b/` filenames.
+`/dev/null` is _not_ used in place of the `a/` or `b/` filenames.
 +
 When rename/copy is involved, `file1` and `file2` show the
 name of the source file of the rename/copy and the name of
@@ -37,18 +36,39 @@ the file that rename/copy produces, respectively.
        similarity index <number>
        dissimilarity index <number>
        index <hash>..<hash> <mode>
-
-3.  TAB, LF, double quote and backslash characters in pathnames
-    are represented as `\t`, `\n`, `\"` and `\\`, respectively.
-    If there is need for such substitution then the whole
-    pathname is put in double quotes.
-
++
+File modes are printed as 6-digit octal numbers including the file type
+and file permission bits.
++
+Path names in extended headers do not include the `a/` and `b/` prefixes.
++
 The similarity index is the percentage of unchanged lines, and
 the dissimilarity index is the percentage of changed lines.  It
 is a rounded down integer, followed by a percent sign.  The
 similarity index value of 100% is thus reserved for two equal
 files, while 100% dissimilarity means that no line from the old
 file made it into the new one.
++
+The index line includes the SHA-1 checksum before and after the change.
+The <mode> is included if the file mode does not change; otherwise,
+separate lines indicate the old and the new mode.
+
+3.  TAB, LF, double quote and backslash characters in pathnames
+    are represented as `\t`, `\n`, `\"` and `\\`, respectively.
+    If there is need for such substitution then the whole
+    pathname is put in double quotes.
+
+4.  All the `file1` files in the output refer to files before the
+    commit, and all the `file2` files refer to files after the commit.
+    It is incorrect to apply each change to each file sequentially.  For
+    example, this patch will swap a and b:
+
+      diff --git a/a b/b
+      rename from a
+      rename to b
+      diff --git a/b b/a
+      rename from b
+      rename to a
 
 
 combined diff format
Previous: Junio C HamanoNext: Andreas Gruenbacher
Message 7 of 10 in “Improve the "diff --git" format documentation”
  1. Improve the "diff --git" format documentationAndreas Gruenbacher, Oct 6, 2010
  2. Junio C HamanoOct 6, 2010
  3. Andreas GruenbacherOct 6, 2010
  4. Andreas GruenbacherOct 11, 2010
  5. Junio C HamanoOct 14, 2010
  6. Junio C HamanoOct 14, 2010
  7. Andreas GruenbacherOct 14, 2010
  8. Andreas GruenbacherOct 14, 2010
  9. Jonathan NiederOct 14, 2010
  10. Junio C HamanoOct 17, 2010

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.