David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 1 | git-diff-tree(1) |
| 2 | ================ |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-diff-tree - Compares the content and mode of blobs found via two tree objects |
| 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Jonas Fonseca | 353ce81 | 2005-12-31 18:37:15 +0100 | [diff] [blame] | 11 | [verse] |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 12 | 'git diff-tree' [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty] |
Junio C Hamano | 34801ca | 2006-01-28 02:19:22 -0800 | [diff] [blame] | 13 | [-t] [-r] [-c | --cc] [--root] [<common diff options>] |
| 14 | <tree-ish> [<tree-ish>] [<path>...] |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 15 | |
| 16 | DESCRIPTION |
| 17 | ----------- |
| 18 | Compares the content and mode of the blobs found via two tree objects. |
| 19 | |
Robert Watson | ff8489c | 2005-09-23 11:06:04 +0100 | [diff] [blame] | 20 | If there is only one <tree-ish> given, the commit is compared with its parents |
| 21 | (see --stdin below). |
| 22 | |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 23 | Note that 'git-diff-tree' can use the tree encapsulated in a commit object. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 24 | |
| 25 | OPTIONS |
| 26 | ------- |
Junio C Hamano | dda2d79 | 2005-07-13 12:52:35 -0700 | [diff] [blame] | 27 | include::diff-options.txt[] |
| 28 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 29 | <tree-ish>:: |
| 30 | The id of a tree object. |
| 31 | |
Junio C Hamano | 232b75a | 2005-06-19 13:14:53 -0700 | [diff] [blame] | 32 | <path>...:: |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 33 | If provided, the results are limited to a subset of files |
| 34 | matching one of these prefix strings. |
Horst H. von Brand | abda1ef | 2006-06-03 16:27:26 -0400 | [diff] [blame] | 35 | i.e., file matches `/^<pattern1>|<pattern2>|.../` |
Junio C Hamano | 232b75a | 2005-06-19 13:14:53 -0700 | [diff] [blame] | 36 | Note that this parameter does not provide any wildcard or regexp |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 37 | features. |
| 38 | |
Chris Shoemaker | 50b8e35 | 2005-10-28 13:04:49 -0400 | [diff] [blame] | 39 | -r:: |
| 40 | recurse into sub-trees |
| 41 | |
Junio C Hamano | 4cae1a9 | 2005-05-24 23:24:22 -0700 | [diff] [blame] | 42 | -t:: |
| 43 | show tree entry itself as well as subtrees. Implies -r. |
| 44 | |
Thomas Glanzmann | 0746b62 | 2005-05-28 16:42:17 +0200 | [diff] [blame] | 45 | --root:: |
| 46 | When '--root' is specified the initial commit will be showed as a big |
| 47 | creation event. This is equivalent to a diff against the NULL tree. |
| 48 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 49 | --stdin:: |
| 50 | When '--stdin' is specified, the command does not take |
| 51 | <tree-ish> arguments from the command line. Instead, it |
| 52 | reads either one <commit> or a pair of <tree-ish> |
| 53 | separated with a single space from its standard input. |
| 54 | + |
| 55 | When a single commit is given on one line of such input, it compares |
| 56 | the commit with its parents. The following flags further affects its |
Horst H. von Brand | abda1ef | 2006-06-03 16:27:26 -0400 | [diff] [blame] | 57 | behavior. This does not apply to the case where two <tree-ish> |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 58 | separated with a single space are given. |
| 59 | |
| 60 | -m:: |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 61 | By default, 'git-diff-tree --stdin' does not show |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 62 | differences for merge commits. With this flag, it shows |
Petr Baudis | a13ba12 | 2006-04-09 15:43:17 +0200 | [diff] [blame] | 63 | differences to that commit from all of its parents. See |
| 64 | also '-c'. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 65 | |
| 66 | -s:: |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 67 | By default, 'git-diff-tree --stdin' shows differences, |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 68 | either in machine-readable form (without '-p') or in patch |
Junio C Hamano | 8943867 | 2005-12-29 01:20:06 -0800 | [diff] [blame] | 69 | form (with '-p'). This output can be suppressed. It is |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 70 | only useful with '-v' flag. |
| 71 | |
| 72 | -v:: |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 73 | This flag causes 'git-diff-tree --stdin' to also show |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 74 | the commit message before the differences. |
| 75 | |
Jakub Narebski | 331b51d | 2007-05-14 01:25:45 +0200 | [diff] [blame] | 76 | include::pretty-options.txt[] |
Junio C Hamano | 232b75a | 2005-06-19 13:14:53 -0700 | [diff] [blame] | 77 | |
Pavel Roskin | 601c978 | 2005-11-10 00:30:12 -0500 | [diff] [blame] | 78 | --no-commit-id:: |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 79 | 'git-diff-tree' outputs a line with the commit ID when |
Pavel Roskin | 601c978 | 2005-11-10 00:30:12 -0500 | [diff] [blame] | 80 | applicable. This flag suppressed the commit ID output. |
| 81 | |
Petr Baudis | a13ba12 | 2006-04-09 15:43:17 +0200 | [diff] [blame] | 82 | -c:: |
| 83 | This flag changes the way a merge commit is displayed |
Junio C Hamano | 34801ca | 2006-01-28 02:19:22 -0800 | [diff] [blame] | 84 | (which means it is useful only when the command is given |
| 85 | one <tree-ish>, or '--stdin'). It shows the differences |
Petr Baudis | a13ba12 | 2006-04-09 15:43:17 +0200 | [diff] [blame] | 86 | from each of the parents to the merge result simultaneously |
| 87 | instead of showing pairwise diff between a parent and the |
| 88 | result one at a time (which is what the '-m' option does). |
| 89 | Furthermore, it lists only files which were modified |
| 90 | from all parents. |
| 91 | |
Matthias Kestenholz | de5f2bf | 2006-05-03 12:51:40 +0200 | [diff] [blame] | 92 | --cc:: |
Petr Baudis | a13ba12 | 2006-04-09 15:43:17 +0200 | [diff] [blame] | 93 | This flag changes the way a merge commit patch is displayed, |
| 94 | in a similar way to the '-c' option. It implies the '-c' |
| 95 | and '-p' options and further compresses the patch output |
| 96 | by omitting hunks that show differences from only one |
Junio C Hamano | 34801ca | 2006-01-28 02:19:22 -0800 | [diff] [blame] | 97 | parent, or show the same change from all but one parent |
| 98 | for an Octopus merge. When this optimization makes all |
| 99 | hunks disappear, the commit itself and the commit log |
Petr Baudis | a13ba12 | 2006-04-09 15:43:17 +0200 | [diff] [blame] | 100 | message is not shown, just like in any other "empty diff" case. |
Junio C Hamano | 34801ca | 2006-01-28 02:19:22 -0800 | [diff] [blame] | 101 | |
Petr Baudis | 3904848 | 2006-02-07 12:47:44 +0100 | [diff] [blame] | 102 | --always:: |
| 103 | Show the commit itself and the commit log message even |
| 104 | if the diff itself is empty. |
| 105 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 106 | |
Jakub Narebski | 331b51d | 2007-05-14 01:25:45 +0200 | [diff] [blame] | 107 | include::pretty-formats.txt[] |
| 108 | |
| 109 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 110 | Limiting Output |
| 111 | --------------- |
| 112 | If you're only interested in differences in a subset of files, for |
| 113 | example some architecture-specific files, you might do: |
| 114 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 115 | git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64 |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 116 | |
| 117 | and it will only show you what changed in those two directories. |
| 118 | |
| 119 | Or if you are searching for what changed in just `kernel/sched.c`, just do |
| 120 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 121 | git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 122 | |
| 123 | and it will ignore all differences to other files. |
| 124 | |
| 125 | The pattern is always the prefix, and is matched exactly. There are no |
Johannes Schindelin | 2c6e477 | 2005-08-05 17:05:02 +0200 | [diff] [blame] | 126 | wildcards. Even stricter, it has to match a complete path component. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 127 | I.e. "foo" does not pick up `foobar.h`. "foo" does match `foo/bar.h` |
| 128 | so it can be used to name subdirectories. |
| 129 | |
| 130 | An example of normal usage is: |
| 131 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 132 | torvalds@ppc970:~/git> git diff-tree 5319e4...... |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 133 | *100664->100664 blob ac348b.......->a01513....... git-fsck-objects.c |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 134 | |
| 135 | which tells you that the last commit changed just one file (it's from |
| 136 | this one: |
| 137 | |
Jonas Fonseca | df8baa4 | 2005-10-03 19:16:30 +0200 | [diff] [blame] | 138 | ----------------------------------------------------------------------------- |
| 139 | commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8 |
| 140 | tree 5319e4d609cdd282069cc4dce33c1db559539b03 |
| 141 | parent b4e628ea30d5ab3606119d2ea5caeab141d38df7 |
| 142 | author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005 |
| 143 | committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005 |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 144 | |
Jonas Fonseca | df8baa4 | 2005-10-03 19:16:30 +0200 | [diff] [blame] | 145 | Make "git-fsck-objects" print out all the root commits it finds. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 146 | |
Jonas Fonseca | df8baa4 | 2005-10-03 19:16:30 +0200 | [diff] [blame] | 147 | Once I do the reference tracking, I'll also make it print out all the |
| 148 | HEAD commits it finds, which is even more interesting. |
| 149 | ----------------------------------------------------------------------------- |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 150 | |
| 151 | in case you care). |
| 152 | |
| 153 | Output format |
| 154 | ------------- |
| 155 | include::diff-format.txt[] |
| 156 | |
| 157 | |
| 158 | Author |
| 159 | ------ |
| 160 | Written by Linus Torvalds <torvalds@osdl.org> |
| 161 | |
| 162 | Documentation |
| 163 | -------------- |
| 164 | Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. |
| 165 | |
| 166 | GIT |
| 167 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 168 | Part of the linkgit:git[1] suite |