Re: [PATCH v2 3/3] archive: do not read .gitattributes in working directory

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

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:

> @@ -168,6 +171,22 @@ int write_archive_entries(struct archiver_args *args,
>  	context.args = args;
>  	context.write_entry = write_entry;
>  
> +	/*
> +	 * Setup index and instruct attr to read index only
> +	 */
> +	if (!args->worktree_attributes) {
> +		memset(&opts, 0, sizeof(opts));
> +		opts.index_only = 1;
> +		opts.head_idx = -1;
> +		opts.src_index = &the_index;
> +		opts.dst_index = &the_index;
> +		opts.fn = oneway_merge;
> +		init_tree_desc(&t, args->tree->buffer, args->tree->size);
> +		if (unpack_trees(1, &t, &opts))
> +			return -1;
> +		git_attr_set_direction(GIT_ATTR_INDEX, &the_index);

Why use unpack_trees with oneway_merge?  You won't be doing "is this file
up-to-date in the work tree?", and you won't be writing the index out
either, so there is nothing gained by keeping the cached stat information
fresh, which is the major justification of using that mechanism.  I think
using tree.c::read_tree() would be more appropriate.

> diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
> index 0713bca..69a93fc 100644
> --- a/builtin-tar-tree.c
> +++ b/builtin-tar-tree.c
> @@ -36,6 +36,11 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
>  		argv++;
>  		argc--;
>  	}
> +	if (2 <= argc && !strcmp(argv[1], "--fix-attributes")) {
> +		nargv[nargc++] = argv[1];
> +		argv++;
> +		argc--;
> +	}

I am not sure if it is worth backporting this new option to tar-tree which
is an essentially backward-compatibility interface, and worse yet, doing
it poorly (i.e. --fix-attributes must come after --remote= for unexplained
reason).

It would affect a bit more tests, but I think you would want to test both
the new "normal" mode of operation (generate archives with "git archive"
and "git tar-tree" without options and compare, for example), instead of
adding --fix-attributes everywhere.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]