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

Re: [PATCH] setup: recognise extensions.objectFormat

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 25, 2018, 10:08 UTC
Message-ID
<CACsJy8BFsXAMAGYjKp8EBrepqZwgKrAtqRKyiKLOydWbpzZWWA@mail.gmail.com>
In-Reply-To
<66fb698096ed14ee58b2611f41f2e3e5dfa49059.1516798941.git.patryk.obara@gmail.com>
On Wed, Jan 24, 2018 at 8:09 PM, Patryk Obara <patryk.obara@gmail.com> wrote:
Show 16 quoted lines
> This extension selects which hashing algorithm from vtable should be
> used for reading and writing objects in the object store.  At the moment
> supports only single value (sha-1).
>
> In case value of objectFormat is an unknown hashing algorithm, Git
> command will fail with following message:
>
>   fatal: unknown repository extensions found:
>           objectformat = <value>
>
> To indicate, that this specific objectFormat value is not recognised.
>
> The objectFormat extension is not allowed in repository marked as
> version 0 to prevent any possibility of accidentally writing a NewHash
> object in the sha-1 object store. This extension behaviour is different
> than preciousObjects extension (which is allowed in repo version 0).

This config is so sensitive I wonder if we should forbid changing it via git-config. You can't simply change this and expect anything to work anyway.

"git init" can have an option to specify object format. "git clone" naturally inherits the format from the remote repository. Maybe a future command allows to convert hash algorithm on an existing repo (*). But other than that nobody is allowed to change this.

(*) it's probably git-clone that does this job, cloning and converting at the same time.

Show 7 quoted lines
> +`objectFormat`
> +~~~~~~~~~~~~~~
> +
> +This extension instructs Git to use a specific algorithm for addressing
> +and interpreting objects in the object store. Currently, the only
> +supported object format is `sha-1`.  See `hash-function-transition.txt`
> +document for more detailed explanation.
Maybe the word "experimental" should be mentioned somewhere.
Show 15 quoted lines
> +static int find_object_format(const char *value)
> +{
> +       int i;
> +       for (i = GIT_HASH_SHA1; i < GIT_HASH_NALGOS; ++i) {
> +               if (strcmp(value, hash_algos[i].name) == 0)
> +                       return i;
> +       }
> +       return GIT_HASH_UNKNOWN;
> +}
> +
> +static void detect_object_format(struct repository_format *data,
> +                                const char *value)
> +{
> +       if (data->version == 0)
> +               die("invalid repository format version");
die(_("invalid repository format version '%d'"), data->version);
Show 6 quoted lines
> +
> +       data->hash_algo = find_object_format(value);
> +       if (data->hash_algo == GIT_HASH_UNKNOWN) {
> +               char object_format[25];
> +               xsnprintf(object_format, sizeof(object_format),
> +                         "objectformat = %s", value);
We have strbuf so that we don't have to deal with fixed size buffers like this.
-- 
Duy
Previous: Patryk ObaraNext: Johannes Schindelin
Message 3 of 6 in “setup: recognise extensions.objectFormat”
  1. setup: recognise extensions.objectFormatPatryk Obara, Jan 24, 2018
  2. Patryk ObaraJan 24, 2018
  3. Duy NguyenJan 25, 2018
  4. Johannes SchindelinJan 26, 2018
  5. Patryk ObaraJan 26, 2018
  6. Stefan BellerJan 26, 2018

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.