summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-05-21 02:40:01 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-21 09:58:03 -0700
commit52e9578985fb636ec1d3f6cf794fdadd5ec896fc (patch)
treebb22f522116f5d8e6ae677b7a4660e959c052fc2 /diff.c
parent427dcb4bca49117664d9428fd4e86483f516d703 (diff)
downloadgit-52e9578985fb636ec1d3f6cf794fdadd5ec896fc.tar.gz
[PATCH] Introducing software archaeologist's tool "pickaxe".
This steals the "pickaxe" feature from JIT and make it available to the bare Plumbing layer. From the command line, the user gives a string he is intersted in. Using the diff-core infrastructure previously introduced, it filters the differences to limit the output only to the diffs between <src> and <dst> where the string appears only in one but not in the other. For example: $ ./git-rev-list HEAD | ./git-diff-tree -Sdiff-tree-helper --stdin -M would show the diffs that touch the string "diff-tree-helper". In real software-archaeologist application, you would typically look for a few to several lines of code and see where that code came from. The "pickaxe" module runs after "rename/copy detection" module, so it even crosses the file rename boundary, as the above example demonstrates. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/diff.c b/diff.c
index d908ef3fde..13d5e3edf4 100644
--- a/diff.c
+++ b/diff.c
@@ -17,6 +17,7 @@ static int reverse_diff;
static int diff_raw_output = -1;
static const char **pathspec;
static int speccnt;
+static const char *pickaxe;
static int minimum_score;
static const char *external_diff(void)
@@ -511,8 +512,9 @@ int diff_scoreopt_parse(const char *opt)
return MAX_SCORE * num / scale;
}
-void diff_setup(int detect_rename_, int minimum_score_, int reverse_diff_,
- int diff_raw_output_,
+void diff_setup(int detect_rename_, int minimum_score_,
+ char *pickaxe_,
+ int reverse_diff_, int diff_raw_output_,
const char **pathspec_, int speccnt_)
{
detect_rename = detect_rename_;
@@ -521,15 +523,16 @@ void diff_setup(int detect_rename_, int minimum_score_, int reverse_diff_,
diff_raw_output = diff_raw_output_;
speccnt = speccnt_;
minimum_score = minimum_score_ ? : DEFAULT_MINIMUM_SCORE;
+ pickaxe = pickaxe_;
}
static struct diff_queue_struct queued_diff;
-struct diff_file_pair *diff_queue(struct diff_queue_struct *queue,
+struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
struct diff_filespec *one,
struct diff_filespec *two)
{
- struct diff_file_pair *dp = xmalloc(sizeof(*dp));
+ struct diff_filepair *dp = xmalloc(sizeof(*dp));
dp->one = one;
dp->two = two;
dp->xfrm_msg = 0;
@@ -549,7 +552,7 @@ static const char *git_object_type(unsigned mode)
return S_ISDIR(mode) ? "tree" : "blob";
}
-static void diff_flush_raw(struct diff_file_pair *p)
+static void diff_flush_raw(struct diff_filepair *p)
{
struct diff_filespec *it;
int addremove;
@@ -583,7 +586,7 @@ static void diff_flush_raw(struct diff_file_pair *p)
sha1_to_hex(it->sha1), it->path, diff_raw_output);
}
-static void diff_flush_patch(struct diff_file_pair *p)
+static void diff_flush_patch(struct diff_filepair *p)
{
const char *name, *other;
@@ -600,7 +603,7 @@ static int identical(struct diff_filespec *one, struct diff_filespec *two)
{
/* This function is written stricter than necessary to support
* the currently implemented transformers, but the idea is to
- * let transformers to produce diff_file_pairs any way they want,
+ * let transformers to produce diff_filepairs any way they want,
* and filter and clean them up here before producing the output.
*/
@@ -623,7 +626,7 @@ static int identical(struct diff_filespec *one, struct diff_filespec *two)
return 0;
}
-static void diff_flush_one(struct diff_file_pair *p)
+static void diff_flush_one(struct diff_filepair *p)
{
if (identical(p->one, p->two))
return;
@@ -640,11 +643,13 @@ void diff_flush(void)
if (detect_rename)
diff_detect_rename(q, detect_rename, minimum_score);
+ if (pickaxe)
+ diff_pickaxe(q, pickaxe);
for (i = 0; i < q->nr; i++)
diff_flush_one(q->queue[i]);
for (i = 0; i < q->nr; i++) {
- struct diff_file_pair *p = q->queue[i];
+ struct diff_filepair *p = q->queue[i];
diff_free_filespec_data(p->one);
diff_free_filespec_data(p->two);
free(p->xfrm_msg);