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

Re: [PATCH 2/2] use strbuf_add_unique_abbrev() for adding short hashes, part 2

From
René Scharfe <l.s.r@web.de>
Date
Sep 27, 2016, 20:59 UTC
Message-ID
<3c80f7d7-a145-3a4a-4bf2-2d8fb6dda04b@web.de>
In-Reply-To
<xmqqshslm6jo.fsf@gitster.mtv.corp.google.com>
Am 27.09.2016 um 22:28 schrieb Junio C Hamano:
Show 19 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>> diff --git a/submodule.c b/submodule.c
>> index dcc5ce3..8cf40ea 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -396,7 +396,7 @@ static void show_submodule_header(FILE *f, const char *path,
>>  			find_unique_abbrev(one->hash, DEFAULT_ABBREV));
>>  	if (!fast_backward && !fast_forward)
>>  		strbuf_addch(&sb, '.');
>> -	strbuf_addstr(&sb, find_unique_abbrev(two->hash, DEFAULT_ABBREV));
>> +	strbuf_add_unique_abbrev(&sb->hash, two, DEFAULT_ABBREV);
> 
> I wonder how could this change come out of this definition:
> 
>     @@
>     expression E1, E2, E3;
>     @@
>     - strbuf_addstr(E1, find_unique_abbrev(E2, E3));
>     + strbuf_add_unique_abbrev(E1, E2, E3);

Impossible. I added "->hash" manually during a rebase (merging a0d12c44, wrongly). Good catch, thanks!

Seeing proof of skipping compile-testing I wonder what else I do forget in my daily life. :-| I'll better go to sleep now..

Fixup patch, generated by reverting the diff, re-adding the
semantic patch and using coccicheck; compiles and survives make
test:
---
 submodule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/submodule.c b/submodule.c
index 8cf40ea..bb06b60 100644
--- a/submodule.c
+++ b/submodule.c
@@ -396,7 +396,7 @@ static void show_submodule_header(FILE *f, const char *path,
 			find_unique_abbrev(one->hash, DEFAULT_ABBREV));
 	if (!fast_backward && !fast_forward)
 		strbuf_addch(&sb, '.');
-	strbuf_add_unique_abbrev(&sb->hash, two, DEFAULT_ABBREV);
+	strbuf_add_unique_abbrev(&sb, two->hash, DEFAULT_ABBREV);
 	if (message)
 		strbuf_addf(&sb, " %s%s\n", message, reset);
 	else
-- 
2.10.0
Previous: Junio C HamanoNext: Jeff King
Message 4 of 6 in “use strbuf_addstr() instead of strbuf_addf() with "%s", part 2”
  1. 1/2 use strbuf_addstr() instead of strbuf_addf() with "%s", part 2René Scharfe, Sep 27, 2016
  2. 2/2 use strbuf_add_unique_abbrev() for adding short hashes, part 2René Scharfe, Sep 27, 2016
  3. Junio C HamanoSep 27, 2016
  4. René ScharfeSep 27, 2016
  5. Jeff KingOct 7, 2016
  6. René ScharfeOct 7, 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.