From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] Prepare diffcore interface for diff-tree header supression.
Date: Sat, 21 May 2005 19:40:36 -0700 [thread overview]
Message-ID: <7v1x80dluj.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vwtpsdvgm.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Sat, 21 May 2005 16:12:57 -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>
---
diff-cache.c | 10 ++++++----
diff-files.c | 10 ++++++----
diff-helper.c | 13 +++++++------
diff-tree.c | 26 ++++++++++++++++++--------
diff.c | 43 ++++++++++++++++++++++---------------------
diff.h | 12 +++++++-----
diffcore-pickaxe.c | 3 ++-
diffcore-rename.c | 4 ++--
diffcore.h | 3 +--
9 files changed, 71 insertions(+), 53 deletions(-)
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -214,9 +214,7 @@ int main(int argc, char **argv)
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();
@@ -227,6 +225,10 @@ int main(int argc, char **argv)
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
--- a/diff-files.c
+++ b/diff-files.c
@@ -92,9 +92,7 @@ int main(int argc, char **argv)
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;
@@ -136,6 +134,10 @@ int main(int argc, char **argv)
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
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -127,10 +127,7 @@ int main(int ac, const char **av) {
}
/* 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);
@@ -138,11 +135,15 @@ int main(int ac, const char **av) {
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
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -267,16 +267,28 @@ static int diff_tree_sha1(const unsigned
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;
}
@@ -286,15 +298,13 @@ static int diff_root_tree(const unsigned
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;
}
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -12,13 +12,10 @@
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)
{
@@ -512,21 +509,13 @@ int diff_scoreopt_parse(const char *opt)
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,
@@ -636,15 +625,27 @@ static void diff_flush_one(struct diff_f
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]);
@@ -693,7 +694,7 @@ void diff_addremove(int addremove, unsig
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,
@@ -716,7 +717,7 @@ void diff_change(unsigned old_mode, unsi
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)
diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -19,11 +19,13 @@ extern void diff_unmerge(const char *pat
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
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -21,8 +21,9 @@ static int contains(struct diff_filespec
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
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -224,10 +224,10 @@ static int needs_to_stay(struct diff_que
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
--- a/diffcore.h
+++ b/diffcore.h
@@ -52,10 +52,9 @@ struct diff_queue_struct {
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
------------------------------------------------
next prev parent reply other threads:[~2005-05-22 2:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-21 23:12 updated design for the diff-raw format Junio C Hamano
2005-05-21 23:16 ` Junio C Hamano
2005-05-21 23:17 ` Junio C Hamano
2005-05-21 23:18 ` Junio C Hamano
2005-05-21 23:19 ` Junio C Hamano
2005-05-22 2:40 ` Junio C Hamano [this message]
2005-05-22 2:42 ` [PATCH] The diff-raw format updates Junio C Hamano
2005-05-22 6:01 ` Linus Torvalds
2005-05-22 6:33 ` Junio C Hamano
2005-05-22 6:57 ` Junio C Hamano
2005-05-22 8:31 ` [PATCH] Fix tweak in similarity estimator Junio C Hamano
2005-05-22 18:35 ` [PATCH] The diff-raw format updates Linus Torvalds
2005-05-22 18:36 ` Niklas Hoglund
2005-05-22 19:15 ` Junio C Hamano
2005-05-22 18:42 ` Thomas Glanzmann
2005-05-22 19:05 ` Linus Torvalds
2005-05-22 19:05 ` Thomas Glanzmann
2005-05-22 19:20 ` Junio C Hamano
2005-05-22 19:35 ` Junio C Hamano
2005-05-22 20:24 ` Linus Torvalds
2005-05-22 23:01 ` Junio C Hamano
2005-05-22 23:14 ` Linus Torvalds
2005-05-23 0:35 ` Junio C Hamano
2005-05-23 1:07 ` Linus Torvalds
2005-05-23 1:33 ` Junio C Hamano
2005-05-23 4:26 ` [PATCH] Rename/copy detection fix Junio C Hamano
2005-05-23 4:38 ` Comments on "Rename/copy detection fix." Junio C Hamano
2005-05-22 19:13 ` [PATCH] The diff-raw format updates Junio C Hamano
2005-05-22 9:41 ` [PATCH] Diffcore updates Junio C Hamano
2005-05-22 16:40 ` Linus Torvalds
2005-05-22 16:47 ` Junio C Hamano
2005-05-22 17:04 ` Junio C Hamano
2005-05-23 4:24 ` [PATCH] Be careful with symlinks when detecting renames and copies Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v1x80dluj.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.