Re: [PATCH] Avoid running lstat(2) on the same cache entry.
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 20, 2008, 02:42 UTC
- Message-ID
- <alpine.LSU.1.00.0801200231250.5731@racer.site>
- In-Reply-To
- <alpine.LFD.1.00.0801191709380.2957@woody.linux-foundation.org>
Hi,
On Sat, 19 Jan 2008, Linus Torvalds wrote:
Show 25 quoted lines
> @@ -687,13 +732,20 @@ int run_diff_index(struct rev_info *revs, int cached)
> tree = parse_tree_indirect(ent->sha1);
> if (!tree)
> return error("bad tree object %s", tree_name);
> - if (read_tree(tree, 1, revs->prune_data))
> - return error("unable to read tree object %s", tree_name);
> - ret = diff_cache(revs, active_cache, active_nr, revs->prune_data,
> - cached, match_missing);
> +
> + memset(&opts, 0, sizeof(opts));
> + opts.head_idx = 1;
> + opts.index_only = cached;
> + opts.merge = 1;
> + opts.fn = oneway_diff;
> + opts.unpack_data = revs;
> +
> + init_tree_desc(&t, tree->buffer, tree->size);
> + unpack_trees(1, &t, &opts);
> +
> diffcore_std(&revs->diffopt);
> diff_flush(&revs->diffopt);
> - return ret;
> + return 0;
> }
>Two problems I see (before I go to bed): match_missing is now ignored, and the return value is set to 0, whereas it was the return value of diff_cache() before.
The first is easily fixed, by replacing the two "0"s in the calls to show_new_file() and show_modified() with "!revs->ignore_merges". Unless I am missing something, of course.
And the second is not _that_ bad, as it seems that diff_cache() has only one return statement, and it returns 0, AFAICS. But it had to be said somewhere.
Ciao, Dscho