summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58b103f)
raw | patch | inline | side by side (parent: 58b103f)
author | Junio C Hamano <junkio@cox.net> | |
Sun, 22 May 2005 02:40:36 +0000 (19:40 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 22 May 2005 05:49:19 +0000 (22:49 -0700) |
This does not actually supress the extra headers when pickaxe is
used, but prepares enough support for diff-tree to implement it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
used, but prepares enough support for diff-tree to implement it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff-cache.c | patch | blob | history | |
diff-files.c | patch | blob | history | |
diff-helper.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
diff.c | patch | blob | history | |
diff.h | patch | blob | history | |
diffcore-pickaxe.c | patch | blob | history | |
diffcore-rename.c | patch | blob | history | |
diffcore.h | patch | blob | history |
diff --git a/diff-cache.c b/diff-cache.c
index c604359401447e77244ad9b1938eb86bd4198e3a..fe6f45534443d4e317b45448ad266ed39b7743c6 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
if (argc != 2 || get_sha1(argv[1], tree_sha1))
usage(diff_cache_usage);
- diff_setup(detect_rename, diff_score_opt, pickaxe,
- reverse_diff, (generate_patch ? -1 : line_termination),
- NULL, 0);
+ diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
mark_merge_entries();
die("unable to read tree object %s", argv[1]);
ret = diff_cache(active_cache, active_nr);
- diff_flush();
+ if (detect_rename)
+ diff_detect_rename(detect_rename, diff_score_opt);
+ if (pickaxe)
+ diff_pickaxe(pickaxe);
+ diff_flush(NULL, 0);
return ret;
}
diff --git a/diff-files.c b/diff-files.c
index 6dca9e0e2b58728f4f13c899a513fbd3fb766808..a47bd4376ce7a31054f70ddc22004bb54f1b2939 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
exit(1);
}
- diff_setup(detect_rename, diff_score_opt, pickaxe,
- reverse_diff, (generate_patch ? -1 : line_termination),
- NULL, 0);
+ diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
for (i = 0; i < entries; i++) {
struct stat st;
show_modified(oldmode, mode, ce->sha1, null_sha1,
ce->name);
}
- diff_flush();
+ if (detect_rename)
+ diff_detect_rename(detect_rename, diff_score_opt);
+ if (pickaxe)
+ diff_pickaxe(pickaxe);
+ diff_flush(NULL, 0);
return 0;
}
diff --git a/diff-helper.c b/diff-helper.c
index 3c39c96d7e854f784e2c2dd06182fd0ec6e586a6..108ca07ed09e2a54e05adf6a2b659746cb0770fc 100644 (file)
--- a/diff-helper.c
+++ b/diff-helper.c
}
/* the remaining parameters are paths patterns */
- diff_setup(detect_rename, diff_score_opt, pickaxe,
- reverse, (generate_patch ? -1 : line_termination),
- av+1, ac-1);
-
+ diff_setup(reverse, (generate_patch ? -1 : line_termination));
while (1) {
int status;
read_line(&sb, stdin, line_termination);
break;
status = parse_diff_raw_output(sb.buf);
if (status) {
- diff_flush();
+ diff_flush(av+1, ac-1);
printf("%s%c", sb.buf, line_termination);
}
}
- diff_flush();
+ if (detect_rename)
+ diff_detect_rename(detect_rename, diff_score_opt);
+ if (pickaxe)
+ diff_pickaxe(pickaxe);
+ diff_flush(av+1, ac-1);
return 0;
}
diff --git a/diff-tree.c b/diff-tree.c
index 68186484b14d8e3293d1436f772b59b0132d3287..e8bad722140f6275dcea00b4ac86c378a079d73a 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -267,16 +267,28 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
return retval;
}
+static void call_diff_setup(void)
+{
+ diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
+}
+
+static void call_diff_flush(void)
+{
+ if (detect_rename)
+ diff_detect_rename(detect_rename, diff_score_opt);
+ if (pickaxe)
+ diff_pickaxe(pickaxe);
+ diff_flush(NULL, 0);
+}
+
static int diff_tree_sha1_top(const unsigned char *old,
const unsigned char *new, const char *base)
{
int ret;
- diff_setup(detect_rename, diff_score_opt, pickaxe,
- reverse_diff, (generate_patch ? -1 : line_termination),
- NULL, 0);
+ call_diff_setup();
ret = diff_tree_sha1(old, new, base);
- diff_flush();
+ call_diff_flush();
return ret;
}
void *tree;
unsigned long size;
- diff_setup(detect_rename, diff_score_opt, pickaxe,
- reverse_diff, (generate_patch ? -1 : line_termination),
- NULL, 0);
+ call_diff_setup();
tree = read_object_with_reference(new, "tree", &size, NULL);
if (!tree)
die("unable to read root tree (%s)", sha1_to_hex(new));
retval = diff_tree("", 0, tree, size, base);
free(tree);
- diff_flush();
+ call_diff_flush();
return retval;
}
index f7d4bc4b5aa479f6060e03e799aad76b9ad71d3d..85505fa54880881b2d109c16e69e3b21cf66ba31 100644 (file)
--- a/diff.c
+++ b/diff.c
static const char *diff_opts = "-pu";
static unsigned char null_sha1[20] = { 0, };
-static int detect_rename;
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)
{
return MAX_SCORE * num / scale;
}
-void diff_setup(int detect_rename_, int minimum_score_,
- const char *pickaxe_,
- int reverse_diff_, int diff_raw_output_,
- const char **pathspec_, int speccnt_)
+void diff_setup(int reverse_diff_, int diff_raw_output_)
{
- detect_rename = detect_rename_;
reverse_diff = reverse_diff_;
- pathspec = pathspec_;
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_queue_struct diff_queued_diff;
struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
struct diff_filespec *one,
diff_flush_patch(p);
}
-void diff_flush(void)
+int diff_queue_is_empty(void)
{
- struct diff_queue_struct *q = &queued_diff;
+ struct diff_queue_struct *q = &diff_queued_diff;
int i;
- if (detect_rename)
- diff_detect_rename(q, detect_rename, minimum_score);
- if (pickaxe)
- diff_pickaxe(q, pickaxe);
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ if (!identical(p->one, p->two))
+ return 0;
+ }
+ return 1;
+}
+
+void diff_flush(const char **pathspec_, int speccnt_)
+{
+ struct diff_queue_struct *q = &diff_queued_diff;
+ int i;
+
+ pathspec = pathspec_;
+ speccnt = speccnt_;
+
for (i = 0; i < q->nr; i++)
diff_flush_one(q->queue[i]);
if (addremove != '-')
fill_filespec(two, sha1, mode);
- diff_queue(&queued_diff, one, two);
+ diff_queue(&diff_queued_diff, one, two);
}
void diff_change(unsigned old_mode, unsigned new_mode,
fill_filespec(one, old_sha1, old_mode);
fill_filespec(two, new_sha1, new_mode);
- diff_queue(&queued_diff, one, two);
+ diff_queue(&diff_queued_diff, one, two);
}
void diff_unmerge(const char *path)
index 7473c522846068b8e4ea3a4f4a62eba239b0e90e..7b9f37d1b8af201fbcf5dcf43b2b1187841dc6c6 100644 (file)
--- a/diff.h
+++ b/diff.h
extern int diff_scoreopt_parse(const char *opt);
-extern void diff_setup(int detect_rename, int minimum_score,
- const char *pickaxe,
- int reverse, int raw_output,
- const char **spec, int cnt);
+extern void diff_setup(int reverse, int diff_raw_output);
-extern void diff_flush(void);
+extern void diff_detect_rename(int, int);
+extern void diff_pickaxe(const char *);
+
+extern int diff_queue_is_empty(void);
+
+extern void diff_flush(const char **, int);
#endif /* DIFF_H */
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index ee22e36abc3ccfce7a92f33134353d2a0d1576f9..9b9d0b73f2656cc989b397f7fdc26c37f19d6dc1 100644 (file)
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
return 0;
}
-void diff_pickaxe(struct diff_queue_struct *q, const char *needle)
+void diff_pickaxe(const char *needle)
{
+ struct diff_queue_struct *q = &diff_queued_diff;
unsigned long len = strlen(needle);
int i;
struct diff_queue_struct outq;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index e21a8071bc3f561afa7243e57bd981e707483780..9a13cafd6856607f429b517067c3f4c03975fb36 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
return 0;
}
-void diff_detect_rename(struct diff_queue_struct *q,
- int detect_rename,
+void diff_detect_rename(int detect_rename,
int minimum_score)
{
+ struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
struct diff_rename_pool created, deleted, stay;
struct diff_rename_pool *(srcs[2]);
diff --git a/diffcore.h b/diffcore.h
index c3809ef858dc7388b898e5a0658e8f0e292f7857..2938271511b2020a682135b96ad281f3c5a49bfc 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
int nr;
};
+extern struct diff_queue_struct diff_queued_diff;
extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
struct diff_filespec *,
struct diff_filespec *);
-extern void diff_detect_rename(struct diff_queue_struct *, int, int);
-extern void diff_pickaxe(struct diff_queue_struct *, const char *);
#endif