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

Re: [PATCH v2] builtin-fast-export: Add importing and exporting of revision marks

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 6, 2008, 23:09 UTC
Message-ID
<7v8wxirwi1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1212663163-43064-1-git-send-email-pdebie@ai.rug.nl>
Pieter de Bie <pdebie@ai.rug.nl> writes:
Show 23 quoted lines
> +static void export_marks(char *file)
> +{
> +	unsigned int i;
> +	uint32_t mark;
> +	struct object_decoration *deco = idnums.hash;
> +	FILE *f;
> +
> +	f = fopen(file, "w");
> +	if (!f)
> +		error("Unable to open marks file %s for writing", file);
> +
> +	for (i = 0; i < idnums.size; ++i) {
> +		deco++;
> ...
> +			mark = (uint32_t *)deco->decoration - (uint32_t *)NULL;
> +			fprintf(f, ":%u %s\n", mark,
> +				sha1_to_hex(deco->base->sha1));
> ...
> +}
> +
> +static void import_marks(char * input_file)
> ...
> +		add_decoration(&idnums, object, ((uint32_t *)NULL) + mark);
I am confused.

The type of object_decoration.decorattion is a (void*). Why isn't it sufficient to do it in a naïve and straightforward way?

	mark = (uint32_t)(deco->decoration);
        add_decoration(&idnums, object, (void*) mark);

Is this twisted pointer arithmetic done in order to avoid cast between int and pointer of different size in the code? Even if that is the case, doesn't "(uint32_t *)deco->decoration - (uint32_t *)NULL" mean the value range for deco->decoration is one-fourth of U32? What are you gaining from using "uint32_t *" instead of some other pointer types, say "char *"?

Previous: Johannes SchindelinNext: Pieter de Bie
Message 6 of 18 in “builtin-fast-export: Add importing and exporting of revision marks”
  1. builtin-fast-export: Add importing and exporting of revision marksPieter de Bie, Jun 4, 2008
  2. Johannes SchindelinJun 5, 2008
  3. Pieter de BieJun 5, 2008
  4. builtin-fast-export: Add importing and exporting of revision marksPieter de Bie, Jun 5, 2008
  5. Johannes SchindelinJun 5, 2008
  6. Junio C HamanoJun 6, 2008
  7. Pieter de BieJun 7, 2008
  8. Johannes SchindelinJun 7, 2008
  9. Junio C HamanoJun 7, 2008
  10. Johannes SchindelinJun 11, 2008
  11. Documentation/fast-export: Document --import-marks and --export-marks optionsPieter de Bie, Jun 7, 2008
  12. Johannes SchindelinJun 7, 2008
  13. Junio C HamanoJun 10, 2008
  14. builtin-fast-export: Add importing and exporting of revision marksPieter de Bie, Jun 11, 2008
  15. Pieter de BieJun 11, 2008
  16. Johannes SchindelinJun 11, 2008
  17. Junio C HamanoJun 11, 2008
  18. Johannes SchindelinJun 5, 2008

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.