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

Re: [PATCH] fast-export: factor out print_oid()

From
René Scharfe <l.s.r@web.de>
Date
Aug 13, 2020, 17:17 UTC
Message-ID
<153a34a4-f0c9-6105-75d7-68f940a1cb39@web.de>
In-Reply-To
<20200813115815.GA3098633@coredump.intra.peff.net>
Am 13.08.20 um 13:58 schrieb Jeff King:
Show 8 quoted lines
> On Thu, Aug 13, 2020 at 01:11:18PM +0200, René Scharfe wrote:
>
>> Simplify the output code by splitting it up and reducing duplication.
>> Reuse the logic for printing object IDs -- anonymized if needed -- by
>> moving it to its own function, print_oid().
>
> Looks sane overall, though somehow we added 4 extra lines while reducing
> duplication. ;)
Yeah, but they are shorter. :)
Show 13 quoted lines
>
>> +static void print_oid(const struct object_id *oid, int anonymize)
>> +{
>> +	const char *oid_hex = oid_to_hex(oid);
>> +	if (anonymize)
>> +		oid_hex = anonymize_oid(oid_hex);
>> +	fputs(oid_hex, stdout);
>> +}
>
> Would anyone ever pass anything except the global "anonymize" into this
> function (certainly neither of the new callers does). I get that it
> takes us on a possible road towards moving the globals to locals, but in
> the meantime, shadowing the global name just seems more confusing to me.
Good point.
Show 10 quoted lines
>
>> @@ -470,21 +478,19 @@ static void show_filemodify(struct diff_queue_struct *q,
>>  		case DIFF_STATUS_TYPE_CHANGED:
>>  		case DIFF_STATUS_MODIFIED:
>>  		case DIFF_STATUS_ADDED:
>> +			printf("M %06o ", spec->mode);
>
> This makes the output a bit more lego-like (i.e., hard to see what the
> full line will look like from the code), but it already was pretty
> bad because of using print_path(). I think that's fine.

Yes, it was almost halfway to all-out lego style before, and the patch moves it further in that direction.

Show 11 quoted lines
>
>> @@ -724,12 +730,10 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
>>  		else
>>  			printf("merge ");
>>  		if (mark)
>> -			printf(":%d\n", mark);
>> +			printf(":%d", mark);
>
> This line gets repeated, too. I guess we could have a print_mark(), but
> there is really no logic here except "put a colon in front of it", so
> probably not worthwhile.
Right.
René
Previous: Jeff KingNext: Taylor Blau
Message 3 of 10 in “fast-export: factor out print_oid()”
  1. fast-export: factor out print_oid()René Scharfe, Aug 13, 2020
  2. Jeff KingAug 13, 2020
  3. René ScharfeAug 13, 2020
  4. Taylor BlauAug 13, 2020
  5. René ScharfeAug 13, 2020
  6. Jeff KingAug 13, 2020
  7. René ScharfeAug 15, 2020
  8. Jeff KingAug 17, 2020
  9. Junio C HamanoAug 17, 2020
  10. Junio C HamanoAug 13, 2020

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.