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

Re: [PATCH v4] diff: handle --no-abbrev in no-index case

From
JBJack Bates <bk874k@nottheoilrig.com>
Date
Dec 9, 2016, 00:22 UTC
Message-ID
<763ddb21-f735-342b-45a4-2f22e03dd346@nottheoilrig.com>
In-Reply-To
<xmqqtwaerq1x.fsf@gitster.mtv.corp.google.com>
On 08/12/16 03:53 PM, Junio C Hamano wrote:
Show 31 quoted lines
> Jack Bates <bk874k@nottheoilrig.com> writes:
>> @@ -3364,6 +3365,7 @@ void diff_setup(struct diff_options *options)
>>
>>  	options->file = stdout;
>>
>> +	options->abbrev = DEFAULT_ABBREV;
>
> This is a new change relative to your earlier one.
>
> I looked at all the callers of diff_setup() and noticed that many of
> them were initializing "struct diff_options" that is on-stack that
> is totally uninitialized, which means they were using a completely
> random value that happened to be on the stack.
>
> Which was surprising and made me wonder how the entire "diff" code
> could have ever worked correctly for the past 10 years, as it's not
> like all the users always passed --[no-]abbrev[=<value>] from the
> command line.
>
> In any case, this cannot possibly be introducing a regression; these
> callsites of diff_setup() were starting from a random garbage---now
> they start with -1 in this field.  If they were doing the right
> thing by assigning their own abbrev to the field after diff_setup()
> returned, they will continue to do the same, and otherwise they will
> keep doing whatever random things they have been doing when the
> uninitialized field happened to contain -1 the same way.
>
> I didn't look carefully at the additional tests, but the code change
> looks good.
>
> Thanks.
Great, thanks for reviewing it!
Previous: Junio C Hamano
Message 13 of 13 in “diff: handle --no-abbrev outside of repository”
  1. diff: handle --no-abbrev outside of repositoryJack Bates, Nov 28, 2016
  2. Junio C HamanoNov 28, 2016
  3. Jeff KingNov 29, 2016
  4. diff: handle --no-abbrev outside of repositoryJack Bates, Dec 2, 2016
  5. Jeff KingDec 5, 2016
  6. Jeff KingDec 5, 2016
  7. Jeff KingDec 5, 2016
  8. diff: handle --no-abbrev in no-index caseJack Bates, Dec 6, 2016
  9. diff: handle --no-abbrev in no-index caseJack Bates, Dec 6, 2016
  10. diff: handle --no-abbrev in no-index caseJack Bates, Dec 6, 2016
  11. Jack BatesDec 6, 2016
  12. Junio C HamanoDec 8, 2016
  13. Jack BatesDec 9, 2016

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.