@matheusbsbs / matheus-bagliano / commits / 62476c8e33
Fork 0

Introduce a new revision set operator <rev>^!

This is a shorthand for "<rev> --not <rev>^@", i.e. "include this commit but exclude any of its parents". When a new file $F is introduced by revision $R, this notation can be used to find a copy-and-paste from existing file in the parents of that revision without annotating the ancestry of the lines that were copied from: git pickaxe -f -C $R^! -- $F Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 31, 2006 at 14:22 UTC 62476c8e331a22e224d87c18830913129f5f303b
3 files changed +55 -3
Documentation/git-pickaxe.txt
+38
@@ -111,6 +111,44 @@ The contents of the actual line is output after the above
111 header, prefixed by a TAB. This is to allow adding more
112 header elements later.
113
114 +
115 +SPECIFIYING RANGES
116 +------------------
117 +
118 +Unlike `git-blame` and `git-annotate` in older git, the extent
119 +of annotation can be limited to both line ranges and revision
120 +ranges. When you are interested in finding the origin for
121 +ll. 40-60 for file `foo`, you can use `-L` option like this:
122 +
123 + git pickaxe -L 40,60 foo
124 +
125 +When you are not interested in changes older than the version
126 +v2.6.18, or changes older than 3 weeks, you can use revision
127 +range specifiers similar to `git-rev-list`:
128 +
129 + git pickaxe v2.6.18.. -- foo
130 + git pickaxe --since=3.weeks -- foo
131 +
132 +When revision range specifiers are used to limit the annotation,
133 +lines that have not changed since the range boundary (either the
134 +commit v2.6.18 or the most recent commit that is more than 3
135 +weeks old in the above example) are blamed for that range
136 +boundary commit.
137 +
138 +A particularly useful way is to see if an added file have lines
139 +created by copy-and-paste from existing files. Sometimes this
140 +indicates that the developer was being sloppy and did not
141 +refactor the code properly. You can first find the commit that
142 +introduced the file with:
143 +
144 + git log --diff-filter=A --pretty=short -- foo
145 +
146 +and then annotate the change between the commit and its
147 +parents, using `commit{caret}!` notation:
148 +
149 + git pickaxe -C -C -f $commit^! -- foo
150 +
151 +
152 SEE ALSO
153 --------
154 gitlink:git-blame[1]
Documentation/git-rev-parse.txt
+10 -3
@@ -222,14 +222,21 @@ of `r1` and `r2` and is defined as
222 It it the set of commits that are reachable from either one of
223 `r1` or `r2` but not from both.
224
225 -Here are a few examples:
225 +Two other shorthands for naming a set that is formed by a commit
226 +and its parent commits exists. `r1{caret}@` notation means all
227 +parents of `r1`. `r1{caret}!` includes commit `r1` but excludes
228 +its all parents.
229 +
230 +Here are a handful examples:
231
232 D A B D
233 D F A B C D F
229 - ^A G B D
234 + ^A G B D
235 ^A F B C F
236 G...I C D F G I
232 - ^B G I C D F G I
237 + ^B G I C D F G I
238 + F^@ A B C
239 + F^! H D F H
240
241 Author
242 ------
revision.c
+7
@@ -660,6 +660,13 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
660 return 0;
661 *dotdot = '^';
662 }
663 + dotdot = strstr(arg, "^!");
664 + if (dotdot && !dotdot[2]) {
665 + *dotdot = 0;
666 + if (!add_parents_only(revs, arg, flags ^ UNINTERESTING))
667 + *dotdot = '^';
668 + }
669 +
670 local_flags = 0;
671 if (*arg == '^') {
672 local_flags = UNINTERESTING;