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

Re: [PATCH v4 5/8] evolve: add the change-table structure

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Feb 1, 2019, 15:46 UTC
Message-ID
<f9c093bb-0225-1e0a-94ed-3854fa1f9ee2@ramsayjones.plus.com>
In-Reply-To
<20190201030925.177124-5-sxenos@google.com>
On 01/02/2019 03:09, sxenos@google.com wrote:
Show 19 quoted lines
> From: Stefan Xenos <sxenos@google.com>
> 
> A change table stores a list of changes, and supports efficient lookup
> from a commit hash to the list of changes that reference that commit
> directly.
> 
> It can be used to look up content commits or metacommits at the head
> of a change, but does not support lookup of commits referenced as part
> of the commit history.
> 
> Signed-off-by: Stefan Xenos <sxenos@google.com>
> ---
>  Makefile       |   1 +
>  change-table.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++++
>  change-table.h | 127 +++++++++++++++++++++++++++++++++++
>  3 files changed, 304 insertions(+)
>  create mode 100644 change-table.c
>  create mode 100644 change-table.h
> 
[snip]
Show 62 quoted lines
> diff --git a/change-table.h b/change-table.h
> new file mode 100644
> index 0000000000..023bca37d1
> --- /dev/null
> +++ b/change-table.h
> @@ -0,0 +1,127 @@
> +#ifndef CHANGE_TABLE_H
> +#define CHANGE_TABLE_H
> +
> +#include "oidmap.h"
> +
> +struct commit;
> +struct ref_filter;
> +
> +/*
> + * This struct holds a list of change refs. The first element is stored inline,
> + * to optimize for small lists.
> + */
> +struct change_list {
> +	/* Ref name for the first change in the list, or null if none.
> +	 *
> +	 * This field is private. Use for_each_change_in to read.
> +	 */
> +	const char* first_refname;
> +	/* List of additional change refs. Note that this is empty if the list
> +	 * contains 0 or 1 elements.
> +	 *
> +	 * This field is private. Use for_each_change_in to read.
> +	 */
> +	struct string_list additional_refnames;
> +};
> +
> +/*
> + * Holds information about the head of a single change.
> + */
> +struct change_head {
> +	/*
> +	 * The location pointed to by the head of the change. May be a commit or a
> +	 * metacommit.
> +	 */
> +	struct object_id head;
> +	/*
> +	 * The content commit for the latest commit in the change. Always points to a
> +	 * real commit, never a metacommit.
> +	 */
> +	struct object_id content;
> +	/*
> +	 * Abandoned: indicates that the content commit should be removed from the
> +	 * history.
> +	 *
> +	 * Hidden: indicates that the change is an inactive change from the
> +	 * hiddenmetas namespace. Such changes will be hidden from the user by
> +	 * default.
> +	 *
> +	 * Deleted: indicates that the change has been removed from the repository.
> +	 * That is the ref was deleted since the time this struct was created. Such
> +	 * entries should be ignored.
> +	 */
> +	int abandoned:1,
> +		hidden:1,
> +		remote:1,
> +		deleted:1;

This causes sparse to issue errors about 'dubious one-bit signed bitfield' for each of these fields (and for each file which #includes this header file).

The field type should be 'unsigned int', thus:
-- >8 --
diff --git a/change-table.h b/change-table.h
index 85bb19c3bf..1c385e076e 100644
--- a/change-table.h
+++ b/change-table.h
@@ -50,10 +50,10 @@ struct change_head {
         * That is the ref was deleted since the time this struct was created. Such
         * entries should be ignored.
         */
-       int abandoned:1,
-               hidden:1,
-               remote:1,
-               deleted:1;
+       unsigned int abandoned:1,
+                       hidden:1,
+                       remote:1,
+                       deleted:1;
 };
 
 /*
-- >8 --

[Note: this diff was against the v3 series].

ATB,
Ramsay Jones
Previous: sxenos@google.comNext: sxenos@google.com
Message 6 of 9 in “technical doc: add a design doc for the evolve command”
  1. 1/8 technical doc: add a design doc for the evolve commandsxenos@google.com, Feb 1, 2019
  2. 2/8 sha1-array: implement oid_array_readonly_containssxenos@google.com, Feb 1, 2019
  3. 3/8 ref-filter: add the metas namespace to ref-filtersxenos@google.com, Feb 1, 2019
  4. 4/8 evolve: add support for parsing metacommitssxenos@google.com, Feb 1, 2019
  5. 5/8 evolve: add the change-table structuresxenos@google.com, Feb 1, 2019
  6. Ramsay JonesFeb 1, 2019
  7. 6/8 evolve: add support for writing metacommitssxenos@google.com, Feb 1, 2019
  8. 7/8 evolve: implement the git change commandsxenos@google.com, Feb 1, 2019
  9. 8/8 evolve: add the git change list commandsxenos@google.com, Feb 1, 2019

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.