Re: [PATCH 11/16] mktree: create tree using an in-core index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 11, 2024 at 06:24:43PM +0000, Victoria Dye via GitGitGadget wrote:
> From: Victoria Dye <vdye@xxxxxxxxxx>
> diff --git a/builtin/mktree.c b/builtin/mktree.c
> index e9e2134136f..12f68187221 100644
> --- a/builtin/mktree.c
> +++ b/builtin/mktree.c
> @@ -24,6 +25,11 @@ struct tree_entry {
>  	char name[FLEX_ARRAY];
>  };
>  
> +static inline size_t df_path_len(size_t pathlen, unsigned int mode)
> +{
> +	return S_ISDIR(mode) ? pathlen - 1 : pathlen;

I wonder whether we want to have a sanity check that ensures that the
path really does have a trailing slash.

> @@ -120,24 +137,43 @@ static void sort_and_dedup_tree_entry_array(struct tree_entry_array *arr)
>  	QSORT_S(arr->entries, arr->nr, ent_compare, &ignore_mode);
>  }
>  
> +static int add_tree_entry_to_index(struct index_state *istate,
> +				   struct tree_entry *ent)
> +{
> +	struct cache_entry *ce;
> +	struct strbuf ce_name = STRBUF_INIT;
> +	strbuf_add(&ce_name, ent->name, ent->len);
> +
> +	ce = make_cache_entry(istate, ent->mode, &ent->oid, ent->name, 0, 0);
> +	if (!ce)
> +		return error(_("make_cache_entry failed for path '%s'"), ent->name);

I noticed that `make_cache_entry()` will skip over index entries which
are up-to-date, and it will replace entries which are part of the index
but with different information. Is this the motivator for the preceding
commit where we start to overwrite duplicate entries?

Patrick

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux