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

Re: [PATCH v2] blame: add a range option to -L

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
May 4, 2010, 18:11 UTC
Message-ID
<vpqk4rj8rks.fsf@bauges.imag.fr>
In-Reply-To
<1272909995-3198-1-git-send-email-wfp5p@virginia.edu>
Bill Pemberton <wfp5p@virginia.edu> writes:
>  		term = parse_loc(term + 1, sb, lno, *bottom + 1, top);
> -		if (*term)
> -			usage(blame_usage);
> +		x = *top;
Why not use parse_loc(..., &x) if you want the value to end up in x ?
> +		*top = *bottom - x;
> +		*bottom += x;

The existing code seems to assume that top >= bottom, but swaps top and bottom otherwise:

	if (bottom && top && top < bottom) {
		long tmp;
		tmp = top; top = bottom; bottom = tmp;
	}
So, I'd write

*top = *bottom + x; *bottom -= x;

> +		if (*bottom < 1)
> +			*bottom = 1;

I guess you've assumed that bottom was the small number here, otherwise, you're checking for overflow, not for actually negative numbers. Either you apply my proposal above or you should s/bottom/top/ here, right?

(the existing code already have this a few lines after the call to this functions, it doesn't harm to do it again, but better do it on the right function)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Jakub Narebski
Message 5 of 5 in “blame: add a range option to -L”
  1. blame: add a range option to -LBill Pemberton, May 3, 2010
  2. Michael WittenMay 3, 2010
  3. Junio C HamanoMay 4, 2010
  4. Jakub NarebskiMay 4, 2010
  5. Matthieu MoyMay 4, 2010

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.