Re: [PATCH] Teach git-diff{,-files} the new option `--no-index`
- From
Junio C Hamano <junkio@cox.net>
- Date
- Feb 22, 2007, 10:36 UTC
- Message-ID
- <7vzm76fpia.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.63.0702201944340.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Is this better than diff2 or what?
Probably.
Show 20 quoted lines
> +int run_diff_files(struct rev_info *revs, int argc, const char **argv)
> {
> int entries, i;
> + int diff_unmerged_stage;
> + int silent_on_removed;
> +
> + if (handle_diff_files_args(revs, argc, argv, &silent_on_removed))
> + return -1;
> +
> + diff_unmerged_stage = revs->max_count;
> +
> + if (revs->max_count == -2) {
> + if (revs->diffopt.nr_paths != 2)
> + return error("need two files/directories with --no-index");
> + queue_diff(&revs->diffopt, revs->diffopt.paths[0],
> + revs->diffopt.paths[1]);
> + diffcore_std(&revs->diffopt);
> + diff_flush(&revs->diffopt);
> + return 0;
> + }However, I do not like this part.
I do not mind the "max_count == -2 is some magic" hack too much, but I do not think it belongs to a generic service function whose purpose is to run "diff-files" aka "diff between index and working tree". run_diff_files() is used by other applications (most notably wt-status) for example, and I expect we would need that when we rewrite git-commit itself in C.