From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Steffen Prohaska <prohaska@zib.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] Also use unpack_trees() in do_diff_cache()
Date: Sun, 20 Jan 2008 15:19:56 +0000 (GMT) [thread overview]
Message-ID: <alpine.LSU.1.00.0801201519320.5731@racer.site> (raw)
In-Reply-To: <alpine.LSU.1.00.0801201515060.5731@racer.site>
As in run_diff_index(), we call unpack_trees() with the oneway_diff()
function in do_diff_cache() now. This makes the function diff_cache()
obsolete.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Obviously on top of Junio's + Linus' patch.
diff-lib.c | 92 ++++++++---------------------------------------------------
1 files changed, 13 insertions(+), 79 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index dc7b514..7941486 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -580,81 +580,6 @@ static int show_modified(struct rev_info *revs,
return 0;
}
-static int diff_cache(struct rev_info *revs,
- struct cache_entry **ac, int entries,
- const char **pathspec,
- int cached, int match_missing)
-{
- while (entries) {
- struct cache_entry *ce = *ac;
- int same = (entries > 1) && ce_same_name(ce, ac[1]);
-
- if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
- DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
- break;
-
- if (!ce_path_match(ce, pathspec))
- goto skip_entry;
-
- switch (ce_stage(ce)) {
- case 0:
- /* No stage 1 entry? That means it's a new file */
- if (!same) {
- show_new_file(revs, ce, cached, match_missing);
- break;
- }
- /* Show difference between old and new */
- show_modified(revs, ac[1], ce, 1,
- cached, match_missing);
- break;
- case 1:
- /* No stage 3 (merge) entry?
- * That means it's been deleted.
- */
- if (!same) {
- diff_index_show_file(revs, "-", ce,
- ce->sha1, ce->ce_mode);
- break;
- }
- /* We come here with ce pointing at stage 1
- * (original tree) and ac[1] pointing at stage
- * 3 (unmerged). show-modified with
- * report-missing set to false does not say the
- * file is deleted but reports true if work
- * tree does not have it, in which case we
- * fall through to report the unmerged state.
- * Otherwise, we show the differences between
- * the original tree and the work tree.
- */
- if (!cached &&
- !show_modified(revs, ce, ac[1], 0,
- cached, match_missing))
- break;
- diff_unmerge(&revs->diffopt, ce->name,
- ntohl(ce->ce_mode), ce->sha1);
- break;
- case 3:
- diff_unmerge(&revs->diffopt, ce->name,
- 0, null_sha1);
- break;
-
- default:
- die("impossible cache entry stage");
- }
-
-skip_entry:
- /*
- * Ignore all the different stages for this file,
- * we've handled the relevant cases now.
- */
- do {
- ac++;
- entries--;
- } while (entries && ce_same_name(ce, ac[0]));
- }
- return 0;
-}
-
/*
* This turns all merge entries into "stage 3". That guarantees that
* when we read in the new tree (into "stage 1"), we won't lose sight
@@ -758,6 +683,8 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
int i;
struct cache_entry **dst;
struct cache_entry *last = NULL;
+ struct unpack_trees_options opts;
+ struct tree_desc t;
/*
* This is used by git-blame to run diff-cache internally;
@@ -786,8 +713,15 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
tree = parse_tree_indirect(tree_sha1);
if (!tree)
die("bad tree object %s", sha1_to_hex(tree_sha1));
- if (read_tree(tree, 1, opt->paths))
- return error("unable to read tree %s", sha1_to_hex(tree_sha1));
- return diff_cache(&revs, active_cache, active_nr, revs.prune_data,
- 1, 0);
+
+ memset(&opts, 0, sizeof(opts));
+ opts.head_idx = 1;
+ opts.index_only = 1;
+ opts.merge = 1;
+ opts.fn = oneway_diff;
+ opts.unpack_data = &revs;
+
+ init_tree_desc(&t, tree->buffer, tree->size);
+ unpack_trees(1, &t, &opts);
+ return 0;
}
--
1.5.4.rc3.44.g6cd4
next prev parent reply other threads:[~2008-01-20 15:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-19 3:25 Updated in-memory index cleanup Linus Torvalds
2008-01-19 7:42 ` [PATCH] index: be careful when handling long names Junio C Hamano
2008-01-19 7:45 ` [PATCH] Avoid running lstat(2) on the same cache entry Junio C Hamano
2008-01-19 19:47 ` Linus Torvalds
2008-01-19 19:58 ` Linus Torvalds
2008-01-20 1:22 ` Linus Torvalds
2008-01-20 1:34 ` Linus Torvalds
2008-01-20 1:48 ` Johannes Schindelin
2008-01-20 2:02 ` Linus Torvalds
2008-01-20 10:33 ` Steffen Prohaska
2008-01-20 14:15 ` Johannes Schindelin
2008-01-21 0:18 ` Junio C Hamano
2008-01-20 15:10 ` Steffen Prohaska
2008-01-20 15:18 ` Johannes Schindelin
2008-01-20 15:19 ` Johannes Schindelin [this message]
2008-01-20 20:32 ` [PATCH] Also use unpack_trees() in do_diff_cache() Linus Torvalds
2008-01-20 21:53 ` Linus Torvalds
2008-01-20 23:34 ` Johannes Schindelin
2008-01-20 23:58 ` Linus Torvalds
2008-01-21 0:19 ` Johannes Schindelin
2008-01-20 15:21 ` [PATCH] Try to resurrect the handling for 'diff-index -m' Johannes Schindelin
2008-01-20 18:20 ` [PATCH] Avoid running lstat(2) on the same cache entry Linus Torvalds
2008-01-20 20:03 ` Brian Downing
2008-01-20 21:40 ` Steffen Prohaska
2008-01-20 22:09 ` Linus Torvalds
2008-01-20 2:42 ` Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.1.00.0801201519320.5731@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=prohaska@zib.de \
--cc=torvalds@linux-foundation.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).