git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Teach git-diff{,-files} the new option `--no-index`
Date: Thu, 22 Feb 2007 10:09:47 -0800	[thread overview]
Message-ID: <7vvehuf4ic.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.63.0702221724090.22628@wbgn013.biozentrum.uni-wuerzburg.de> (Johannes Schindelin's message of "Thu, 22 Feb 2007 17:25:49 +0100 (CET)")

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi,
>
> On Thu, 22 Feb 2007, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 
>> > +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;
>> > +	}
>> 
>> 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.
>
> Well, the alternative is to duplicate code, as you need both the option 
> parsing and the special handling of max_count==-2 in both builtin-diff.c 
> and builtin-diff-files.c.

Can't they made to call a new function, which has the option
parsing followed by the switch between magic max_count==-2
codepath and run_diff_files()?

  reply	other threads:[~2007-02-22 18:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-20 18:46 [PATCH] Teach git-diff{,-files} the new option `--no-index` Johannes Schindelin
2007-02-22 10:36 ` Junio C Hamano
2007-02-22 16:25   ` Johannes Schindelin
2007-02-22 18:09     ` Junio C Hamano [this message]
2007-02-22 18:27       ` Johannes Schindelin
2007-02-22 18:54         ` [PATCH] run_diff_files(): add option to prevent --no-index Johannes Schindelin
2007-02-22 19:18         ` [PATCH] Teach git-diff{,-files} the new option `--no-index` Junio C Hamano
2007-02-22 20:01           ` Johannes Schindelin
2007-02-22 20:28             ` Junio C Hamano
2007-02-22 20:47               ` Johannes Schindelin
2007-02-22 20:50               ` [PATCH, N'TH TRY] Teach git-diff-files " Johannes Schindelin
2007-02-23 11:44                 ` Junio C Hamano
2007-02-23 16:07                   ` diff-patch: Avoid emitting double-slashes in textual patch 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vvehuf4ic.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.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 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 NNTP newsgroup(s).