git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Teach git-diff{,-files} the new option `--no-index`

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 22, 2007, 18:27 UTC
Message-ID
<Pine.LNX.4.63.0702221926390.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vvehuf4ic.fsf@assigned-by-dhcp.cox.net>
Hi,
On Thu, 22 Feb 2007, Junio C Hamano wrote:
Show 43 quoted lines
> 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()?

How about adding "int always_use_index" to the signature of run_diff_files()?

Ciao, Dscho

Previous: Junio C HamanoNext: Johannes Schindelin
Message 5 of 13 in “Teach git-diff{,-files} the new option `--no-index`”
  1. Teach git-diff{,-files} the new option `--no-index`Johannes Schindelin, Feb 20, 2007
  2. Junio C HamanoFeb 22, 2007
  3. Johannes SchindelinFeb 22, 2007
  4. Junio C HamanoFeb 22, 2007
  5. Johannes SchindelinFeb 22, 2007
  6. run_diff_files(): add option to prevent --no-indexJohannes Schindelin, Feb 22, 2007
  7. Junio C HamanoFeb 22, 2007
  8. Johannes SchindelinFeb 22, 2007
  9. Junio C HamanoFeb 22, 2007
  10. Johannes SchindelinFeb 22, 2007
  11. Teach git-diff-files the new option `--no-index`Johannes Schindelin, Feb 22, 2007
  12. Junio C HamanoFeb 23, 2007
  13. Johannes SchindelinFeb 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.