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

Re: [Annoyance] "git log .." thinks ".." is ambiguous

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 3, 2011, 06:33 UTC
Message-ID
<4DBFA1A2.6050409@drmicha.warpmail.net>
In-Reply-To
<FB837238-9953-4FD8-BC52-5C0AB061C291@gmail.com>
Joshua Juran venit, vidit, dixit 03.05.2011 03:57:
Show 35 quoted lines
> On May 2, 2011, at 12:15 PM, Junio C Hamano wrote:
> 
>> diff --git a/revision.c b/revision.c
>> index f4b8b38..26271d1 100644
>> --- a/revision.c
>> +++ b/revision.c
>> @@ -905,14 +905,26 @@ int handle_revision_arg(const char *arg,  
>> struct rev_info *revs,
>> 		const char *this = arg;
>> 		int symmetric = *next == '.';
>> 		unsigned int flags_exclude = flags ^ UNINTERESTING;
>> +		static const char head_by_default[] = "HEAD";
>>
>> 		*dotdot = 0;
>> 		next += symmetric;
>>
>> 		if (!*next)
>> -			next = "HEAD";
>> +			next = head_by_default;
>> 		if (dotdot == arg)
>> -			this = "HEAD";
>> +			this = head_by_default;
>> +		if (this == head_by_default && next == head_by_default &&
>> +		    !symmetric) {
> 
> Is there a reason not to write
> 
> 	const char *head_by_default = "HEAD";
> 
> or even
> 
> 	const char *const head_by_default = "HEAD";
> 
> instead?  Loading a static array and checking an init flag is a  
> pessimization versus just pointing into a read-only segment.
Because of the comparisons later on: this == "HEAD" is not the same.
Michael
Previous: Joshua JuranNext: Joshua Juran
Message 15 of 19 in “[Annoyance] "git log .." thinks ".." is ambiguous”
  1. Junio C HamanoMay 2, 2011
  2. Jeff KingMay 2, 2011
  3. Jeff KingMay 2, 2011
  4. Junio C HamanoMay 2, 2011
  5. Jeff KingMay 2, 2011
  6. specifying ranges: we did not mean to make ".." an empty setJunio C Hamano, May 2, 2011
  7. Jeff KingMay 2, 2011
  8. Junio C HamanoMay 2, 2011
  9. Michael J GruberMay 3, 2011
  10. Junio C HamanoMay 3, 2011
  11. Michael J GruberMay 4, 2011
  12. Junio C HamanoMay 4, 2011
  13. Junio C HamanoMay 4, 2011
  14. Joshua JuranMay 3, 2011
  15. Michael J GruberMay 3, 2011
  16. Joshua JuranMay 3, 2011
  17. Michael J GruberMay 3, 2011
  18. Junio C HamanoMay 3, 2011
  19. John SzakmeisterMay 3, 2011

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.