1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-15 13:43:45 +01:00
git/t/t4211/history.export

407 lines
5.1 KiB
Text
Raw Normal View History

Implement line-history search (git log -L) This is a rewrite of much of Bo's work, mainly in an effort to split it into smaller, easier to understand routines. The algorithm is built around the struct range_set, which encodes a series of line ranges as intervals [a,b). This is used in two contexts: * A set of lines we are tracking (which will change as we dig through history). * To encode diffs, as pairs of ranges. The main routine is range_set_map_across_diff(). It processes the diff between a commit C and some parent P. It determines which diff hunks are relevant to the ranges tracked in C, and computes the new ranges for P. The algorithm is then simply to process history in topological order from newest to oldest, computing ranges and (partial) diffs. At branch points, we need to merge the ranges we are watching. We will find that many commits do not affect the chosen ranges, and mark them TREESAME (in addition to those already filtered by pathspec limiting). Another pass of history simplification then gets rid of such commits. This is wired as an extra filtering pass in the log machinery. This currently only reduces code duplication, but should allow for other simplifications and options to be used. Finally, we hook a diff printer into the output chain. Ideally we would wire directly into the diff logic, to optionally use features like word diff. However, that will require some major reworking of the diff chain, so we completely replace the output with our own diff for now. As this was a GSoC project, and has quite some history by now, many people have helped. In no particular order, thanks go to Jakub Narebski <jnareb@gmail.com> Jens Lehmann <Jens.Lehmann@web.de> Jonathan Nieder <jrnieder@gmail.com> Junio C Hamano <gitster@pobox.com> Ramsay Jones <ramsay@ramsay1.demon.co.uk> Will Palmer <wmpalmer@gmail.com> Apologies to everyone I forgot. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-28 17:47:32 +01:00
blob
mark :1
data 157
#include <stdio.h>
int f(int x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
}
/*
* A comment.
*/
int main ()
{
printf("%d\n", f(15));
return 0;
}
reset refs/tags/simple
commit refs/tags/simple
mark :2
author Thomas Rast <trast@student.ethz.ch> 1362044688 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044688 +0100
data 8
initial
M 100644 :1 a.c
blob
mark :3
data 168
#include <stdio.h>
int f(int x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* A comment.
*/
int main ()
{
printf("%d\n", f(15));
return 0;
}
commit refs/tags/simple
mark :4
author Thomas Rast <trast@student.ethz.ch> 1362044695 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044695 +0100
data 11
change f()
from :2
M 100644 :3 a.c
blob
mark :5
data 171
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* A comment.
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
commit refs/tags/simple
mark :6
author Thomas Rast <trast@student.ethz.ch> 1362044716 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044716 +0100
data 21
touch both functions
from :4
M 100644 :5 a.c
blob
mark :7
data 185
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
commit refs/tags/simple
mark :8
author Thomas Rast <trast@student.ethz.ch> 1362044741 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044741 +0100
data 14
touch comment
from :6
M 100644 :7 a.c
blob
mark :9
data 205
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
commit refs/tags/simple
mark :10
author Thomas Rast <trast@student.ethz.ch> 1362044860 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044860 +0100
data 25
change at very beginning
from :8
M 100644 :9 a.c
blob
mark :11
data 204
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
commit refs/tags/simple
mark :12
author Thomas Rast <trast@student.ethz.ch> 1362044890 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044890 +0100
data 36
change to an incomplete line at end
from :10
M 100644 :11 a.c
blob
mark :13
data 238
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
/* incomplete lines are bad! */
commit refs/tags/simple
mark :14
author Thomas Rast <trast@student.ethz.ch> 1362044923 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044923 +0100
data 29
change back to complete line
from :12
M 100644 :13 a.c
commit refs/tags/move-support
mark :15
author Thomas Rast <trast@student.ethz.ch> 1362044968 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044968 +0100
data 10
move file
from :14
D a.c
M 100644 :13 b.c
blob
mark :16
data 237
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x /= 2;
s++;
}
return s;
}
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
/* incomplete lines are bad! */
commit refs/tags/move-support
mark :17
author Thomas Rast <trast@student.ethz.ch> 1362044990 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362044990 +0100
data 22
another simple change
from :15
M 100644 :16 b.c
blob
mark :18
data 254
#include <unistd.h>
#include <stdio.h>
long f(long x);
/*
* This is only an example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
/* incomplete lines are bad! */
long f(long x)
{
int s = 0;
while (x) {
x /= 2;
s++;
}
return s;
}
commit refs/heads/master
mark :19
author Thomas Rast <trast@student.ethz.ch> 1362045024 +0100
committer Thomas Rast <trast@student.ethz.ch> 1362045024 +0100
data 21
move within the file
from :17
M 100644 :18 b.c
blob
mark :20
data 243
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x >>= 1;
s++;
}
return s;
}
/*
* This is only a short example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
/* incomplete lines are bad! */
commit refs/heads/parallel-change
mark :21
author Thomas Rast <trast@inf.ethz.ch> 1365776157 +0200
committer Thomas Rast <trast@inf.ethz.ch> 1365776157 +0200
data 55
change on another line of history while rename happens
from :14
M 100644 :20 a.c
blob
mark :22
data 242
#include <unistd.h>
#include <stdio.h>
long f(long x)
{
int s = 0;
while (x) {
x /= 2;
s++;
}
return s;
}
/*
* This is only a short example!
*/
int main ()
{
printf("%ld\n", f(15));
return 0;
}
/* incomplete lines are bad! */
commit refs/heads/parallel-change
mark :23
author Thomas Rast <trast@inf.ethz.ch> 1365776184 +0200
committer Thomas Rast <trast@inf.ethz.ch> 1365776191 +0200
data 24
Merge across the rename
from :21
merge :17
D a.c
M 100644 :22 b.c
reset refs/heads/parallel-change
from :23
Implement line-history search (git log -L) This is a rewrite of much of Bo's work, mainly in an effort to split it into smaller, easier to understand routines. The algorithm is built around the struct range_set, which encodes a series of line ranges as intervals [a,b). This is used in two contexts: * A set of lines we are tracking (which will change as we dig through history). * To encode diffs, as pairs of ranges. The main routine is range_set_map_across_diff(). It processes the diff between a commit C and some parent P. It determines which diff hunks are relevant to the ranges tracked in C, and computes the new ranges for P. The algorithm is then simply to process history in topological order from newest to oldest, computing ranges and (partial) diffs. At branch points, we need to merge the ranges we are watching. We will find that many commits do not affect the chosen ranges, and mark them TREESAME (in addition to those already filtered by pathspec limiting). Another pass of history simplification then gets rid of such commits. This is wired as an extra filtering pass in the log machinery. This currently only reduces code duplication, but should allow for other simplifications and options to be used. Finally, we hook a diff printer into the output chain. Ideally we would wire directly into the diff logic, to optionally use features like word diff. However, that will require some major reworking of the diff chain, so we completely replace the output with our own diff for now. As this was a GSoC project, and has quite some history by now, many people have helped. In no particular order, thanks go to Jakub Narebski <jnareb@gmail.com> Jens Lehmann <Jens.Lehmann@web.de> Jonathan Nieder <jrnieder@gmail.com> Junio C Hamano <gitster@pobox.com> Ramsay Jones <ramsay@ramsay1.demon.co.uk> Will Palmer <wmpalmer@gmail.com> Apologies to everyone I forgot. Signed-off-by: Bo Yang <struggleyb.nku@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-28 17:47:32 +01:00