logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-diff-index.1 (58350B)


  1. '\" t
  2. .\" Title: git-diff-index
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-DIFF\-INDEX" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-diff-index \- Compare a tree to the working tree or index
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit diff\-index\fR [\-m] [\-\-cached] [\-\-merge\-base] [<common\-diff\-options>] <tree\-ish> [<path>\&...\:]
  36. .fi
  37. .SH "DESCRIPTION"
  38. .sp
  39. Compare the content and mode of the blobs found in a tree object with the corresponding tracked files in the working tree, or with the corresponding paths in the index\&. When <path> arguments are present, compare only paths matching those patterns\&. Otherwise all tracked files are compared\&.
  40. .SH "OPTIONS"
  41. .PP
  42. \fB\-p\fR, \fB\-u\fR, \fB\-\-patch\fR
  43. .RS 4
  44. Generate patch (see
  45. the section called \(lqGENERATING PATCH TEXT WITH \-P\(rq)\&.
  46. .RE
  47. .PP
  48. \fB\-s\fR, \fB\-\-no\-patch\fR
  49. .RS 4
  50. Suppress all output from the diff machinery\&. Useful for commands like
  51. \fBgit\fR
  52. \fBshow\fR
  53. that show the patch by default to squelch their output, or to cancel the effect of options like
  54. \fB\-\-patch\fR,
  55. \fB\-\-stat\fR
  56. earlier on the command line in an alias\&.
  57. .RE
  58. .PP
  59. \fB\-U\fR\fI<n>\fR, \fB\-\-unified=\fR\fI<n>\fR
  60. .RS 4
  61. Generate diffs with
  62. \fI<n>\fR
  63. lines of context instead of the usual three\&. Implies
  64. \fB\-\-patch\fR\&.
  65. .RE
  66. .PP
  67. \fB\-\-output=\fR\fI<file>\fR
  68. .RS 4
  69. Output to a specific file instead of stdout\&.
  70. .RE
  71. .PP
  72. \fB\-\-output\-indicator\-new=\fR\fI<char>\fR, \fB\-\-output\-indicator\-old=\fR\fI<char>\fR, \fB\-\-output\-indicator\-context=\fR\fI<char>\fR
  73. .RS 4
  74. Specify the character used to indicate new, old or context lines in the generated patch\&. Normally they are
  75. \fB+\fR,
  76. \fB\-\fR
  77. and \*(Aq \*(Aq respectively\&.
  78. .RE
  79. .PP
  80. \fB\-\-raw\fR
  81. .RS 4
  82. Generate the diff in raw format\&. This is the default\&.
  83. .RE
  84. .PP
  85. \fB\-\-patch\-with\-raw\fR
  86. .RS 4
  87. Synonym for
  88. \fB\-p\fR
  89. \fB\-\-raw\fR\&.
  90. .RE
  91. .PP
  92. \fB\-\-indent\-heuristic\fR
  93. .RS 4
  94. Enable the heuristic that shifts diff hunk boundaries to make patches easier to read\&. This is the default\&.
  95. .RE
  96. .PP
  97. \fB\-\-no\-indent\-heuristic\fR
  98. .RS 4
  99. Disable the indent heuristic\&.
  100. .RE
  101. .PP
  102. \fB\-\-minimal\fR
  103. .RS 4
  104. Spend extra time to make sure the smallest possible diff is produced\&.
  105. .RE
  106. .PP
  107. \fB\-\-patience\fR
  108. .RS 4
  109. Generate a diff using the "patience diff" algorithm\&.
  110. .RE
  111. .PP
  112. \fB\-\-histogram\fR
  113. .RS 4
  114. Generate a diff using the "histogram diff" algorithm\&.
  115. .RE
  116. .PP
  117. \fB\-\-anchored=\fR\fI<text>\fR
  118. .RS 4
  119. Generate a diff using the "anchored diff" algorithm\&.
  120. .sp
  121. This option may be specified more than once\&.
  122. .sp
  123. If a line exists in both the source and destination, exists only once, and starts with
  124. \fI<text>\fR, this algorithm attempts to prevent it from appearing as a deletion or addition in the output\&. It uses the "patience diff" algorithm internally\&.
  125. .RE
  126. .PP
  127. \fB\-\-diff\-algorithm=\fR(\fBpatience\fR|\fBminimal\fR|\fBhistogram\fR|\fBmyers\fR)
  128. .RS 4
  129. Choose a diff algorithm\&. The variants are as follows:
  130. .PP
  131. \fBdefault\fR, \fBmyers\fR
  132. .RS 4
  133. The basic greedy diff algorithm\&. Currently, this is the default\&.
  134. .RE
  135. .PP
  136. \fBminimal\fR
  137. .RS 4
  138. Spend extra time to make sure the smallest possible diff is produced\&.
  139. .RE
  140. .PP
  141. \fBpatience\fR
  142. .RS 4
  143. Use "patience diff" algorithm when generating patches\&.
  144. .RE
  145. .PP
  146. \fBhistogram\fR
  147. .RS 4
  148. This algorithm extends the patience algorithm to "support low\-occurrence common elements"\&.
  149. .RE
  150. .sp
  151. For instance, if you configured the
  152. \fBdiff\&.algorithm\fR
  153. variable to a non\-default value and want to use the default one, then you have to use
  154. \fB\-\-diff\-algorithm=default\fR
  155. option\&.
  156. .RE
  157. .PP
  158. \fB\-\-stat\fR[\fB=\fR\fI<width>\fR[\fB,\fR\fI<name\-width>\fR[\fB,\fR\fI<count>\fR]]]
  159. .RS 4
  160. Generate a diffstat\&. By default, as much space as necessary will be used for the filename part, and the rest for the graph part\&. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by
  161. \fI<width>\fR\&. The width of the filename part can be limited by giving another width
  162. \fI<name\-width>\fR
  163. after a comma or by setting
  164. \fBdiff\&.statNameWidth=\fR\fI<name\-width>\fR\&. The width of the graph part can be limited by using
  165. \fB\-\-stat\-graph\-width=\fR\fI<graph\-width>\fR
  166. or by setting
  167. \fBdiff\&.statGraphWidth=\fR\fI<graph\-width>\fR\&. Using
  168. \fB\-\-stat\fR
  169. or
  170. \fB\-\-stat\-graph\-width\fR
  171. affects all commands generating a stat graph, while setting
  172. \fBdiff\&.statNameWidth\fR
  173. or
  174. \fBdiff\&.statGraphWidth\fR
  175. does not affect
  176. \fBgit\fR
  177. \fBformat\-patch\fR\&. By giving a third parameter
  178. \fI<count>\fR, you can limit the output to the first
  179. \fI<count>\fR
  180. lines, followed by \&.\&.\&. if there are more\&.
  181. .sp
  182. These parameters can also be set individually with
  183. \fB\-\-stat\-width=\fR\fI<width>\fR,
  184. \fB\-\-stat\-name\-width=\fR\fI<name\-width>\fR
  185. and
  186. \fB\-\-stat\-count=\fR\fI<count>\fR\&.
  187. .RE
  188. .PP
  189. \fB\-\-compact\-summary\fR
  190. .RS 4
  191. Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally
  192. \fB+l\fR
  193. if it\(cqs a symlink) and mode changes (\fB+x\fR
  194. or
  195. \fB\-x\fR
  196. for adding or removing executable bit respectively) in diffstat\&. The information is put between the filename part and the graph part\&. Implies
  197. \fB\-\-stat\fR\&.
  198. .RE
  199. .PP
  200. \fB\-\-numstat\fR
  201. .RS 4
  202. Similar to
  203. \fB\-\-stat\fR, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly\&. For binary files, outputs two
  204. \fB\-\fR
  205. instead of saying
  206. \fB0\fR
  207. \fB0\fR\&.
  208. .RE
  209. .PP
  210. \fB\-\-shortstat\fR
  211. .RS 4
  212. Output only the last line of the
  213. \fB\-\-stat\fR
  214. format containing total number of modified files, as well as number of added and deleted lines\&.
  215. .RE
  216. .PP
  217. \fB\-X\fR [\fI<param>\fR\fB,\&.\&.\fR\&.], \fB\-\-dirstat\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
  218. .RS 4
  219. Output the distribution of relative amount of changes for each sub\-directory\&. The behavior of
  220. \fB\-\-dirstat\fR
  221. can be customized by passing it a comma separated list of parameters\&. The defaults are controlled by the
  222. \fBdiff\&.dirstat\fR
  223. configuration variable (see
  224. \fBgit-config\fR(1))\&. The following parameters are available:
  225. .PP
  226. \fBchanges\fR
  227. .RS 4
  228. Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination\&. This ignores the amount of pure code movements within a file\&. In other words, rearranging lines in a file is not counted as much as other changes\&. This is the default behavior when no parameter is given\&.
  229. .RE
  230. .PP
  231. \fBlines\fR
  232. .RS 4
  233. Compute the dirstat numbers by doing the regular line\-based diff analysis, and summing the removed/added line counts\&. (For binary files, count 64\-byte chunks instead, since binary files have no natural concept of lines)\&. This is a more expensive
  234. \fB\-\-dirstat\fR
  235. behavior than the
  236. \fBchanges\fR
  237. behavior, but it does count rearranged lines within a file as much as other changes\&. The resulting output is consistent with what you get from the other
  238. \fB\-\-\fR*stat options\&.
  239. .RE
  240. .PP
  241. \fBfiles\fR
  242. .RS 4
  243. Compute the dirstat numbers by counting the number of files changed\&. Each changed file counts equally in the dirstat analysis\&. This is the computationally cheapest
  244. \fB\-\-dirstat\fR
  245. behavior, since it does not have to look at the file contents at all\&.
  246. .RE
  247. .PP
  248. \fBcumulative\fR
  249. .RS 4
  250. Count changes in a child directory for the parent directory as well\&. Note that when using
  251. \fBcumulative\fR, the sum of the percentages reported may exceed 100%\&. The default (non\-cumulative) behavior can be specified with the
  252. \fBnoncumulative\fR
  253. parameter\&.
  254. .RE
  255. .PP
  256. \fI<limit>\fR
  257. .RS 4
  258. An integer parameter specifies a cut\-off percent (3% by default)\&. Directories contributing less than this percentage of the changes are not shown in the output\&.
  259. .RE
  260. .sp
  261. Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:
  262. \fB\-\-dirstat=files,10,cumulative\fR\&.
  263. .RE
  264. .PP
  265. \fB\-\-cumulative\fR
  266. .RS 4
  267. Synonym for
  268. \fB\-\-dirstat=cumulative\fR\&.
  269. .RE
  270. .PP
  271. \fB\-\-dirstat\-by\-file\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
  272. .RS 4
  273. Synonym for
  274. \fB\-\-dirstat=files,\fR\fI<param>\fR\fB,\&.\&.\fR\&.\&.
  275. .RE
  276. .PP
  277. \fB\-\-summary\fR
  278. .RS 4
  279. Output a condensed summary of extended header information such as creations, renames and mode changes\&.
  280. .RE
  281. .PP
  282. \fB\-\-patch\-with\-stat\fR
  283. .RS 4
  284. Synonym for
  285. \fB\-p\fR
  286. \fB\-\-stat\fR\&.
  287. .RE
  288. .PP
  289. \fB\-z\fR
  290. .RS 4
  291. When
  292. \fB\-\-raw\fR,
  293. \fB\-\-numstat\fR,
  294. \fB\-\-name\-only\fR
  295. or
  296. \fB\-\-name\-status\fR
  297. has been given, do not munge pathnames and use NULs as output field terminators\&.
  298. .sp
  299. Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable
  300. \fBcore\&.quotePath\fR
  301. (see
  302. \fBgit-config\fR(1))\&.
  303. .RE
  304. .PP
  305. \fB\-\-name\-only\fR
  306. .RS 4
  307. Show only the name of each changed file in the post\-image tree\&. The file names are often encoded in UTF\-8\&. For more information see the discussion about encoding in the
  308. \fBgit-log\fR(1)
  309. manual page\&.
  310. .RE
  311. .PP
  312. \fB\-\-name\-status\fR
  313. .RS 4
  314. Show only the name(s) and status of each changed file\&. See the description of the
  315. \fB\-\-diff\-filter\fR
  316. option on what the status letters mean\&. Just like
  317. \fB\-\-name\-only\fR
  318. the file names are often encoded in UTF\-8\&.
  319. .RE
  320. .PP
  321. \fB\-\-submodule\fR[\fB=\fR\fI<format>\fR]
  322. .RS 4
  323. Specify how differences in submodules are shown\&. When specifying
  324. \fB\-\-submodule=short\fR
  325. the
  326. \fBshort\fR
  327. format is used\&. This format just shows the names of the commits at the beginning and end of the range\&. When
  328. \fB\-\-submodule\fR
  329. or
  330. \fB\-\-submodule=log\fR
  331. is specified, the
  332. \fBlog\fR
  333. format is used\&. This format lists the commits in the range like
  334. \fBgit-submodule\fR(1)
  335. \fBsummary\fR
  336. does\&. When
  337. \fB\-\-submodule=diff\fR
  338. is specified, the
  339. \fBdiff\fR
  340. format is used\&. This format shows an inline diff of the changes in the submodule contents between the commit range\&. Defaults to
  341. \fBdiff\&.submodule\fR
  342. or the
  343. \fBshort\fR
  344. format if the config option is unset\&.
  345. .RE
  346. .PP
  347. \fB\-\-color\fR[\fB=\fR\fI<when>\fR]
  348. .RS 4
  349. Show colored diff\&.
  350. \fB\-\-color\fR
  351. (i\&.e\&. without
  352. \fB=\fR\fI<when>\fR) is the same as
  353. \fB\-\-color=always\fR\&.
  354. \fI<when>\fR
  355. can be one of
  356. \fBalways\fR,
  357. \fBnever\fR, or
  358. \fBauto\fR\&.
  359. .RE
  360. .PP
  361. \fB\-\-no\-color\fR
  362. .RS 4
  363. Turn off colored diff\&. It is the same as
  364. \fB\-\-color=never\fR\&.
  365. .RE
  366. .PP
  367. \fB\-\-color\-moved\fR[\fB=\fR\fI<mode>\fR]
  368. .RS 4
  369. Moved lines of code are colored differently\&. The
  370. \fI<mode>\fR
  371. defaults to
  372. \fBno\fR
  373. if the option is not given and to
  374. \fBzebra\fR
  375. if the option with no mode is given\&. The mode must be one of:
  376. .PP
  377. \fBno\fR
  378. .RS 4
  379. Moved lines are not highlighted\&.
  380. .RE
  381. .PP
  382. \fBdefault\fR
  383. .RS 4
  384. Is a synonym for
  385. \fBzebra\fR\&. This may change to a more sensible mode in the future\&.
  386. .RE
  387. .PP
  388. \fBplain\fR
  389. .RS 4
  390. Any line that is added in one location and was removed in another location will be colored with
  391. \fBcolor\&.diff\&.newMoved\fR\&. Similarly
  392. \fBcolor\&.diff\&.oldMoved\fR
  393. will be used for removed lines that are added somewhere else in the diff\&. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation\&.
  394. .RE
  395. .PP
  396. \fBblocks\fR
  397. .RS 4
  398. Blocks of moved text of at least 20 alphanumeric characters are detected greedily\&. The detected blocks are painted using either the
  399. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
  400. color\&. Adjacent blocks cannot be told apart\&.
  401. .RE
  402. .PP
  403. \fBzebra\fR
  404. .RS 4
  405. Blocks of moved text are detected as in
  406. \fBblocks\fR
  407. mode\&. The blocks are painted using either the
  408. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
  409. color or
  410. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMovedAlternative\fR\&. The change between the two colors indicates that a new block was detected\&.
  411. .RE
  412. .PP
  413. \fBdimmed\-zebra\fR
  414. .RS 4
  415. Similar to
  416. \fBzebra\fR, but additional dimming of uninteresting parts of moved code is performed\&. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting\&.
  417. \fBdimmed_zebra\fR
  418. is a deprecated synonym\&.
  419. .RE
  420. .RE
  421. .PP
  422. \fB\-\-no\-color\-moved\fR
  423. .RS 4
  424. Turn off move detection\&. This can be used to override configuration settings\&. It is the same as
  425. \fB\-\-color\-moved=no\fR\&.
  426. .RE
  427. .PP
  428. \fB\-\-color\-moved\-ws=\fR\fI<mode>\fR\fB,\&.\&.\fR\&.
  429. .RS 4
  430. This configures how whitespace is ignored when performing the move detection for
  431. \fB\-\-color\-moved\fR\&. These modes can be given as a comma separated list:
  432. .PP
  433. \fBno\fR
  434. .RS 4
  435. Do not ignore whitespace when performing move detection\&.
  436. .RE
  437. .PP
  438. \fBignore\-space\-at\-eol\fR
  439. .RS 4
  440. Ignore changes in whitespace at EOL\&.
  441. .RE
  442. .PP
  443. \fBignore\-space\-change\fR
  444. .RS 4
  445. Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
  446. .RE
  447. .PP
  448. \fBignore\-all\-space\fR
  449. .RS 4
  450. Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
  451. .RE
  452. .PP
  453. \fBallow\-indentation\-change\fR
  454. .RS 4
  455. Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line\&. This is incompatible with the other modes\&.
  456. .RE
  457. .RE
  458. .PP
  459. \fB\-\-no\-color\-moved\-ws\fR
  460. .RS 4
  461. Do not ignore whitespace when performing move detection\&. This can be used to override configuration settings\&. It is the same as
  462. \fB\-\-color\-moved\-ws=no\fR\&.
  463. .RE
  464. .PP
  465. \fB\-\-word\-diff\fR[\fB=\fR\fI<mode>\fR]
  466. .RS 4
  467. By default, words are delimited by whitespace; see
  468. \fB\-\-word\-diff\-regex\fR
  469. below\&. The
  470. \fI<mode>\fR
  471. defaults to
  472. \fBplain\fR, and must be one of:
  473. .PP
  474. \fBcolor\fR
  475. .RS 4
  476. Highlight changed words using only colors\&. Implies
  477. \fB\-\-color\fR\&.
  478. .RE
  479. .PP
  480. \fBplain\fR
  481. .RS 4
  482. Show words as [\fB\-removed\-\fR] and {\fBadded\fR}\&. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous\&.
  483. .RE
  484. .PP
  485. \fBporcelain\fR
  486. .RS 4
  487. Use a special line\-based format intended for script consumption\&. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a
  488. \fB+\fR/\fB\-\fR/` ` character at the beginning of the line and extending to the end of the line\&. Newlines in the input are represented by a tilde
  489. \fB~\fR
  490. on a line of its own\&.
  491. .RE
  492. .PP
  493. \fBnone\fR
  494. .RS 4
  495. Disable word diff again\&.
  496. .RE
  497. .sp
  498. Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled\&.
  499. .RE
  500. .PP
  501. \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR
  502. .RS 4
  503. Use
  504. \fI<regex>\fR
  505. to decide what a word is, instead of considering runs of non\-whitespace to be a word\&. Also implies
  506. \fB\-\-word\-diff\fR
  507. unless it was already enabled\&.
  508. .sp
  509. Every non\-overlapping match of the
  510. \fI<regex>\fR
  511. is considered a word\&. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences\&. You may want to append |[\fB^\fR[\fB:space:\fR]] to your regular expression to make sure that it matches all non\-whitespace characters\&. A match that contains a newline is silently truncated(!) at the newline\&.
  512. .sp
  513. For example,
  514. \fB\-\-word\-diff\-regex=\&.\fR
  515. will treat each character as a word and, correspondingly, show differences character by character\&.
  516. .sp
  517. The regex can also be set via a diff driver or configuration option, see
  518. \fBgitattributes\fR(5)
  519. or
  520. \fBgit-config\fR(1)\&. Giving it explicitly overrides any diff driver or configuration setting\&. Diff drivers override configuration settings\&.
  521. .RE
  522. .PP
  523. \fB\-\-color\-words\fR[\fB=\fR\fI<regex>\fR]
  524. .RS 4
  525. Equivalent to
  526. \fB\-\-word\-diff=color\fR
  527. plus (if a regex was specified)
  528. \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR\&.
  529. .RE
  530. .PP
  531. \fB\-\-no\-renames\fR
  532. .RS 4
  533. Turn off rename detection, even when the configuration file gives the default to do so\&.
  534. .RE
  535. .PP
  536. \fB\-\-\fR[\fBno\-\fR]\fBrename\-empty\fR
  537. .RS 4
  538. Whether to use empty blobs as rename source\&.
  539. .RE
  540. .PP
  541. \fB\-\-check\fR
  542. .RS 4
  543. Warn if changes introduce conflict markers or whitespace errors\&. What are considered whitespace errors is controlled by
  544. \fBcore\&.whitespace\fR
  545. configuration\&. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors\&. Exits with non\-zero status if problems are found\&. Not compatible with
  546. \fB\-\-exit\-code\fR\&.
  547. .RE
  548. .PP
  549. \fB\-\-ws\-error\-highlight=\fR\fI<kind>\fR
  550. .RS 4
  551. Highlight whitespace errors in the
  552. \fBcontext\fR,
  553. \fBold\fR
  554. or
  555. \fBnew\fR
  556. lines of the diff\&. Multiple values are separated by comma,
  557. \fBnone\fR
  558. resets previous values,
  559. \fBdefault\fR
  560. reset the list to
  561. \fBnew\fR
  562. and
  563. \fBall\fR
  564. is a shorthand for
  565. \fBold,new,context\fR\&. When this option is not given, and the configuration variable
  566. \fBdiff\&.wsErrorHighlight\fR
  567. is not set, only whitespace errors in
  568. \fBnew\fR
  569. lines are highlighted\&. The whitespace errors are colored with
  570. \fBcolor\&.diff\&.whitespace\fR\&.
  571. .RE
  572. .PP
  573. \fB\-\-full\-index\fR
  574. .RS 4
  575. Instead of the first handful of characters, show the full pre\- and post\-image blob object names on the "index" line when generating patch format output\&.
  576. .RE
  577. .PP
  578. \fB\-\-binary\fR
  579. .RS 4
  580. In addition to
  581. \fB\-\-full\-index\fR, output a binary diff that can be applied with
  582. \fBgit\-apply\fR\&. Implies
  583. \fB\-\-patch\fR\&.
  584. .RE
  585. .PP
  586. \fB\-\-abbrev\fR[\fB=\fR\fI<n>\fR]
  587. .RS 4
  588. Instead of showing the full 40\-byte hexadecimal object name in diff\-raw format output and diff\-tree header lines, show the shortest prefix that is at least
  589. \fI<n>\fR
  590. hexdigits long that uniquely refers the object\&. In diff\-patch output format,
  591. \fB\-\-full\-index\fR
  592. takes higher precedence, i\&.e\&. if
  593. \fB\-\-full\-index\fR
  594. is specified, full blob names will be shown regardless of
  595. \fB\-\-abbrev\fR\&. Non default number of digits can be specified with
  596. \fB\-\-abbrev=\fR\fI<n>\fR\&.
  597. .RE
  598. .PP
  599. \fB\-B\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR], \fB\-\-break\-rewrites\fR[\fB=\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR]]
  600. .RS 4
  601. Break complete rewrite changes into pairs of delete and create\&. This serves two purposes:
  602. .sp
  603. It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number
  604. \fI<m>\fR
  605. controls this aspect of the
  606. \fB\-B\fR
  607. option (defaults to 60%)\&.
  608. \fB\-B/70\fR% specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i\&.e\&. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines)\&.
  609. .sp
  610. When used with
  611. \fB\-M\fR, a totally\-rewritten file is also considered as the source of a rename (usually
  612. \fB\-M\fR
  613. only considers a file that disappeared as the source of a rename), and the number
  614. \fI<n>\fR
  615. controls this aspect of the
  616. \fB\-B\fR
  617. option (defaults to 50%)\&.
  618. \fB\-B20\fR% specifies that a change with addition and deletion compared to 20% or more of the file\(cqs size are eligible for being picked up as a possible source of a rename to another file\&.
  619. .RE
  620. .PP
  621. \fB\-M\fR[\fI<n>\fR], \fB\-\-find\-renames\fR[\fB=\fR\fI<n>\fR]
  622. .RS 4
  623. Detect renames\&. If
  624. \fI<n>\fR
  625. is specified, it is a threshold on the similarity index (i\&.e\&. amount of addition/deletions compared to the file\(cqs size)\&. For example,
  626. \fB\-M90\fR% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn\(cqt changed\&. Without a % sign, the number is to be read as a fraction, with a decimal point before it\&. I\&.e\&.,
  627. \fB\-M5\fR
  628. becomes 0\&.5, and is thus the same as
  629. \fB\-M50\fR%\&. Similarly,
  630. \fB\-M05\fR
  631. is the same as
  632. \fB\-M5\fR%\&. To limit detection to exact renames, use
  633. \fB\-M100\fR%\&. The default similarity index is 50%\&.
  634. .RE
  635. .PP
  636. \fB\-C\fR[\fI<n>\fR], \fB\-\-find\-copies\fR[\fB=\fR\fI<n>\fR]
  637. .RS 4
  638. Detect copies as well as renames\&. See also
  639. \fB\-\-find\-copies\-harder\fR\&. If
  640. \fI<n>\fR
  641. is specified, it has the same meaning as for
  642. \fB\-M\fR\fI<n>\fR\&.
  643. .RE
  644. .PP
  645. \fB\-\-find\-copies\-harder\fR
  646. .RS 4
  647. For performance reasons, by default,
  648. \fB\-C\fR
  649. option finds copies only if the original file of the copy was modified in the same changeset\&. This flag makes the command inspect unmodified files as candidates for the source of copy\&. This is a very expensive operation for large projects, so use it with caution\&. Giving more than one
  650. \fB\-C\fR
  651. option has the same effect\&.
  652. .RE
  653. .PP
  654. \fB\-D\fR, \fB\-\-irreversible\-delete\fR
  655. .RS 4
  656. Omit the preimage for deletes, i\&.e\&. print only the header but not the diff between the preimage and
  657. \fB/dev/null\fR\&. The resulting patch is not meant to be applied with
  658. \fBpatch\fR
  659. or
  660. \fBgit\fR
  661. \fBapply\fR; this is solely for people who want to just concentrate on reviewing the text after the change\&. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option\&.
  662. .sp
  663. When used together with
  664. \fB\-B\fR, omit also the preimage in the deletion part of a delete/create pair\&.
  665. .RE
  666. .PP
  667. \fB\-l\fR\fI<num>\fR
  668. .RS 4
  669. The
  670. \fB\-M\fR
  671. and
  672. \fB\-C\fR
  673. options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources\&. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant\&.) For N sources and destinations, this exhaustive check is O(N^2)\&. This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number\&. Defaults to
  674. \fBdiff\&.renameLimit\fR\&. Note that a value of 0 is treated as unlimited\&.
  675. .RE
  676. .PP
  677. \fB\-\-diff\-filter=\fR[(\fBA\fR|\fBC\fR|\fBD\fR|\fBM\fR|\fBR\fR|\fBT\fR|\fBU\fR|\fBX\fR|\fBB\fR)\fB\&.\&.\&.\fR[*]]
  678. .RS 4
  679. Select only files that are Added (\fBA\fR), Copied (\fBC\fR), Deleted (\fBD\fR), Modified (\fBM\fR), Renamed (\fBR\fR), have their type (i\&.e\&. regular file, symlink, submodule, \&...\:) changed (\fBT\fR), are Unmerged (\fBU\fR), are Unknown (\fBX\fR), or have had their pairing Broken (\fBB\fR)\&. Any combination of the filter characters (including none) can be used\&. When * (All\-or\-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected\&.
  680. .sp
  681. Also, these upper\-case letters can be downcased to exclude\&. E\&.g\&.
  682. \fB\-\-diff\-filter=ad\fR
  683. excludes added and deleted paths\&.
  684. .sp
  685. Note that not all diffs can feature all types\&. For instance, copied and renamed entries cannot appear if detection for those types is disabled\&.
  686. .RE
  687. .PP
  688. \fB\-S\fR\fI<string>\fR
  689. .RS 4
  690. Look for differences that change the number of occurrences of the specified
  691. \fI<string>\fR
  692. (i\&.e\&. addition/deletion) in a file\&. Intended for the scripter\(cqs use\&.
  693. .sp
  694. It is useful when you\(cqre looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into
  695. \fB\-S\fR, and keep going until you get the very first version of the block\&.
  696. .sp
  697. Binary files are searched as well\&.
  698. .RE
  699. .PP
  700. \fB\-G\fR\fI<regex>\fR
  701. .RS 4
  702. Look for differences whose patch text contains added/removed lines that match
  703. \fI<regex>\fR\&.
  704. .sp
  705. To illustrate the difference between
  706. \fB\-S\fR\fI<regex>\fR
  707. \fB\-\-pickaxe\-regex\fR
  708. and
  709. \fB\-G\fR\fI<regex>\fR, consider a commit with the following diff in the same file:
  710. .sp
  711. .if n \{\
  712. .RS 4
  713. .\}
  714. .nf
  715. + return frotz(nitfol, two\->ptr, 1, 0);
  716. \&.\&.\&.
  717. \- hit = frotz(nitfol, mf2\&.ptr, 1, 0);
  718. .fi
  719. .if n \{\
  720. .RE
  721. .\}
  722. .sp
  723. While
  724. \fBgit\fR
  725. \fBlog\fR
  726. \fB\-G\fR"frotz\e(\fBnitfol\fR" will show this commit,
  727. \fBgit\fR
  728. \fBlog\fR
  729. \fB\-S\fR"frotz\e(\fBnitfol\fR"
  730. \fB\-\-pickaxe\-regex\fR
  731. will not (because the number of occurrences of that string did not change)\&.
  732. .sp
  733. Unless
  734. \fB\-\-text\fR
  735. is supplied patches of binary files without a textconv filter will be ignored\&.
  736. .sp
  737. See the
  738. \fIpickaxe\fR
  739. entry in
  740. \fBgitdiffcore\fR(7)
  741. for more information\&.
  742. .RE
  743. .PP
  744. \fB\-\-find\-object=\fR\fI<object\-id>\fR
  745. .RS 4
  746. Look for differences that change the number of occurrences of the specified object\&. Similar to
  747. \fB\-S\fR, just the argument is different in that it doesn\(cqt search for a specific string but for a specific object id\&.
  748. .sp
  749. The object can be a blob or a submodule commit\&. It implies the
  750. \fB\-t\fR
  751. option in
  752. \fBgit\-log\fR
  753. to also find trees\&.
  754. .RE
  755. .PP
  756. \fB\-\-pickaxe\-all\fR
  757. .RS 4
  758. When
  759. \fB\-S\fR
  760. or
  761. \fB\-G\fR
  762. finds a change, show all the changes in that changeset, not just the files that contain the change in
  763. \fI<string>\fR\&.
  764. .RE
  765. .PP
  766. \fB\-\-pickaxe\-regex\fR
  767. .RS 4
  768. Treat the
  769. \fI<string>\fR
  770. given to
  771. \fB\-S\fR
  772. as an extended POSIX regular expression to match\&.
  773. .RE
  774. .PP
  775. \fB\-O\fR\fI<orderfile>\fR
  776. .RS 4
  777. Control the order in which files appear in the output\&. This overrides the
  778. \fBdiff\&.orderFile\fR
  779. configuration variable (see
  780. \fBgit-config\fR(1))\&. To cancel
  781. \fBdiff\&.orderFile\fR, use
  782. \fB\-O/dev/null\fR\&.
  783. .sp
  784. The output order is determined by the order of glob patterns in
  785. \fI<orderfile>\fR\&. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on\&. All files with pathnames that do not match any pattern are output last, as if there was an implicit match\-all pattern at the end of the file\&. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order\&.
  786. .sp
  787. \fI<orderfile>\fR
  788. is parsed as follows:
  789. .sp
  790. .RS 4
  791. .ie n \{\
  792. \h'-04'\(bu\h'+03'\c
  793. .\}
  794. .el \{\
  795. .sp -1
  796. .IP \(bu 2.3
  797. .\}
  798. Blank lines are ignored, so they can be used as separators for readability\&.
  799. .RE
  800. .sp
  801. .RS 4
  802. .ie n \{\
  803. \h'-04'\(bu\h'+03'\c
  804. .\}
  805. .el \{\
  806. .sp -1
  807. .IP \(bu 2.3
  808. .\}
  809. Lines starting with a hash ("#") are ignored, so they can be used for comments\&. Add a backslash ("\e") to the beginning of the pattern if it starts with a hash\&.
  810. .RE
  811. .sp
  812. .RS 4
  813. .ie n \{\
  814. \h'-04'\(bu\h'+03'\c
  815. .\}
  816. .el \{\
  817. .sp -1
  818. .IP \(bu 2.3
  819. .\}
  820. Each other line contains a single pattern\&.
  821. .RE
  822. .sp
  823. Patterns have the same syntax and semantics as patterns used for
  824. \fBfnmatch\fR(3) without the
  825. \fBFNM_PATHNAME\fR
  826. flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern\&. For example, the pattern "\fBfoo\fR*bar" matches "\fBfooasdfbar\fR" and "\fBfoo/bar/baz/asdf\fR" but not "\fBfoobarx\fR"\&.
  827. .RE
  828. .PP
  829. \fB\-\-skip\-to=\fR\fI<file>\fR, \fB\-\-rotate\-to=\fR\fI<file>\fR
  830. .RS 4
  831. Discard the files before the named
  832. \fI<file>\fR
  833. from the output (i\&.e\&.
  834. \fIskip to\fR), or move them to the end of the output (i\&.e\&.
  835. \fIrotate to\fR)\&. These options were invented primarily for the use of the
  836. \fBgit\fR
  837. \fBdifftool\fR
  838. command, and may not be very useful otherwise\&.
  839. .RE
  840. .PP
  841. \fB\-R\fR
  842. .RS 4
  843. Swap two inputs; that is, show differences from index or on\-disk file to tree contents\&.
  844. .RE
  845. .PP
  846. \fB\-\-relative\fR[\fB=\fR\fI<path>\fR], \fB\-\-no\-relative\fR
  847. .RS 4
  848. When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option\&. When you are not in a subdirectory (e\&.g\&. in a bare repository), you can name which subdirectory to make the output relative to by giving a
  849. \fI<path>\fR
  850. as an argument\&.
  851. \fB\-\-no\-relative\fR
  852. can be used to countermand both
  853. \fBdiff\&.relative\fR
  854. config option and previous
  855. \fB\-\-relative\fR\&.
  856. .RE
  857. .PP
  858. \fB\-a\fR, \fB\-\-text\fR
  859. .RS 4
  860. Treat all files as text\&.
  861. .RE
  862. .PP
  863. \fB\-\-ignore\-cr\-at\-eol\fR
  864. .RS 4
  865. Ignore carriage\-return at the end of line when doing a comparison\&.
  866. .RE
  867. .PP
  868. \fB\-\-ignore\-space\-at\-eol\fR
  869. .RS 4
  870. Ignore changes in whitespace at EOL\&.
  871. .RE
  872. .PP
  873. \fB\-b\fR, \fB\-\-ignore\-space\-change\fR
  874. .RS 4
  875. Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
  876. .RE
  877. .PP
  878. \fB\-w\fR, \fB\-\-ignore\-all\-space\fR
  879. .RS 4
  880. Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
  881. .RE
  882. .PP
  883. \fB\-\-ignore\-blank\-lines\fR
  884. .RS 4
  885. Ignore changes whose lines are all blank\&.
  886. .RE
  887. .PP
  888. \fB\-I\fR\fI<regex>\fR, \fB\-\-ignore\-matching\-lines=\fR\fI<regex>\fR
  889. .RS 4
  890. Ignore changes whose all lines match
  891. \fI<regex>\fR\&. This option may be specified more than once\&.
  892. .RE
  893. .PP
  894. \fB\-\-inter\-hunk\-context=\fR\fI<number>\fR
  895. .RS 4
  896. Show the context between diff hunks, up to the specified
  897. \fI<number>\fR
  898. of lines, thereby fusing hunks that are close to each other\&. Defaults to
  899. \fBdiff\&.interHunkContext\fR
  900. or 0 if the config option is unset\&.
  901. .RE
  902. .PP
  903. \fB\-W\fR, \fB\-\-function\-context\fR
  904. .RS 4
  905. Show whole function as context lines for each change\&. The function names are determined in the same way as
  906. \fBgit\fR
  907. \fBdiff\fR
  908. works out patch hunk headers (see "Defining a custom hunk\-header" in
  909. \fBgitattributes\fR(5))\&.
  910. .RE
  911. .PP
  912. \fB\-\-exit\-code\fR
  913. .RS 4
  914. Make the program exit with codes similar to
  915. \fBdiff\fR(1)\&. That is, it exits with 1 if there were differences and 0 means no differences\&.
  916. .RE
  917. .PP
  918. \fB\-\-quiet\fR
  919. .RS 4
  920. Disable all output of the program\&. Implies
  921. \fB\-\-exit\-code\fR\&. Disables execution of external diff helpers whose exit code is not trusted, i\&.e\&. their respective configuration option
  922. \fBdiff\&.trustExitCode\fR
  923. or
  924. \fBdiff\&.\fR\fI<driver>\fR\&.\fBtrustExitCode\fR
  925. or environment variable
  926. \fBGIT_EXTERNAL_DIFF_TRUST_EXIT_CODE\fR
  927. is false\&.
  928. .RE
  929. .PP
  930. \fB\-\-ext\-diff\fR
  931. .RS 4
  932. Allow an external diff helper to be executed\&. If you set an external diff driver with
  933. \fBgitattributes\fR(5), you need to use this option with
  934. \fBgit-log\fR(1)
  935. and friends\&.
  936. .RE
  937. .PP
  938. \fB\-\-no\-ext\-diff\fR
  939. .RS 4
  940. Disallow external diff drivers\&.
  941. .RE
  942. .PP
  943. \fB\-\-textconv\fR, \fB\-\-no\-textconv\fR
  944. .RS 4
  945. Allow (or disallow) external text conversion filters to be run when comparing binary files\&. See
  946. \fBgitattributes\fR(5)
  947. for details\&. Because textconv filters are typically a one\-way conversion, the resulting diff is suitable for human consumption, but cannot be applied\&. For this reason, textconv filters are enabled by default only for
  948. \fBgit-diff\fR(1)
  949. and
  950. \fBgit-log\fR(1), but not for
  951. \fBgit-format-patch\fR(1)
  952. or diff plumbing commands\&.
  953. .RE
  954. .PP
  955. \fB\-\-ignore\-submodules\fR[\fB=\fR(\fBnone\fR|\fBuntracked\fR|\fBdirty\fR|\fBall\fR)]
  956. .RS 4
  957. Ignore changes to submodules in the diff generation\&.
  958. \fBall\fR
  959. is the default\&. Using
  960. \fBnone\fR
  961. will consider the submodule modified when it either contains untracked or modified files or its
  962. \fBHEAD\fR
  963. differs from the commit recorded in the superproject and can be used to override any settings of the
  964. \fBignore\fR
  965. option in
  966. \fBgit-config\fR(1)
  967. or
  968. \fBgitmodules\fR(5)\&. When
  969. \fBuntracked\fR
  970. is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content)\&. Using
  971. \fBdirty\fR
  972. ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1\&.7\&.0)\&. Using
  973. \fBall\fR
  974. hides all changes to submodules\&.
  975. .RE
  976. .PP
  977. \fB\-\-src\-prefix=\fR\fI<prefix>\fR
  978. .RS 4
  979. Show the given source
  980. \fI<prefix>\fR
  981. instead of "a/"\&.
  982. .RE
  983. .PP
  984. \fB\-\-dst\-prefix=\fR\fI<prefix>\fR
  985. .RS 4
  986. Show the given destination
  987. \fI<prefix>\fR
  988. instead of "b/"\&.
  989. .RE
  990. .PP
  991. \fB\-\-no\-prefix\fR
  992. .RS 4
  993. Do not show any source or destination prefix\&.
  994. .RE
  995. .PP
  996. \fB\-\-default\-prefix\fR
  997. .RS 4
  998. Use the default source and destination prefixes ("a/" and "b/")\&. This overrides configuration variables such as
  999. \fBdiff\&.noprefix\fR,
  1000. \fBdiff\&.srcPrefix\fR,
  1001. \fBdiff\&.dstPrefix\fR, and
  1002. \fBdiff\&.mnemonicPrefix\fR
  1003. (see
  1004. \fBgit-config\fR(1))\&.
  1005. .RE
  1006. .PP
  1007. \fB\-\-line\-prefix=\fR\fI<prefix>\fR
  1008. .RS 4
  1009. Prepend an additional
  1010. \fI<prefix>\fR
  1011. to every line of output\&.
  1012. .RE
  1013. .PP
  1014. \fB\-\-ita\-invisible\-in\-index\fR
  1015. .RS 4
  1016. By default entries added by
  1017. \fBgit\fR
  1018. \fBadd\fR
  1019. \fB\-N\fR
  1020. appear as an existing empty file in
  1021. \fBgit\fR
  1022. \fBdiff\fR
  1023. and a new file in
  1024. \fBgit\fR
  1025. \fBdiff\fR
  1026. \fB\-\-cached\fR\&. This option makes the entry appear as a new file in
  1027. \fBgit\fR
  1028. \fBdiff\fR
  1029. and non\-existent in
  1030. \fBgit\fR
  1031. \fBdiff\fR
  1032. \fB\-\-cached\fR\&. This option could be reverted with
  1033. \fB\-\-ita\-visible\-in\-index\fR\&. Both options are experimental and could be removed in future\&.
  1034. .RE
  1035. .sp
  1036. For more detailed explanation on these common options, see also \fBgitdiffcore\fR(7)\&.
  1037. .PP
  1038. <tree\-ish>
  1039. .RS 4
  1040. The id of a tree object to diff against\&.
  1041. .RE
  1042. .PP
  1043. \-\-cached
  1044. .RS 4
  1045. Do not consider the on\-disk file at all\&.
  1046. .RE
  1047. .PP
  1048. \-\-merge\-base
  1049. .RS 4
  1050. Instead of comparing <tree\-ish> directly, use the merge base between <tree\-ish> and HEAD instead\&. <tree\-ish> must be a commit\&.
  1051. .RE
  1052. .PP
  1053. \-m
  1054. .RS 4
  1055. By default, files recorded in the index but not checked out are reported as deleted\&. This flag makes
  1056. \fIgit diff\-index\fR
  1057. say that all non\-checked\-out files are up to date\&.
  1058. .RE
  1059. .SH "RAW OUTPUT FORMAT"
  1060. .sp
  1061. The raw output format from \fBgit\-diff\-index\fR, \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\fR \fBdiff\fR \fB\-\-raw\fR are very similar\&.
  1062. .sp
  1063. These commands all compare two sets of things; what is compared differs:
  1064. .PP
  1065. \fBgit\-diff\-index\fR \fI<tree\-ish>\fR
  1066. .RS 4
  1067. compares the
  1068. \fI<tree\-ish>\fR
  1069. and the files on the filesystem\&.
  1070. .RE
  1071. .PP
  1072. \fBgit\-diff\-index\fR \fB\-\-cached\fR \fI<tree\-ish>\fR
  1073. .RS 4
  1074. compares the
  1075. \fI<tree\-ish>\fR
  1076. and the index\&.
  1077. .RE
  1078. .PP
  1079. \fBgit\-diff\-tree\fR [\fB\-r\fR] \fI<tree\-ish\-1>\fR \fI<tree\-ish\-2>\fR [\fI<pattern>\fR\&.\&.\&.]
  1080. .RS 4
  1081. compares the trees named by the two arguments\&.
  1082. .RE
  1083. .PP
  1084. \fBgit\-diff\-files\fR [\fI<pattern>\fR\&.\&.\&.]
  1085. .RS 4
  1086. compares the index and the files on the filesystem\&.
  1087. .RE
  1088. .sp
  1089. The \fBgit\-diff\-tree\fR command begins its output by printing the hash of what is being compared\&. After that, all the commands print one output line per changed file\&.
  1090. .sp
  1091. An output line is formatted this way:
  1092. .sp
  1093. .if n \{\
  1094. .RS 4
  1095. .\}
  1096. .nf
  1097. in\-place edit :100644 100644 bcd1234 0123456 M file0
  1098. copy\-edit :100644 100644 abcd123 1234567 C68 file1 file2
  1099. rename\-edit :100644 100644 abcd123 1234567 R86 file1 file3
  1100. create :000000 100644 0000000 1234567 A file4
  1101. delete :100644 000000 1234567 0000000 D file5
  1102. unmerged :000000 000000 0000000 0000000 U file6
  1103. .fi
  1104. .if n \{\
  1105. .RE
  1106. .\}
  1107. .sp
  1108. That is, from the left to the right:
  1109. .sp
  1110. .RS 4
  1111. .ie n \{\
  1112. \h'-04' 1.\h'+01'\c
  1113. .\}
  1114. .el \{\
  1115. .sp -1
  1116. .IP " 1." 4.2
  1117. .\}
  1118. a colon\&.
  1119. .RE
  1120. .sp
  1121. .RS 4
  1122. .ie n \{\
  1123. \h'-04' 2.\h'+01'\c
  1124. .\}
  1125. .el \{\
  1126. .sp -1
  1127. .IP " 2." 4.2
  1128. .\}
  1129. mode for "src"; 000000 if creation or unmerged\&.
  1130. .RE
  1131. .sp
  1132. .RS 4
  1133. .ie n \{\
  1134. \h'-04' 3.\h'+01'\c
  1135. .\}
  1136. .el \{\
  1137. .sp -1
  1138. .IP " 3." 4.2
  1139. .\}
  1140. a space\&.
  1141. .RE
  1142. .sp
  1143. .RS 4
  1144. .ie n \{\
  1145. \h'-04' 4.\h'+01'\c
  1146. .\}
  1147. .el \{\
  1148. .sp -1
  1149. .IP " 4." 4.2
  1150. .\}
  1151. mode for "dst"; 000000 if deletion or unmerged\&.
  1152. .RE
  1153. .sp
  1154. .RS 4
  1155. .ie n \{\
  1156. \h'-04' 5.\h'+01'\c
  1157. .\}
  1158. .el \{\
  1159. .sp -1
  1160. .IP " 5." 4.2
  1161. .\}
  1162. a space\&.
  1163. .RE
  1164. .sp
  1165. .RS 4
  1166. .ie n \{\
  1167. \h'-04' 6.\h'+01'\c
  1168. .\}
  1169. .el \{\
  1170. .sp -1
  1171. .IP " 6." 4.2
  1172. .\}
  1173. sha1 for "src"; 0{40} if creation or unmerged\&.
  1174. .RE
  1175. .sp
  1176. .RS 4
  1177. .ie n \{\
  1178. \h'-04' 7.\h'+01'\c
  1179. .\}
  1180. .el \{\
  1181. .sp -1
  1182. .IP " 7." 4.2
  1183. .\}
  1184. a space\&.
  1185. .RE
  1186. .sp
  1187. .RS 4
  1188. .ie n \{\
  1189. \h'-04' 8.\h'+01'\c
  1190. .\}
  1191. .el \{\
  1192. .sp -1
  1193. .IP " 8." 4.2
  1194. .\}
  1195. sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index"\&.
  1196. .RE
  1197. .sp
  1198. .RS 4
  1199. .ie n \{\
  1200. \h'-04' 9.\h'+01'\c
  1201. .\}
  1202. .el \{\
  1203. .sp -1
  1204. .IP " 9." 4.2
  1205. .\}
  1206. a space\&.
  1207. .RE
  1208. .sp
  1209. .RS 4
  1210. .ie n \{\
  1211. \h'-04'10.\h'+01'\c
  1212. .\}
  1213. .el \{\
  1214. .sp -1
  1215. .IP "10." 4.2
  1216. .\}
  1217. status, followed by optional "score" number\&.
  1218. .RE
  1219. .sp
  1220. .RS 4
  1221. .ie n \{\
  1222. \h'-04'11.\h'+01'\c
  1223. .\}
  1224. .el \{\
  1225. .sp -1
  1226. .IP "11." 4.2
  1227. .\}
  1228. a tab or a NUL when
  1229. \fB\-z\fR
  1230. option is used\&.
  1231. .RE
  1232. .sp
  1233. .RS 4
  1234. .ie n \{\
  1235. \h'-04'12.\h'+01'\c
  1236. .\}
  1237. .el \{\
  1238. .sp -1
  1239. .IP "12." 4.2
  1240. .\}
  1241. path for "src"
  1242. .RE
  1243. .sp
  1244. .RS 4
  1245. .ie n \{\
  1246. \h'-04'13.\h'+01'\c
  1247. .\}
  1248. .el \{\
  1249. .sp -1
  1250. .IP "13." 4.2
  1251. .\}
  1252. a tab or a NUL when
  1253. \fB\-z\fR
  1254. option is used; only exists for C or R\&.
  1255. .RE
  1256. .sp
  1257. .RS 4
  1258. .ie n \{\
  1259. \h'-04'14.\h'+01'\c
  1260. .\}
  1261. .el \{\
  1262. .sp -1
  1263. .IP "14." 4.2
  1264. .\}
  1265. path for "dst"; only exists for C or R\&.
  1266. .RE
  1267. .sp
  1268. .RS 4
  1269. .ie n \{\
  1270. \h'-04'15.\h'+01'\c
  1271. .\}
  1272. .el \{\
  1273. .sp -1
  1274. .IP "15." 4.2
  1275. .\}
  1276. an LF or a NUL when
  1277. \fB\-z\fR
  1278. option is used, to terminate the record\&.
  1279. .RE
  1280. .sp
  1281. Possible status letters are:
  1282. .sp
  1283. .RS 4
  1284. .ie n \{\
  1285. \h'-04'\(bu\h'+03'\c
  1286. .\}
  1287. .el \{\
  1288. .sp -1
  1289. .IP \(bu 2.3
  1290. .\}
  1291. \fBA\fR: addition of a file
  1292. .RE
  1293. .sp
  1294. .RS 4
  1295. .ie n \{\
  1296. \h'-04'\(bu\h'+03'\c
  1297. .\}
  1298. .el \{\
  1299. .sp -1
  1300. .IP \(bu 2.3
  1301. .\}
  1302. \fBC\fR: copy of a file into a new one
  1303. .RE
  1304. .sp
  1305. .RS 4
  1306. .ie n \{\
  1307. \h'-04'\(bu\h'+03'\c
  1308. .\}
  1309. .el \{\
  1310. .sp -1
  1311. .IP \(bu 2.3
  1312. .\}
  1313. \fBD\fR: deletion of a file
  1314. .RE
  1315. .sp
  1316. .RS 4
  1317. .ie n \{\
  1318. \h'-04'\(bu\h'+03'\c
  1319. .\}
  1320. .el \{\
  1321. .sp -1
  1322. .IP \(bu 2.3
  1323. .\}
  1324. \fBM\fR: modification of the contents or mode of a file
  1325. .RE
  1326. .sp
  1327. .RS 4
  1328. .ie n \{\
  1329. \h'-04'\(bu\h'+03'\c
  1330. .\}
  1331. .el \{\
  1332. .sp -1
  1333. .IP \(bu 2.3
  1334. .\}
  1335. \fBR\fR: renaming of a file
  1336. .RE
  1337. .sp
  1338. .RS 4
  1339. .ie n \{\
  1340. \h'-04'\(bu\h'+03'\c
  1341. .\}
  1342. .el \{\
  1343. .sp -1
  1344. .IP \(bu 2.3
  1345. .\}
  1346. \fBT\fR: change in the type of the file (regular file, symbolic link or submodule)
  1347. .RE
  1348. .sp
  1349. .RS 4
  1350. .ie n \{\
  1351. \h'-04'\(bu\h'+03'\c
  1352. .\}
  1353. .el \{\
  1354. .sp -1
  1355. .IP \(bu 2.3
  1356. .\}
  1357. \fBU\fR: file is unmerged (you must complete the merge before it can be committed)
  1358. .RE
  1359. .sp
  1360. .RS 4
  1361. .ie n \{\
  1362. \h'-04'\(bu\h'+03'\c
  1363. .\}
  1364. .el \{\
  1365. .sp -1
  1366. .IP \(bu 2.3
  1367. .\}
  1368. \fBX\fR: "unknown" change type (most probably a bug, please report it)
  1369. .RE
  1370. .sp
  1371. Status letters \fBC\fR and \fBR\fR are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy)\&. Status letter \fBM\fR may be followed by a score (denoting the percentage of dissimilarity) for file rewrites\&.
  1372. .sp
  1373. The sha1 for "dst" is shown as all 0\(cqs if a file on the filesystem is out of sync with the index\&.
  1374. .sp
  1375. Example:
  1376. .sp
  1377. .if n \{\
  1378. .RS 4
  1379. .\}
  1380. .nf
  1381. :100644 100644 5be4a4a 0000000 M file\&.c
  1382. .fi
  1383. .if n \{\
  1384. .RE
  1385. .\}
  1386. .sp
  1387. Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
  1388. .SH "DIFF FORMAT FOR MERGES"
  1389. .sp
  1390. \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\-diff\fR \fB\-\-raw\fR can take \fB\-c\fR or \fB\-\-cc\fR option to generate diff output also for merge commits\&. The output differs from the format described above in the following way:
  1391. .sp
  1392. .RS 4
  1393. .ie n \{\
  1394. \h'-04' 1.\h'+01'\c
  1395. .\}
  1396. .el \{\
  1397. .sp -1
  1398. .IP " 1." 4.2
  1399. .\}
  1400. there is a colon for each parent
  1401. .RE
  1402. .sp
  1403. .RS 4
  1404. .ie n \{\
  1405. \h'-04' 2.\h'+01'\c
  1406. .\}
  1407. .el \{\
  1408. .sp -1
  1409. .IP " 2." 4.2
  1410. .\}
  1411. there are more "src" modes and "src" sha1
  1412. .RE
  1413. .sp
  1414. .RS 4
  1415. .ie n \{\
  1416. \h'-04' 3.\h'+01'\c
  1417. .\}
  1418. .el \{\
  1419. .sp -1
  1420. .IP " 3." 4.2
  1421. .\}
  1422. status is concatenated status characters for each parent
  1423. .RE
  1424. .sp
  1425. .RS 4
  1426. .ie n \{\
  1427. \h'-04' 4.\h'+01'\c
  1428. .\}
  1429. .el \{\
  1430. .sp -1
  1431. .IP " 4." 4.2
  1432. .\}
  1433. no optional "score" number
  1434. .RE
  1435. .sp
  1436. .RS 4
  1437. .ie n \{\
  1438. \h'-04' 5.\h'+01'\c
  1439. .\}
  1440. .el \{\
  1441. .sp -1
  1442. .IP " 5." 4.2
  1443. .\}
  1444. tab\-separated pathname(s) of the file
  1445. .RE
  1446. .sp
  1447. For \fB\-c\fR and \fB\-\-cc\fR, only the destination or final path is shown even if the file was renamed on any side of history\&. With \fB\-\-combined\-all\-paths\fR, the name of the path in each parent is shown followed by the name of the path in the merge commit\&.
  1448. .sp
  1449. Examples for \fB\-c\fR and \fB\-\-cc\fR without \fB\-\-combined\-all\-paths\fR:
  1450. .sp
  1451. .if n \{\
  1452. .RS 4
  1453. .\}
  1454. .nf
  1455. ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c
  1456. ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar\&.sh
  1457. ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey\&.c
  1458. .fi
  1459. .if n \{\
  1460. .RE
  1461. .\}
  1462. .sp
  1463. Examples when \fB\-\-combined\-all\-paths\fR added to either \fB\-c\fR or \fB\-\-cc\fR:
  1464. .sp
  1465. .if n \{\
  1466. .RS 4
  1467. .\}
  1468. .nf
  1469. ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c desc\&.c desc\&.c
  1470. ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo\&.sh bar\&.sh bar\&.sh
  1471. ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey\&.c fuey\&.c phooey\&.c
  1472. .fi
  1473. .if n \{\
  1474. .RE
  1475. .\}
  1476. .sp
  1477. Note that \fIcombined diff\fR lists only files which were modified from all parents\&.
  1478. .SH "GENERATING PATCH TEXT WITH \-P"
  1479. .sp
  1480. Running \fBgit-diff\fR(1), \fBgit-log\fR(1), \fBgit-show\fR(1), \fBgit-diff-index\fR(1), \fBgit-diff-tree\fR(1), or \fBgit-diff-files\fR(1) with the \fB\-p\fR option produces patch text\&. You can customize the creation of patch text via the \fBGIT_EXTERNAL_DIFF\fR and the \fBGIT_DIFF_OPTS\fR environment variables (see \fBgit\fR(1)), and the \fBdiff\fR attribute (see \fBgitattributes\fR(5))\&.
  1481. .sp
  1482. What the \fB\-p\fR option produces is slightly different from the traditional diff format:
  1483. .sp
  1484. .RS 4
  1485. .ie n \{\
  1486. \h'-04' 1.\h'+01'\c
  1487. .\}
  1488. .el \{\
  1489. .sp -1
  1490. .IP " 1." 4.2
  1491. .\}
  1492. It is preceded by a "git diff" header that looks like this:
  1493. .sp
  1494. .if n \{\
  1495. .RS 4
  1496. .\}
  1497. .nf
  1498. diff \-\-git a/file1 b/file2
  1499. .fi
  1500. .if n \{\
  1501. .RE
  1502. .\}
  1503. .sp
  1504. The
  1505. \fBa/\fR
  1506. and
  1507. \fBb/\fR
  1508. filenames are the same unless rename/copy is involved\&. Especially, even for a creation or a deletion,
  1509. \fB/dev/null\fR
  1510. is
  1511. \fInot\fR
  1512. used in place of the
  1513. \fBa/\fR
  1514. or
  1515. \fBb/\fR
  1516. filenames\&.
  1517. .sp
  1518. When a rename/copy is involved,
  1519. \fBfile1\fR
  1520. and
  1521. \fBfile2\fR
  1522. show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively\&.
  1523. .RE
  1524. .sp
  1525. .RS 4
  1526. .ie n \{\
  1527. \h'-04' 2.\h'+01'\c
  1528. .\}
  1529. .el \{\
  1530. .sp -1
  1531. .IP " 2." 4.2
  1532. .\}
  1533. It is followed by one or more extended header lines:
  1534. .sp
  1535. .if n \{\
  1536. .RS 4
  1537. .\}
  1538. .nf
  1539. \fBold\fR \fBmode\fR \fI<mode>\fR
  1540. \fBnew\fR \fBmode\fR \fI<mode>\fR
  1541. \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1542. \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1543. \fBcopy\fR \fBfrom\fR \fI<path>\fR
  1544. \fBcopy\fR \fBto\fR \fI<path>\fR
  1545. \fBrename\fR \fBfrom\fR \fI<path>\fR
  1546. \fBrename\fR \fBto\fR \fI<path>\fR
  1547. \fBsimilarity\fR \fBindex\fR \fI<number>\fR
  1548. \fBdissimilarity\fR \fBindex\fR \fI<number>\fR
  1549. \fBindex\fR \fI<hash>\fR`\&.\&.`\fI<hash>\fR \fI<mode>\fR
  1550. .fi
  1551. .if n \{\
  1552. .RE
  1553. .\}
  1554. File modes
  1555. \fI<mode>\fR
  1556. are printed as 6\-digit octal numbers including the file type and file permission bits\&.
  1557. .sp
  1558. Path names in extended headers do not include the
  1559. \fBa/\fR
  1560. and
  1561. \fBb/\fR
  1562. prefixes\&.
  1563. .sp
  1564. 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\&.
  1565. .sp
  1566. The index line includes the blob object names before and after the change\&. The
  1567. \fI<mode>\fR
  1568. is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode\&.
  1569. .RE
  1570. .sp
  1571. .RS 4
  1572. .ie n \{\
  1573. \h'-04' 3.\h'+01'\c
  1574. .\}
  1575. .el \{\
  1576. .sp -1
  1577. .IP " 3." 4.2
  1578. .\}
  1579. Pathnames with "unusual" characters are quoted as explained for the configuration variable
  1580. \fBcore\&.quotePath\fR
  1581. (see
  1582. \fBgit-config\fR(1))\&.
  1583. .RE
  1584. .sp
  1585. .RS 4
  1586. .ie n \{\
  1587. \h'-04' 4.\h'+01'\c
  1588. .\}
  1589. .el \{\
  1590. .sp -1
  1591. .IP " 4." 4.2
  1592. .\}
  1593. All the
  1594. \fBfile1\fR
  1595. files in the output refer to files before the commit, and all the
  1596. \fBfile2\fR
  1597. 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:
  1598. .sp
  1599. .if n \{\
  1600. .RS 4
  1601. .\}
  1602. .nf
  1603. diff \-\-git a/a b/b
  1604. rename from a
  1605. rename to b
  1606. diff \-\-git a/b b/a
  1607. rename from b
  1608. rename to a
  1609. .fi
  1610. .if n \{\
  1611. .RE
  1612. .\}
  1613. .RE
  1614. .sp
  1615. .RS 4
  1616. .ie n \{\
  1617. \h'-04' 5.\h'+01'\c
  1618. .\}
  1619. .el \{\
  1620. .sp -1
  1621. .IP " 5." 4.2
  1622. .\}
  1623. Hunk headers mention the name of the function to which the hunk applies\&. See "Defining a custom hunk\-header" in
  1624. \fBgitattributes\fR(5)
  1625. for details of how to tailor this to specific languages\&.
  1626. .RE
  1627. .SH "COMBINED DIFF FORMAT"
  1628. .sp
  1629. Any diff\-generating command can take the \fB\-c\fR or \fB\-\-cc\fR option to produce a \fIcombined diff\fR when showing a merge\&. This is the default format when showing merges with \fBgit-diff\fR(1) or \fBgit-show\fR(1)\&. Note also that you can give suitable \fB\-\-diff\-merges\fR option to any of these commands to force generation of diffs in a specific format\&.
  1630. .sp
  1631. A "combined diff" format looks like this:
  1632. .sp
  1633. .if n \{\
  1634. .RS 4
  1635. .\}
  1636. .nf
  1637. diff \-\-combined describe\&.c
  1638. index fabadb8,cc95eb0\&.\&.4866510
  1639. \-\-\- a/describe\&.c
  1640. +++ b/describe\&.c
  1641. @@@ \-98,20 \-98,12 +98,20 @@@
  1642. return (a_date > b_date) ? \-1 : (a_date == b_date) ? 0 : 1;
  1643. }
  1644. \- static void describe(char *arg)
  1645. \-static void describe(struct commit *cmit, int last_one)
  1646. ++static void describe(char *arg, int last_one)
  1647. {
  1648. + unsigned char sha1[20];
  1649. + struct commit *cmit;
  1650. struct commit_list *list;
  1651. static int initialized = 0;
  1652. struct commit_name *n;
  1653. + if (get_sha1(arg, sha1) < 0)
  1654. + usage(describe_usage);
  1655. + cmit = lookup_commit_reference(sha1);
  1656. + if (!cmit)
  1657. + usage(describe_usage);
  1658. +
  1659. if (!initialized) {
  1660. initialized = 1;
  1661. for_each_ref(get_name);
  1662. .fi
  1663. .if n \{\
  1664. .RE
  1665. .\}
  1666. .sp
  1667. .RS 4
  1668. .ie n \{\
  1669. \h'-04' 1.\h'+01'\c
  1670. .\}
  1671. .el \{\
  1672. .sp -1
  1673. .IP " 1." 4.2
  1674. .\}
  1675. It is preceded by a "git diff" header, that looks like this (when the
  1676. \fB\-c\fR
  1677. option is used):
  1678. .sp
  1679. .if n \{\
  1680. .RS 4
  1681. .\}
  1682. .nf
  1683. diff \-\-combined file
  1684. .fi
  1685. .if n \{\
  1686. .RE
  1687. .\}
  1688. .sp
  1689. or like this (when the
  1690. \fB\-\-cc\fR
  1691. option is used):
  1692. .sp
  1693. .if n \{\
  1694. .RS 4
  1695. .\}
  1696. .nf
  1697. diff \-\-cc file
  1698. .fi
  1699. .if n \{\
  1700. .RE
  1701. .\}
  1702. .RE
  1703. .sp
  1704. .RS 4
  1705. .ie n \{\
  1706. \h'-04' 2.\h'+01'\c
  1707. .\}
  1708. .el \{\
  1709. .sp -1
  1710. .IP " 2." 4.2
  1711. .\}
  1712. It is followed by one or more extended header lines (this example shows a merge with two parents):
  1713. .sp
  1714. .if n \{\
  1715. .RS 4
  1716. .\}
  1717. .nf
  1718. \fBindex\fR \fI<hash>\fR\fB,\fR\fI<hash>\fR`\&.\&.\fB__\fR\fI<hash>\fR\fB__\fR
  1719. {empty}`mode \fI<mode>\fR\fB,\fR\fI<mode>\fR``\&.\&.``\fI<mode>\fR
  1720. \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1721. \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR\fB,\fR\fI<mode>\fR
  1722. .fi
  1723. .if n \{\
  1724. .RE
  1725. .\}
  1726. The
  1727. \fBmode\fR
  1728. \fI<mode>\fR\fB,\fR\fI<mode>\fR\fB\&.\&.\fR\fI<mode>\fR
  1729. line appears only if at least one of the <mode> is different from the rest\&. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two
  1730. \fI<tree\-ish>\fR
  1731. and are not used by combined diff format\&.
  1732. .RE
  1733. .sp
  1734. .RS 4
  1735. .ie n \{\
  1736. \h'-04' 3.\h'+01'\c
  1737. .\}
  1738. .el \{\
  1739. .sp -1
  1740. .IP " 3." 4.2
  1741. .\}
  1742. It is followed by a two\-line from\-file/to\-file header:
  1743. .sp
  1744. .if n \{\
  1745. .RS 4
  1746. .\}
  1747. .nf
  1748. \-\-\- a/file
  1749. +++ b/file
  1750. .fi
  1751. .if n \{\
  1752. .RE
  1753. .\}
  1754. .sp
  1755. Similar to the two\-line header for the traditional
  1756. \fIunified\fR
  1757. diff format,
  1758. \fB/dev/null\fR
  1759. is used to signal created or deleted files\&.
  1760. .sp
  1761. However, if the \-\-combined\-all\-paths option is provided, instead of a two\-line from\-file/to\-file, you get an N+1 line from\-file/to\-file header, where N is the number of parents in the merge commit:
  1762. .sp
  1763. .if n \{\
  1764. .RS 4
  1765. .\}
  1766. .nf
  1767. \-\-\- a/file
  1768. \-\-\- a/file
  1769. \-\-\- a/file
  1770. +++ b/file
  1771. .fi
  1772. .if n \{\
  1773. .RE
  1774. .\}
  1775. .sp
  1776. This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents\&.
  1777. .RE
  1778. .sp
  1779. .RS 4
  1780. .ie n \{\
  1781. \h'-04' 4.\h'+01'\c
  1782. .\}
  1783. .el \{\
  1784. .sp -1
  1785. .IP " 4." 4.2
  1786. .\}
  1787. Chunk header format is modified to prevent people from accidentally feeding it to
  1788. \fBpatch\fR
  1789. \fB\-p1\fR\&. Combined diff format was created for review of merge commit changes, and was not meant to be applied\&. The change is similar to the change in the extended
  1790. \fIindex\fR
  1791. header:
  1792. .sp
  1793. .if n \{\
  1794. .RS 4
  1795. .\}
  1796. .nf
  1797. @@@ <from\-file\-range> <from\-file\-range> <to\-file\-range> @@@
  1798. .fi
  1799. .if n \{\
  1800. .RE
  1801. .\}
  1802. .sp
  1803. There are (number of parents + 1)
  1804. \fB@\fR
  1805. characters in the chunk header for combined diff format\&.
  1806. .RE
  1807. .sp
  1808. Unlike the traditional \fIunified\fR diff format, which shows two files A and B with a single column that has \fB\-\fR (minus \(em appears in A but removed in B), \fB+\fR (plus \(em missing in A but added to B), or " " (space \(em unchanged) prefix, this format compares two or more files file1, file2,\&...\: with one file X, and shows how X differs from each of fileN\&. One column for each of fileN is prepended to the output line to note how X\(cqs line is different from it\&.
  1809. .sp
  1810. A \fB\-\fR character in the column N means that the line appears in fileN but it does not appear in the result\&. A \fB+\fR character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent)\&.
  1811. .sp
  1812. In the above example output, the function signature was changed from both files (hence two \fB\-\fR removals from both file1 and file2, plus \fB++\fR to mean one line that was added does not appear in either file1 or file2)\&. Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with \fB+\fR)\&.
  1813. .sp
  1814. When shown by \fBgit\fR \fBdiff\-tree\fR \fB\-c\fR, it compares the parents of a merge commit with the merge result (i\&.e\&. file1\&.\&.fileN are the parents)\&. When shown by \fBgit\fR \fBdiff\-files\fR \fB\-c\fR, it compares the two unresolved merge parents with the working tree file (i\&.e\&. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version")\&.
  1815. .SH "OTHER DIFF FORMATS"
  1816. .sp
  1817. The \fB\-\-summary\fR option describes newly added, deleted, renamed and copied files\&. The \fB\-\-stat\fR option adds \fBdiffstat\fR(1) graph to the output\&. These options can be combined with other options, such as \fB\-p\fR, and are meant for human consumption\&.
  1818. .sp
  1819. When showing a change that involves a rename or a copy, \fB\-\-stat\fR output formats the pathnames compactly by combining common prefix and suffix of the pathnames\&. For example, a change that moves \fBarch/i386/Makefile\fR to \fBarch/x86/Makefile\fR while modifying 4 lines will be shown like this:
  1820. .sp
  1821. .if n \{\
  1822. .RS 4
  1823. .\}
  1824. .nf
  1825. arch/{i386 => x86}/Makefile | 4 +\-\-
  1826. .fi
  1827. .if n \{\
  1828. .RE
  1829. .\}
  1830. .sp
  1831. The \fB\-\-numstat\fR option gives the diffstat(1) information but is designed for easier machine consumption\&. An entry in \fB\-\-numstat\fR output looks like this:
  1832. .sp
  1833. .if n \{\
  1834. .RS 4
  1835. .\}
  1836. .nf
  1837. 1 2 README
  1838. 3 1 arch/{i386 => x86}/Makefile
  1839. .fi
  1840. .if n \{\
  1841. .RE
  1842. .\}
  1843. .sp
  1844. That is, from left to right:
  1845. .sp
  1846. .RS 4
  1847. .ie n \{\
  1848. \h'-04' 1.\h'+01'\c
  1849. .\}
  1850. .el \{\
  1851. .sp -1
  1852. .IP " 1." 4.2
  1853. .\}
  1854. the number of added lines;
  1855. .RE
  1856. .sp
  1857. .RS 4
  1858. .ie n \{\
  1859. \h'-04' 2.\h'+01'\c
  1860. .\}
  1861. .el \{\
  1862. .sp -1
  1863. .IP " 2." 4.2
  1864. .\}
  1865. a tab;
  1866. .RE
  1867. .sp
  1868. .RS 4
  1869. .ie n \{\
  1870. \h'-04' 3.\h'+01'\c
  1871. .\}
  1872. .el \{\
  1873. .sp -1
  1874. .IP " 3." 4.2
  1875. .\}
  1876. the number of deleted lines;
  1877. .RE
  1878. .sp
  1879. .RS 4
  1880. .ie n \{\
  1881. \h'-04' 4.\h'+01'\c
  1882. .\}
  1883. .el \{\
  1884. .sp -1
  1885. .IP " 4." 4.2
  1886. .\}
  1887. a tab;
  1888. .RE
  1889. .sp
  1890. .RS 4
  1891. .ie n \{\
  1892. \h'-04' 5.\h'+01'\c
  1893. .\}
  1894. .el \{\
  1895. .sp -1
  1896. .IP " 5." 4.2
  1897. .\}
  1898. pathname (possibly with rename/copy information);
  1899. .RE
  1900. .sp
  1901. .RS 4
  1902. .ie n \{\
  1903. \h'-04' 6.\h'+01'\c
  1904. .\}
  1905. .el \{\
  1906. .sp -1
  1907. .IP " 6." 4.2
  1908. .\}
  1909. a newline\&.
  1910. .RE
  1911. .sp
  1912. When \fB\-z\fR output option is in effect, the output is formatted this way:
  1913. .sp
  1914. .if n \{\
  1915. .RS 4
  1916. .\}
  1917. .nf
  1918. 1 2 README NUL
  1919. 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
  1920. .fi
  1921. .if n \{\
  1922. .RE
  1923. .\}
  1924. .sp
  1925. That is:
  1926. .sp
  1927. .RS 4
  1928. .ie n \{\
  1929. \h'-04' 1.\h'+01'\c
  1930. .\}
  1931. .el \{\
  1932. .sp -1
  1933. .IP " 1." 4.2
  1934. .\}
  1935. the number of added lines;
  1936. .RE
  1937. .sp
  1938. .RS 4
  1939. .ie n \{\
  1940. \h'-04' 2.\h'+01'\c
  1941. .\}
  1942. .el \{\
  1943. .sp -1
  1944. .IP " 2." 4.2
  1945. .\}
  1946. a tab;
  1947. .RE
  1948. .sp
  1949. .RS 4
  1950. .ie n \{\
  1951. \h'-04' 3.\h'+01'\c
  1952. .\}
  1953. .el \{\
  1954. .sp -1
  1955. .IP " 3." 4.2
  1956. .\}
  1957. the number of deleted lines;
  1958. .RE
  1959. .sp
  1960. .RS 4
  1961. .ie n \{\
  1962. \h'-04' 4.\h'+01'\c
  1963. .\}
  1964. .el \{\
  1965. .sp -1
  1966. .IP " 4." 4.2
  1967. .\}
  1968. a tab;
  1969. .RE
  1970. .sp
  1971. .RS 4
  1972. .ie n \{\
  1973. \h'-04' 5.\h'+01'\c
  1974. .\}
  1975. .el \{\
  1976. .sp -1
  1977. .IP " 5." 4.2
  1978. .\}
  1979. a NUL (only exists if renamed/copied);
  1980. .RE
  1981. .sp
  1982. .RS 4
  1983. .ie n \{\
  1984. \h'-04' 6.\h'+01'\c
  1985. .\}
  1986. .el \{\
  1987. .sp -1
  1988. .IP " 6." 4.2
  1989. .\}
  1990. pathname in preimage;
  1991. .RE
  1992. .sp
  1993. .RS 4
  1994. .ie n \{\
  1995. \h'-04' 7.\h'+01'\c
  1996. .\}
  1997. .el \{\
  1998. .sp -1
  1999. .IP " 7." 4.2
  2000. .\}
  2001. a NUL (only exists if renamed/copied);
  2002. .RE
  2003. .sp
  2004. .RS 4
  2005. .ie n \{\
  2006. \h'-04' 8.\h'+01'\c
  2007. .\}
  2008. .el \{\
  2009. .sp -1
  2010. .IP " 8." 4.2
  2011. .\}
  2012. pathname in postimage (only exists if renamed/copied);
  2013. .RE
  2014. .sp
  2015. .RS 4
  2016. .ie n \{\
  2017. \h'-04' 9.\h'+01'\c
  2018. .\}
  2019. .el \{\
  2020. .sp -1
  2021. .IP " 9." 4.2
  2022. .\}
  2023. a NUL\&.
  2024. .RE
  2025. .sp
  2026. The extra \fBNUL\fR before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single\-path record or a rename/copy record without reading ahead\&. After reading added and deleted lines, reading up to \fBNUL\fR would yield the pathname, but if that is \fBNUL\fR, the record will show two paths\&.
  2027. .SH "OPERATING MODES"
  2028. .sp
  2029. You can choose whether you want to trust the index file entirely (using the \fB\-\-cached\fR flag) or ask the diff logic to show any files that don\(cqt match the stat state as being "tentatively changed"\&. Both of these operations are very useful indeed\&.
  2030. .SH "CACHED MODE"
  2031. .sp
  2032. If \fB\-\-cached\fR is specified, it allows you to ask:
  2033. .sp
  2034. .if n \{\
  2035. .RS 4
  2036. .\}
  2037. .nf
  2038. show me the differences between HEAD and the current index
  2039. contents (the ones I\*(Aqd write using \*(Aqgit write\-tree\*(Aq)
  2040. .fi
  2041. .if n \{\
  2042. .RE
  2043. .\}
  2044. .sp
  2045. For example, let\(cqs say that you have worked on your working directory, updated some files in the index and are ready to commit\&. You want to see exactly \fBwhat\fR you are going to commit, without having to write a new tree object and compare it that way, and to do that, you just do
  2046. .sp
  2047. .if n \{\
  2048. .RS 4
  2049. .\}
  2050. .nf
  2051. git diff\-index \-\-cached HEAD
  2052. .fi
  2053. .if n \{\
  2054. .RE
  2055. .\}
  2056. .sp
  2057. Example: let\(cqs say I had renamed \fBcommit\&.c\fR to \fBgit\-commit\&.c\fR, and I had done an \fBupdate\-index\fR to make that effective in the index file\&. \fBgit\fR \fBdiff\-files\fR wouldn\(cqt show anything at all, since the index file matches my working directory\&. But doing a \fIgit diff\-index\fR does:
  2058. .sp
  2059. .if n \{\
  2060. .RS 4
  2061. .\}
  2062. .nf
  2063. torvalds@ppc970:~/git> git diff\-index \-\-cached HEAD
  2064. :100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D commit\&.c
  2065. :000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git\-commit\&.c
  2066. .fi
  2067. .if n \{\
  2068. .RE
  2069. .\}
  2070. .sp
  2071. You can see easily that the above is a rename\&.
  2072. .sp
  2073. In fact, \fBgit\fR \fBdiff\-index\fR \fB\-\-cached\fR \fBshould\fR always be entirely equivalent to actually doing a \fIgit write\-tree\fR and comparing that\&. Except this one is much nicer for the case where you just want to check where you are\&.
  2074. .sp
  2075. So doing a \fBgit\fR \fBdiff\-index\fR \fB\-\-cached\fR is basically very useful when you are asking yourself "what have I already marked for being committed, and what\(cqs the difference to a previous tree"\&.
  2076. .SH "NON\-CACHED MODE"
  2077. .sp
  2078. The "non\-cached" mode takes a different approach, and is potentially the more useful of the two in that what it does can\(cqt be emulated with a \fIgit write\-tree\fR + \fIgit diff\-tree\fR\&. Thus that\(cqs the default mode\&. The non\-cached version asks the question:
  2079. .sp
  2080. .if n \{\
  2081. .RS 4
  2082. .\}
  2083. .nf
  2084. show me the differences between HEAD and the currently checked out
  2085. tree \- index contents _and_ files that aren\*(Aqt up to date
  2086. .fi
  2087. .if n \{\
  2088. .RE
  2089. .\}
  2090. .sp
  2091. which is obviously a very useful question too, since that tells you what you \fBcould\fR commit\&. Again, the output matches the \fIgit diff\-tree \-r\fR output to a tee, but with a twist\&.
  2092. .sp
  2093. The twist is that if some file doesn\(cqt match the index, we don\(cqt have a backing store thing for it, and we use the magic "all\-zero" sha1 to show that\&. So let\(cqs say that you have edited \fBkernel/sched\&.c\fR, but have not actually done a \fIgit update\-index\fR on it yet \- there is no "object" associated with the new state, and you get:
  2094. .sp
  2095. .if n \{\
  2096. .RS 4
  2097. .\}
  2098. .nf
  2099. torvalds@ppc970:~/v2\&.6/linux> git diff\-index \-\-abbrev HEAD
  2100. :100644 100644 7476bb5ba 000000000 M kernel/sched\&.c
  2101. .fi
  2102. .if n \{\
  2103. .RE
  2104. .\}
  2105. .sp
  2106. i\&.e\&., it shows that the tree has changed, and that \fBkernel/sched\&.c\fR is not up to date and may contain new stuff\&. The all\-zero sha1 means that to get the real diff, you need to look at the object in the working directory directly rather than do an object\-to\-object diff\&.
  2107. .if n \{\
  2108. .sp
  2109. .\}
  2110. .RS 4
  2111. .it 1 an-trap
  2112. .nr an-no-space-flag 1
  2113. .nr an-break-flag 1
  2114. .br
  2115. .ps +1
  2116. \fBNote\fR
  2117. .ps -1
  2118. .br
  2119. .sp
  2120. As with other commands of this type, \fIgit diff\-index\fR does not actually look at the contents of the file at all\&. So maybe \fBkernel/sched\&.c\fR hasn\(cqt actually changed, and it\(cqs just that you touched it\&. In either case, it\(cqs a note that you need to \fIgit update\-index\fR it to make the index be in sync\&.
  2121. .sp .5v
  2122. .RE
  2123. .if n \{\
  2124. .sp
  2125. .\}
  2126. .RS 4
  2127. .it 1 an-trap
  2128. .nr an-no-space-flag 1
  2129. .nr an-break-flag 1
  2130. .br
  2131. .ps +1
  2132. \fBNote\fR
  2133. .ps -1
  2134. .br
  2135. .sp
  2136. You can have a mixture of files show up as "has been updated" and "is still dirty in the working directory" together\&. You can always tell which file is in which state, since the "has been updated" ones show a valid sha1, and the "not in sync with the index" ones will always have the special all\-zero sha1\&.
  2137. .sp .5v
  2138. .RE
  2139. .SH "GIT"
  2140. .sp
  2141. Part of the \fBgit\fR(1) suite