{"thread":{"id":"18782","subject":"[PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","startedAt":"2009-04-08T10:05:25Z","lastAt":"2009-04-18T01:33:50Z","messageCount":24,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","René Scharfe","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"110816","messageId":"1239185133-4181-1-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":null,"subject":"[PATCH 0/8] support \"in-tree attributes\" for git-archive","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:25Z","receivedAt":"2009-04-08T10:05:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This series attempts to fix \"git archive\" sometimes looking into\n.gitattributes in working directory and may cause undesired effects.\n\nNguyá»n ThÃ¡i Ngá»c Duy (8):\n  archive: add shortcuts for --format and --prefix\n\nThis one is unrelated. Just a convenient patch.\n\n  move prune_cache() to git lib\n  archive: add a failure test wrt .gitattributes  misreading\n  archive: add tests for directory selection\n  attr: add GIT_ATTR_INDEX \"direction\"\n  archive: use index instead of parsing tree directly\n  archive: disregard .gitattributes on working directory\n\nMain part, which converts archive.c to load index first, then export from there.\n\n  archive: support creating archives from index\n\nWell, show off patch ;-)\n\n Documentation/git-archive.txt |    4 +-\n archive.c                     |  106 +++++++++++++++++++++++++++++++----------\n archive.h                     |    1 +\n attr.c                        |    4 +-\n attr.h                        |    3 +-\n builtin-ls-files.c            |   29 +-----------\n cache.h                       |    2 +\n read-cache.c                  |   27 ++++++++++\n t/t0024-crlf-archive.sh       |   35 +++++++++++++-\n t/t5000-tar-tree.sh           |    6 ++-\n 10 files changed, 158 insertions(+), 59 deletions(-)\n"},{"id":"110818","messageId":"1239185133-4181-2-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/8] archive: add shortcuts for --format and --prefix","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:26Z","receivedAt":"2009-04-08T10:05:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/git-archive.txt |    4 +++-\n archive.c                     |    4 ++--\n 2 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt\nindex c1adf59..c9fff54 100644\n--- a/Documentation/git-archive.txt\n+++ b/Documentation/git-archive.txt\n@@ -9,7 +9,7 @@ git-archive - Create an archive of files from a named tree\n SYNOPSIS\n --------\n [verse]\n-'git archive' --format=<fmt> [--list] [--prefix=<prefix>/] [<extra>]\n+'git archive' [-f|--format=<fmt>] [--list] [-p|--prefix=<prefix>/] [<extra>]\n \t      [--output=<file>]\n \t      [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>\n \t      [path...]\n@@ -33,6 +33,7 @@ comment.\n OPTIONS\n -------\n \n+-f=<fmt>::\n --format=<fmt>::\n \tFormat of the resulting archive: 'tar' or 'zip'.  The default\n \tis 'tar'.\n@@ -45,6 +46,7 @@ OPTIONS\n --verbose::\n \tReport progress to stderr.\n \n+-p=<prefix>/::\n --prefix=<prefix>/::\n \tPrepend <prefix>/ to each filename in the archive.\n \ndiff --git a/archive.c b/archive.c\nindex 96b62d4..e87fed7 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -260,8 +260,8 @@ static int parse_archive_args(int argc, const char **argv,\n \tint list = 0;\n \tstruct option opts[] = {\n \t\tOPT_GROUP(\"\"),\n-\t\tOPT_STRING(0, \"format\", &format, \"fmt\", \"archive format\"),\n-\t\tOPT_STRING(0, \"prefix\", &base, \"prefix\",\n+\t\tOPT_STRING('f', \"format\", &format, \"fmt\", \"archive format\"),\n+\t\tOPT_STRING('p', \"prefix\", &base, \"prefix\",\n \t\t\t\"prepend prefix to each pathname in the archive\"),\n \t\tOPT_STRING(0, \"output\", &output, \"file\",\n \t\t\t\"write the archive to this file\"),\n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110819","messageId":"1239185133-4181-3-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-2-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/8] move prune_cache() to git lib","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:27Z","receivedAt":"2009-04-08T10:05:27Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin-ls-files.c |   29 +----------------------------\n cache.h            |    2 ++\n read-cache.c       |   27 +++++++++++++++++++++++++++\n 3 files changed, 30 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin-ls-files.c b/builtin-ls-files.c\nindex 88e2697..0151647 100644\n--- a/builtin-ls-files.c\n+++ b/builtin-ls-files.c\n@@ -206,33 +206,6 @@ static void show_files(struct dir_struct *dir, const char *prefix)\n \t}\n }\n \n-/*\n- * Prune the index to only contain stuff starting with \"prefix\"\n- */\n-static void prune_cache(const char *prefix)\n-{\n-\tint pos = cache_name_pos(prefix, prefix_len);\n-\tunsigned int first, last;\n-\n-\tif (pos < 0)\n-\t\tpos = -pos-1;\n-\tmemmove(active_cache, active_cache + pos,\n-\t\t(active_nr - pos) * sizeof(struct cache_entry *));\n-\tactive_nr -= pos;\n-\tfirst = 0;\n-\tlast = active_nr;\n-\twhile (last > first) {\n-\t\tint next = (last + first) >> 1;\n-\t\tstruct cache_entry *ce = active_cache[next];\n-\t\tif (!strncmp(ce->name, prefix, prefix_len)) {\n-\t\t\tfirst = next+1;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tlast = next;\n-\t}\n-\tactive_nr = last;\n-}\n-\n static const char *verify_pathspec(const char *prefix)\n {\n \tconst char **p, *n, *prev;\n@@ -541,7 +514,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\tshow_cached = 1;\n \n \tif (prefix)\n-\t\tprune_cache(prefix);\n+\t\tprune_cache(prefix, prefix_len);\n \tif (with_tree) {\n \t\t/*\n \t\t * Basic sanity check; show-stages and show-unmerged\ndiff --git a/cache.h b/cache.h\nindex ab1294d..54660a5 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -335,6 +335,7 @@ static inline void remove_name_hash(struct cache_entry *ce)\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n #define cache_name_exists(name, namelen, igncase) index_name_exists(&the_index, (name), (namelen), (igncase))\n #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))\n+#define prune_cache(prefix, prefix_len) prune_index((prefix), (prefix_len), &the_index);\n #endif\n \n enum object_type {\n@@ -455,6 +456,7 @@ extern int add_file_to_index(struct index_state *, const char *path, int flags);\n extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);\n extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n+extern void prune_index(const char *prefix, int prefix_len, struct index_state *istate);\n \n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\ndiff --git a/read-cache.c b/read-cache.c\nindex 3f58711..74f889e 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1706,3 +1706,30 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n \t}\n \treturn 1;\n }\n+\n+/*\n+ * Prune the index to only contain stuff starting with \"prefix\"\n+ */\n+void prune_index(const char *prefix, int prefix_len, struct index_state *istate)\n+{\n+\tint pos = index_name_pos(istate, prefix, prefix_len);\n+\tunsigned int first, last;\n+\n+\tif (pos < 0)\n+\t\tpos = -pos-1;\n+\tmemmove(istate->cache, istate->cache + pos,\n+\t\t(istate->cache_nr - pos) * sizeof(struct cache_entry *));\n+\tistate->cache_nr -= pos;\n+\tfirst = 0;\n+\tlast = istate->cache_nr;\n+\twhile (last > first) {\n+\t\tint next = (last + first) >> 1;\n+\t\tstruct cache_entry *ce = istate->cache[next];\n+\t\tif (!strncmp(ce->name, prefix, prefix_len)) {\n+\t\t\tfirst = next+1;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tlast = next;\n+\t}\n+\tistate->cache_nr = last;\n+}\n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110814","messageId":"1239185133-4181-4-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-3-git-send-email-pclouds@gmail.com","subject":"[PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:28Z","receivedAt":"2009-04-08T10:05:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"git archive\" is used to create archives from a tree (or commit), so\nit should not consult any .gitattributes files on working directory.\n\nIt currently does, so this patch records the failure.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n t/t0024-crlf-archive.sh |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh\nindex c7d0324..9c56e0e 100755\n--- a/t/t0024-crlf-archive.sh\n+++ b/t/t0024-crlf-archive.sh\n@@ -43,4 +43,11 @@ test_expect_success UNZIP 'zip archive' '\n \n '\n \n+test_expect_failure '.gitattributes in workdir should not be consulted' '\n+\techo \"sample -crlf\" > .gitattributes &&\n+\tgit archive --format=tar HEAD |\n+\t( mkdir untarred2 && cd untarred2 && \"$TAR\" -xf - )\n+\ttest_cmp sample untarred2/sample\n+'\n+\n test_done\n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110815","messageId":"1239185133-4181-5-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-4-git-send-email-pclouds@gmail.com","subject":"[PATCH 4/8] archive: add tests for directory selection","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:29Z","receivedAt":"2009-04-08T10:05:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"While in archive.c, it says \"pathspec\". It's not really pathspec.\nMake a few tests to catch this point.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n archive.c               |   17 +++++++++++++++++\n t/t0024-crlf-archive.sh |   30 +++++++++++++++++++++++++++++-\n 2 files changed, 46 insertions(+), 1 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex e87fed7..5b54d95 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -15,6 +15,8 @@ static char const * const archive_usage[] = {\n \n #define USES_ZLIB_COMPRESSION 1\n \n+static int list_archive(struct archiver_args *args);\n+\n static const struct archiver {\n \tconst char *name;\n \twrite_archive_fn_t write_archive;\n@@ -22,8 +24,23 @@ static const struct archiver {\n } archivers[] = {\n \t{ \"tar\", write_tar_archive },\n \t{ \"zip\", write_zip_archive, USES_ZLIB_COMPRESSION },\n+\t{ \"dump-file-list\", list_archive },\n };\n \n+static int list_archive_entry(struct archiver_args *args,\n+\t\tconst unsigned char *sha1, const char *path, size_t pathlen,\n+\t\tunsigned int mode, void *buffer, unsigned long size)\n+{\n+\tprintf(\"%s\\n\", path);\n+\treturn 0;\n+}\n+\n+static int list_archive(struct archiver_args *args)\n+{\n+\twrite_archive_entries(args, list_archive_entry);\n+\treturn 0;\n+}\n+\n static void format_subst(const struct commit *commit,\n                          const char *src, size_t len,\n                          struct strbuf *buf)\ndiff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh\nindex 9c56e0e..695ad5a 100755\n--- a/t/t0024-crlf-archive.sh\n+++ b/t/t0024-crlf-archive.sh\n@@ -9,14 +9,42 @@ test_expect_success setup '\n \n \tgit config core.autocrlf true\n \n+\tmkdir sub &&\n \tprintf \"CRLF line ending\\r\\nAnd another\\r\\n\" > sample &&\n-\tgit add sample &&\n+\tcp sample sub/sample &&\n+\tgit add sample sub/sample &&\n \n \ttest_tick &&\n \tgit commit -m Initial\n \n '\n \n+cat <<\\EOF > expected\n+sample\n+sub/\n+sub/sample\n+EOF\n+\n+test_expect_success 'archive without subdir' '\n+\tgit archive --format=dump-file-list HEAD > output &&\n+\ttest_cmp output expected\n+'\n+\n+cat <<\\EOF > expected\n+sub/\n+sub/sample\n+EOF\n+\n+test_expect_success 'archive with subdir' '\n+\tgit archive --format=dump-file-list HEAD sub > output &&\n+\ttest_cmp output expected\n+'\n+\n+test_expect_success 'subdir is not pathspec' '\n+\ttest \"$(git archive --format=dump-file-list HEAD sub/)\" = \"\"\n+\ttest \"$(git archive --format=dump-file-list HEAD s\\*)\" = \"\"\n+'\n+\n test_expect_success 'tar archive' '\n \n \tgit archive --format=tar HEAD |\n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110817","messageId":"1239185133-4181-6-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-5-git-send-email-pclouds@gmail.com","subject":"[PATCH 5/8] attr: add GIT_ATTR_INDEX \"direction\"","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:30Z","receivedAt":"2009-04-08T10:05:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This instructs attr mechanism not to look into working .gitattributes\nat all. Needed by tools that does not handle working directory, such\nas \"git archive\".\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n attr.c |    4 +++-\n attr.h |    3 ++-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 43259e5..37ca288 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -405,7 +405,7 @@ static struct attr_stack *read_attr(const char *path, int macro_ok)\n \t\tif (!res)\n \t\t\tres = read_attr_from_file(path, macro_ok);\n \t}\n-\telse {\n+\telse if (direction == GIT_ATTR_CHECKIN) {\n \t\tres = read_attr_from_file(path, macro_ok);\n \t\tif (!res)\n \t\t\t/*\n@@ -415,6 +415,8 @@ static struct attr_stack *read_attr(const char *path, int macro_ok)\n \t\t\t */\n \t\t\tres = read_attr_from_index(path, macro_ok);\n \t}\n+\telse\n+\t\tres = read_attr_from_index(path, macro_ok);\n \tif (!res)\n \t\tres = xcalloc(1, sizeof(*res));\n \treturn res;\ndiff --git a/attr.h b/attr.h\nindex 3a2f4ec..69b5767 100644\n--- a/attr.h\n+++ b/attr.h\n@@ -33,7 +33,8 @@ int git_checkattr(const char *path, int, struct git_attr_check *);\n \n enum git_attr_direction {\n \tGIT_ATTR_CHECKIN,\n-\tGIT_ATTR_CHECKOUT\n+\tGIT_ATTR_CHECKOUT,\n+\tGIT_ATTR_INDEX,\n };\n void git_attr_set_direction(enum git_attr_direction, struct index_state *);\n \n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110820","messageId":"1239185133-4181-7-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-6-git-send-email-pclouds@gmail.com","subject":"[PATCH 6/8] archive: use index instead of parsing tree directly","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:31Z","receivedAt":"2009-04-08T10:05:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Currently:\n\n - \"git archive\" parses trees directly\n - attr mechanism does not support in-tree attributes\n\nMaking attr.c support in-tree attributes is quite a non-trivial task,\nIMHO. Instead this patch makes \"git archive\" read tree to index first,\nthen start exporting from there.\n\nOne minor regression: \"git archive\" now will no longer generate\ndirectory entries, only files.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n archive.c               |   66 ++++++++++++++++++++++++++++++++---------------\n t/t0024-crlf-archive.sh |    2 -\n 2 files changed, 45 insertions(+), 23 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 5b54d95..402f6d4 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -4,6 +4,8 @@\n #include \"attr.h\"\n #include \"archive.h\"\n #include \"parse-options.h\"\n+#include \"unpack-trees.h\"\n+#include \"dir.h\"\n \n static char const * const archive_usage[] = {\n \t\"git archive [options] <tree-ish> [path...]\",\n@@ -167,7 +169,9 @@ int write_archive_entries(struct archiver_args *args,\n \t\twrite_archive_entry_fn_t write_entry)\n {\n \tstruct archiver_context context;\n-\tint err;\n+\tstruct unpack_trees_options opts;\n+\tstruct tree_desc t;\n+\tint i, prefix_len, err;\n \n \tif (args->baselen > 0 && args->base[args->baselen - 1] == '/') {\n \t\tsize_t len = args->baselen;\n@@ -185,11 +189,42 @@ int write_archive_entries(struct archiver_args *args,\n \tcontext.args = args;\n \tcontext.write_entry = write_entry;\n \n-\terr =  read_tree_recursive(args->tree, args->base, args->baselen, 0,\n-\t\t\targs->pathspec, write_archive_entry, &context);\n-\tif (err == READ_TREE_RECURSIVE)\n-\t\terr = 0;\n-\treturn err;\n+\tmemset(&opts, 0, sizeof(opts));\n+\topts.index_only = 1;\n+\topts.head_idx = -1;\n+\topts.src_index = &the_index;\n+\topts.dst_index = &the_index;\n+\topts.fn = oneway_merge;\n+\tinit_tree_desc(&t, args->tree->buffer, args->tree->size);\n+\tif (unpack_trees(1, &t, &opts))\n+\t\treturn -1;\n+\tprefix_len = common_prefix(args->pathspec);\n+\tif (prefix_len)\n+\t\tprune_cache(args->pathspec[0], prefix_len);\n+\n+\tfor (i = 0;i < active_nr;i++) {\n+\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst char **path;\n+\t\tconst char *str, *prefix;\n+\t\tint match = 0;\n+\n+\t\tif (!args->pathspec || !args->pathspec[0] || !*args->pathspec[0])\n+\t\t\tmatch = 1;\n+\n+\t\t/* It's not really pathspec, so match_pathspec can't be used */\n+\t\tfor (path = args->pathspec;!match && *path;path++) {\n+\t\t\tfor (str = ce->name, prefix = *path;*prefix && *str == *prefix; str++, prefix++)\n+\t\t\t\t;\n+\t\t\tif (!*prefix && *str == '/')\n+\t\t\t\tmatch = 1;\n+\t\t}\n+\n+\t\tif (match)\n+\t\t\twrite_archive_entry(ce->sha1, args->base, args->baselen,\n+\t\t\t\t\t    ce->name, ce->ce_mode, ce_stage(ce),\n+\t\t\t\t\t    &context);\n+\t}\n+\treturn 0;\n }\n \n static const struct archiver *lookup_archiver(const char *name)\n@@ -207,9 +242,10 @@ static const struct archiver *lookup_archiver(const char *name)\n }\n \n static void parse_pathspec_arg(const char **pathspec,\n-\t\tstruct archiver_args *ar_args)\n+\t\t\t       struct archiver_args *ar_args,\n+\t\t\t       const char *prefix)\n {\n-\tar_args->pathspec = get_pathspec(ar_args->base, pathspec);\n+\tar_args->pathspec = get_pathspec(prefix, pathspec);\n }\n \n static void parse_treeish_arg(const char **argv,\n@@ -238,18 +274,6 @@ static void parse_treeish_arg(const char **argv,\n \tif (tree == NULL)\n \t\tdie(\"not a tree object\");\n \n-\tif (prefix) {\n-\t\tunsigned char tree_sha1[20];\n-\t\tunsigned int mode;\n-\t\tint err;\n-\n-\t\terr = get_tree_entry(tree->object.sha1, prefix,\n-\t\t\t\t     tree_sha1, &mode);\n-\t\tif (err || !S_ISDIR(mode))\n-\t\t\tdie(\"current working directory is untracked\");\n-\n-\t\ttree = parse_tree_indirect(tree_sha1);\n-\t}\n \tar_args->tree = tree;\n \tar_args->commit_sha1 = commit_sha1;\n \tar_args->commit = commit;\n@@ -356,7 +380,7 @@ int write_archive(int argc, const char **argv, const char *prefix,\n \t\tprefix = setup_git_directory();\n \n \tparse_treeish_arg(argv, &args, prefix);\n-\tparse_pathspec_arg(argv + 1, &args);\n+\tparse_pathspec_arg(argv + 1, &args, prefix);\n \n \tgit_config(git_default_config, NULL);\n \ndiff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh\nindex 695ad5a..1cbe511 100755\n--- a/t/t0024-crlf-archive.sh\n+++ b/t/t0024-crlf-archive.sh\n@@ -21,7 +21,6 @@ test_expect_success setup '\n \n cat <<\\EOF > expected\n sample\n-sub/\n sub/sample\n EOF\n \n@@ -31,7 +30,6 @@ test_expect_success 'archive without subdir' '\n '\n \n cat <<\\EOF > expected\n-sub/\n sub/sample\n EOF\n \n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110822","messageId":"1239185133-4181-8-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-7-git-send-email-pclouds@gmail.com","subject":"[PATCH 7/8] archive: disregard .gitattributes on working directory","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:32Z","receivedAt":"2009-04-08T10:05:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Some tests in t500-tar-tree.sh depends on in-worktree\n.gitattributes. Fix them too.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n We could make an option to keep old behaviour. But is it worth it?\n\n archive.c               |    1 +\n t/t0024-crlf-archive.sh |    2 +-\n t/t5000-tar-tree.sh     |    6 +++++-\n 3 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 402f6d4..1ce644e 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -138,6 +138,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,\n \tpath_without_prefix = path.buf + args->baselen;\n \n \tsetup_archive_check(check);\n+\tgit_attr_set_direction(GIT_ATTR_INDEX, &the_index);\n \tif (!git_checkattr(path_without_prefix, ARRAY_SIZE(check), check)) {\n \t\tif (ATTR_TRUE(check[0].value))\n \t\t\treturn 0;\ndiff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh\nindex 1cbe511..bf531fc 100755\n--- a/t/t0024-crlf-archive.sh\n+++ b/t/t0024-crlf-archive.sh\n@@ -69,7 +69,7 @@ test_expect_success UNZIP 'zip archive' '\n \n '\n \n-test_expect_failure '.gitattributes in workdir should not be consulted' '\n+test_expect_success '.gitattributes in workdir should not be consulted' '\n \techo \"sample -crlf\" > .gitattributes &&\n \tgit archive --format=tar HEAD |\n \t( mkdir untarred2 && cd untarred2 && \"$TAR\" -xf - )\ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex 7641e0d..420e7ad 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -56,6 +56,7 @@ test_expect_success \\\n     'add files to repository' \\\n     'find a -type f | xargs git update-index --add &&\n      find a -type l | xargs git update-index --add &&\n+     git update-index --add .gitattributes &&\n      treeid=`git write-tree` &&\n      echo $treeid >treeid &&\n      git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE=\"2005-05-27 22:00:00\" \\\n@@ -140,6 +141,8 @@ test_expect_success \\\n test_expect_success \\\n     'create archives with substfiles' \\\n     'echo \"substfile?\" export-subst >a/.gitattributes &&\n+     git add a/.gitattributes &&\n+     git commit -q -m new &&\n      git archive HEAD >f.tar &&\n      git archive --prefix=prefix/ HEAD >g.tar &&\n      rm a/.gitattributes'\n@@ -165,7 +168,8 @@ test_expect_success \\\n      'git log --max-count=1 \"--pretty=format:A${SUBSTFORMAT}O\" HEAD \\\n       >g/prefix/a/substfile1.expected &&\n       test_cmp g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&\n-      test_cmp a/substfile2 g/prefix/a/substfile2\n+      test_cmp a/substfile2 g/prefix/a/substfile2 &&\n+      git reset HEAD^\n '\n \n test_expect_success \\\n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110821","messageId":"1239185133-4181-9-git-send-email-pclouds@gmail.com","threadId":"18782","inReplyTo":"1239185133-4181-8-git-send-email-pclouds@gmail.com","subject":"[PATCH 8/8] archive: support creating archives from index","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-08T10:05:33Z","receivedAt":"2009-04-08T10:05:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is more or less for fun. Does anyone really want to create archives\nfrom index?\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n archive.c |   38 +++++++++++++++++++++++++-------------\n archive.h |    1 +\n 2 files changed, 26 insertions(+), 13 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 1ce644e..bb0a0f1 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -181,7 +181,7 @@ int write_archive_entries(struct archiver_args *args,\n \t\t\tlen--;\n \t\tif (args->verbose)\n \t\t\tfprintf(stderr, \"%.*s\\n\", (int)len, args->base);\n-\t\terr = write_entry(args, args->tree->object.sha1, args->base,\n+\t\terr = write_entry(args, args->tree ? args->tree->object.sha1 : null_sha1, args->base,\n \t\t\t\tlen, 040777, NULL, 0);\n \t\tif (err)\n \t\t\treturn err;\n@@ -190,15 +190,19 @@ int write_archive_entries(struct archiver_args *args,\n \tcontext.args = args;\n \tcontext.write_entry = write_entry;\n \n-\tmemset(&opts, 0, sizeof(opts));\n-\topts.index_only = 1;\n-\topts.head_idx = -1;\n-\topts.src_index = &the_index;\n-\topts.dst_index = &the_index;\n-\topts.fn = oneway_merge;\n-\tinit_tree_desc(&t, args->tree->buffer, args->tree->size);\n-\tif (unpack_trees(1, &t, &opts))\n-\t\treturn -1;\n+\tif (args->tree) {\n+\t\tmemset(&opts, 0, sizeof(opts));\n+\t\topts.index_only = 1;\n+\t\topts.head_idx = -1;\n+\t\topts.src_index = &the_index;\n+\t\topts.dst_index = &the_index;\n+\t\topts.fn = oneway_merge;\n+\t\tinit_tree_desc(&t, args->tree->buffer, args->tree->size);\n+\t\tif (unpack_trees(1, &t, &opts))\n+\t\t\treturn -1;\n+\t}\n+\telse\n+\t\tread_cache();\n \tprefix_len = common_prefix(args->pathspec);\n \tif (prefix_len)\n \t\tprune_cache(args->pathspec[0], prefix_len);\n@@ -300,6 +304,7 @@ static int parse_archive_args(int argc, const char **argv,\n \tint verbose = 0;\n \tint i;\n \tint list = 0;\n+\tint use_index = 0;\n \tstruct option opts[] = {\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_STRING('f', \"format\", &format, \"fmt\", \"archive format\"),\n@@ -307,6 +312,8 @@ static int parse_archive_args(int argc, const char **argv,\n \t\t\t\"prepend prefix to each pathname in the archive\"),\n \t\tOPT_STRING(0, \"output\", &output, \"file\",\n \t\t\t\"write the archive to this file\"),\n+\t\tOPT_BOOLEAN('i', \"index\", &use_index,\n+\t\t\t\"generate from index instead\"),\n \t\tOPT__VERBOSE(&verbose),\n \t\tOPT__COMPR('0', &compression_level, \"store only\", 0),\n \t\tOPT__COMPR('1', &compression_level, \"compress faster\", 1),\n@@ -348,7 +355,7 @@ static int parse_archive_args(int argc, const char **argv,\n \t}\n \n \t/* We need at least one parameter -- tree-ish */\n-\tif (argc < 1)\n+\tif (argc < 1 && !use_index)\n \t\tusage_with_options(archive_usage, opts);\n \t*ar = lookup_archiver(format);\n \tif (!*ar)\n@@ -366,6 +373,7 @@ static int parse_archive_args(int argc, const char **argv,\n \targs->verbose = verbose;\n \targs->base = base;\n \targs->baselen = strlen(base);\n+\targs->use_index = use_index;\n \n \treturn argc;\n }\n@@ -376,12 +384,16 @@ int write_archive(int argc, const char **argv, const char *prefix,\n \tconst struct archiver *ar = NULL;\n \tstruct archiver_args args;\n \n+\tmemset(&args, 0, sizeof(args));\n \targc = parse_archive_args(argc, argv, &ar, &args);\n \tif (setup_prefix && prefix == NULL)\n \t\tprefix = setup_git_directory();\n \n-\tparse_treeish_arg(argv, &args, prefix);\n-\tparse_pathspec_arg(argv + 1, &args, prefix);\n+\tif (!args.use_index) {\n+\t\tparse_treeish_arg(argv, &args, prefix);\n+\t\targv++;\n+\t}\n+\tparse_pathspec_arg(argv, &args, prefix);\n \n \tgit_config(git_default_config, NULL);\n \ndiff --git a/archive.h b/archive.h\nindex 0b15b35..fb94d47 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -10,6 +10,7 @@ struct archiver_args {\n \ttime_t time;\n \tconst char **pathspec;\n \tunsigned int verbose : 1;\n+\tunsigned int use_index : 1;\n \tint compression_level;\n };\n \n-- \n1.6.2.2.602.g83ee9f\n"},{"id":"110861","messageId":"7vhc0zkl5t.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"1239185133-4181-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 2/8] move prune_cache() to git lib","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-08T19:19:58Z","receivedAt":"2009-04-08T19:19:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> +#define prune_cache(prefix, prefix_len) prune_index((prefix), (prefix_len), &the_index);\n> ...\n> +extern void prune_index(const char *prefix, int prefix_len, struct index_state *istate);\n\nPlease make *istate the first parameter to be consistent with other\ndistim_cache() wrappers for distim_index().\n"},{"id":"110860","messageId":"7vab6rkl5f.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"1239185133-4181-4-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-08T19:20:12Z","receivedAt":"2009-04-08T19:20:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> \"git archive\" is used to create archives from a tree (or commit), so\n> it should not consult any .gitattributes files on working directory.\n>\n> It currently does,...\n\n...which _might_ be actively used as a _feature_ by people; I do not think\nit is a bad idea to have a mode of operation where it solely works with\nin-tree attributes ignoring the work tree ones, and I suspect we probably\nwould want to make that the default, but \"so it should not\" is probably a\nbit too strong.\n\nFor example, an older version may record $Id$ with keyword expansion set\nin its in-tree .gitattributes, and you later found it to be a mistake and\nhave removed it in the current version.  Re-exporting an older version\nwith the current code wouldn't have $Id$ expanded, but with your patch it\nwill.\n\nA stronger example would be crlf conversion, I suppose, but the same \"with\nthe current code we can fix it up but after this patch we can't\" worry\napplies.\n\nSo perhaps you may want to resurrect the current behaviour with a new\noption --fix-attributes, whose description would be \"normally the command\ntakes attributes settings from the tree being exported, but .gitattributes\nfiles in it may record wrong attributes you may want to fix while\nexporting.  With this option, corresponding .gitattributes files in the\nwork tree will override the in-tree .gitattributes\" or something like\nthat.\n"},{"id":"110863","messageId":"7v3acjkl4y.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"1239185133-4181-8-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 7/8] archive: disregard .gitattributes on working directory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-08T19:20:29Z","receivedAt":"2009-04-08T19:20:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Some tests in t500-tar-tree.sh depends on in-worktree\n> .gitattributes. Fix them too.\n\ns/500/5000/;\n\nYou can also consider these as examples of possibly useful use cases of\nthe current \"fix-attributes\" feature you are breaking with this patch (see\nmy comments to 3/8).\n"},{"id":"110862","messageId":"7vvdpfj6jz.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"1239185133-4181-7-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 6/8] archive: use index instead of parsing tree directly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-08T19:20:48Z","receivedAt":"2009-04-08T19:20:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Currently:\n>\n>  - \"git archive\" parses trees directly\n>  - attr mechanism does not support in-tree attributes\n>\n> Making attr.c support in-tree attributes is quite a non-trivial task,\n> IMHO. Instead this patch makes \"git archive\" read tree to index first,\n> then start exporting from there.\n>\n> One minor regression: \"git archive\" now will no longer generate\n> directory entries, only files.\n\nHmmm, if you read_tree() into the_index upfront and do not change anything\nelse to the archive.c code, shouldn't it work without such a regression at\nall?  Am I missing something?\n\nIt would allow you to export the index into an archive, but I doubt it is\nworth the amount of code churn.\n"},{"id":"110865","messageId":"49DD0043.9080803@lsrfire.ath.cx","threadId":"18782","inReplyTo":"1239185133-4181-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/8] archive: add shortcuts for --format and --prefix","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-08T19:51:31Z","receivedAt":"2009-04-08T19:51:31Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyễn Thái Ngọc Duy schrieb:\n> +-f=<fmt>::\n>  --format=<fmt>::\n>  \tFormat of the resulting archive: 'tar' or 'zip'.  The default\n>  \tis 'tar'.\n> @@ -45,6 +46,7 @@ OPTIONS\n>  --verbose::\n>  \tReport progress to stderr.\n>  \n> +-p=<prefix>/::\n>  --prefix=<prefix>/::\n>  \tPrepend <prefix>/ to each filename in the archive.\n\nWith short options, you can't use an equal sign to separate their\nparameters (-f=<fmt> vs. -f<fmt>).\n\nRené\n"},{"id":"110866","messageId":"49DD0067.1070002@lsrfire.ath.cx","threadId":"18782","inReplyTo":"1239185133-4181-5-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 4/8] archive: add tests for directory selection","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-08T19:52:07Z","receivedAt":"2009-04-08T19:52:07Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyễn Thái Ngọc Duy schrieb:\n> While in archive.c, it says \"pathspec\". It's not really pathspec.\n> Make a few tests to catch this point.\n> \n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  archive.c               |   17 +++++++++++++++++\n>  t/t0024-crlf-archive.sh |   30 +++++++++++++++++++++++++++++-\n>  2 files changed, 46 insertions(+), 1 deletions(-)\n> \n> diff --git a/archive.c b/archive.c\n> index e87fed7..5b54d95 100644\n> --- a/archive.c\n> +++ b/archive.c\n> @@ -15,6 +15,8 @@ static char const * const archive_usage[] = {\n>  \n>  #define USES_ZLIB_COMPRESSION 1\n>  \n> +static int list_archive(struct archiver_args *args);\n> +\n>  static const struct archiver {\n>  \tconst char *name;\n>  \twrite_archive_fn_t write_archive;\n> @@ -22,8 +24,23 @@ static const struct archiver {\n>  } archivers[] = {\n>  \t{ \"tar\", write_tar_archive },\n>  \t{ \"zip\", write_zip_archive, USES_ZLIB_COMPRESSION },\n> +\t{ \"dump-file-list\", list_archive },\n>  };\n>  \n> +static int list_archive_entry(struct archiver_args *args,\n> +\t\tconst unsigned char *sha1, const char *path, size_t pathlen,\n> +\t\tunsigned int mode, void *buffer, unsigned long size)\n> +{\n> +\tprintf(\"%s\\n\", path);\n> +\treturn 0;\n> +}\n\ngit archive dumps all its output, so I think \"file-list\" would be a\nbetter name for an archiver creating lists of files.\n\nHowever, if you only need it for tests (I can't imagine other uses at\nthe moment), you could do something like this instead:\n\n\t$ git archive -v HEAD >/dev/null 2>file-list\n\nIt might be wasteful since it creates a full archive (including file\ncontents) and throws it away, but it's OK for testing purposes.\n\nRené\n"},{"id":"110869","messageId":"49DD0B97.6040403@lsrfire.ath.cx","threadId":"18782","inReplyTo":"1239185133-4181-7-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 6/8] archive: use index instead of parsing tree directly","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-08T20:39:51Z","receivedAt":"2009-04-08T20:39:51Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyễn Thái Ngọc Duy schrieb:\n> +\t\t/* It's not really pathspec, so match_pathspec can't be used */\n> +\t\tfor (path = args->pathspec;!match && *path;path++) {\n> +\t\t\tfor (str = ce->name, prefix = *path;*prefix && *str == *prefix; str++, prefix++)\n> +\t\t\t\t;\n> +\t\t\tif (!*prefix && *str == '/')\n> +\t\t\t\tmatch = 1;\n> +\t\t}\n\nThis works with, e.g.:\n\n\tgit archive HEAD Documentation\n\nbut not with:\n\n\tgit archive HEAD Makefile\n\nor:\n\tgit archive HEAD Documentation/\n\nRené\n"},{"id":"110870","messageId":"49DD0DAB.8090609@lsrfire.ath.cx","threadId":"18782","inReplyTo":"1239185133-4181-9-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 8/8] archive: support creating archives from index","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-08T20:48:43Z","receivedAt":"2009-04-08T20:48:43Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyễn Thái Ngọc Duy schrieb:\n> This is more or less for fun. Does anyone really want to create archives\n> from index?\n\nPerhaps, but I think it would be better implemented similar to git grep.\n\nRené\n"},{"id":"110872","messageId":"49DD10EB.3090706@lsrfire.ath.cx","threadId":"18782","inReplyTo":"1239185133-4181-7-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 6/8] archive: use index instead of parsing tree directly","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-08T21:02:35Z","receivedAt":"2009-04-08T21:02:35Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyễn Thái Ngọc Duy schrieb:\n> Currently:\n> \n>  - \"git archive\" parses trees directly\n>  - attr mechanism does not support in-tree attributes\n> \n> Making attr.c support in-tree attributes is quite a non-trivial task,\n> IMHO. Instead this patch makes \"git archive\" read tree to index first,\n> then start exporting from there.\n> \n> One minor regression: \"git archive\" now will no longer generate\n> directory entries, only files.\n\nI don't like the need to prepare an index of all paths up front, but\nthat's just a gut feeling.  I haven't looked into implementing in-tree\nattribute support in attr.c; is it really that hard?  Other commands\nwould benefit from this, too, right (e.g. any command using attributes\nin a bare repo)?\n\nRené\n"},{"id":"111190","messageId":"49E3448B.8010602@lsrfire.ath.cx","threadId":"18782","inReplyTo":"7vab6rkl5f.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-13T13:56:27Z","receivedAt":"2009-04-13T13:56:27Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Junio C Hamano schrieb:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n> \n>> \"git archive\" is used to create archives from a tree (or commit), so\n>> it should not consult any .gitattributes files on working directory.\n>>\n>> It currently does,...\n> \n> ...which _might_ be actively used as a _feature_ by people; I do not think\n> it is a bad idea to have a mode of operation where it solely works with\n> in-tree attributes ignoring the work tree ones, and I suspect we probably\n> would want to make that the default, but \"so it should not\" is probably a\n> bit too strong.\n> \n> For example, an older version may record $Id$ with keyword expansion set\n> in its in-tree .gitattributes, and you later found it to be a mistake and\n> have removed it in the current version.  Re-exporting an older version\n> with the current code wouldn't have $Id$ expanded, but with your patch it\n> will.\n> \n> A stronger example would be crlf conversion, I suppose, but the same \"with\n> the current code we can fix it up but after this patch we can't\" worry\n> applies.\n> \n> So perhaps you may want to resurrect the current behaviour with a new\n> option --fix-attributes, whose description would be \"normally the command\n> takes attributes settings from the tree being exported, but .gitattributes\n> files in it may record wrong attributes you may want to fix while\n> exporting.  With this option, corresponding .gitattributes files in the\n> work tree will override the in-tree .gitattributes\" or something like\n> that.\n\nHmm, \"fix\" implies that something is broken without this option, which\nis not necessarily the case.  A purely descriptive name like\n--worktree-attributes fits better IMHO.\n\nAlso, the last sentence of the description may be taken to imply a\nmixing of attributes from work tree and exported tree is done, which is\nnot the case with the patch from series 2 (and shouldn't be).  Perhaps:\n\"With this option, .gitattributes files are read from the work tree\ninstead of from the exported tree.\"\n\nRené\n"},{"id":"111271","messageId":"fcaeb9bf0904132341s777ca697p1930df10eb1ff37b@mail.gmail.com","threadId":"18782","inReplyTo":"49E3448B.8010602@lsrfire.ath.cx","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-14T06:41:53Z","receivedAt":"2009-04-14T06:41:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2009/4/13 René Scharfe <rene.scharfe@lsrfire.ath.cx>:\n> Also, the last sentence of the description may be taken to imply a\n> mixing of attributes from work tree and exported tree is done, which is\n> not the case with the patch from series 2 (and shouldn't be).  Perhaps:\n> \"With this option, .gitattributes files are read from the work tree\n> instead of from the exported tree.\"\n\nI'm at work and haven't had chance to read other mails carefully. Wrt\nto the description, it reads from index too if it fails to read from\nworktree. So perhaps \"With this option, .gitattributes files are read\nfrom work tree (or from index if they are missing from work tree)\ninstead of from exported tree.\", unless you want to introduce another\n\"attr direction\" to read from work tree only.\n-- \nDuy\n"},{"id":"111311","messageId":"49E4EE49.6030404@lsrfire.ath.cx","threadId":"18782","inReplyTo":"fcaeb9bf0904132341s777ca697p1930df10eb1ff37b@mail.gmail.com","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-14T20:12:57Z","receivedAt":"2009-04-14T20:12:57Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Nguyen Thai Ngoc Duy schrieb:\n> 2009/4/13 René Scharfe <rene.scharfe@lsrfire.ath.cx>:\n>> Also, the last sentence of the description may be taken to imply a\n>> mixing of attributes from work tree and exported tree is done, which is\n>> not the case with the patch from series 2 (and shouldn't be).  Perhaps:\n>> \"With this option, .gitattributes files are read from the work tree\n>> instead of from the exported tree.\"\n> \n> I'm at work and haven't had chance to read other mails carefully. Wrt\n> to the description, it reads from index too if it fails to read from\n> worktree. So perhaps \"With this option, .gitattributes files are read\n> from work tree (or from index if they are missing from work tree)\n> instead of from exported tree.\", unless you want to introduce another\n> \"attr direction\" to read from work tree only.\n\nErr, yes, that was nonsense, please disregard this part.  Sorry.  I\nsomehow mixed up falling back to the index and merging the contents of\nattribute files from both sources, not sure why. :-/\n\nRené\n"},{"id":"111433","messageId":"7v4owpm2il.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"49E3448B.8010602@lsrfire.ath.cx","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-16T08:22:26Z","receivedAt":"2009-04-16T08:22:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Hmm, \"fix\" implies that something is broken without this option, which\n> is not necessarily the case.\n\n\"What is recorded in the tree is unsuitable for the purpose of this\nparticular export, so we are xxxing using yyy\", is the intended use case,\nand I think the verb \"fix\" is a good fit there in \"xxx\" part.  \"Tweak\"\nwould also work well.\n\nYour suggestion is to say \"attributes from the work tree\" in place of\n\"yyy\", which also is good.\n\nI got the impression that people tend to prefer the operation named after\nwhat it does than how it does it, but I can go either way.\n"},{"id":"111533","messageId":"49E8E368.2010703@lsrfire.ath.cx","threadId":"18782","inReplyTo":"7v4owpm2il.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-04-17T20:15:36Z","receivedAt":"2009-04-17T20:15:36Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Junio C Hamano schrieb:\n> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n> \n>> Hmm, \"fix\" implies that something is broken without this option, which\n>> is not necessarily the case.\n> \n> \"What is recorded in the tree is unsuitable for the purpose of this\n> particular export, so we are xxxing using yyy\", is the intended use case,\n> and I think the verb \"fix\" is a good fit there in \"xxx\" part.  \"Tweak\"\n> would also work well.\n> \n> Your suggestion is to say \"attributes from the work tree\" in place of\n> \"yyy\", which also is good.\n\n> I got the impression that people tend to prefer the operation named after\n> what it does than how it does it, but I can go either way.\n\nThat's a good rule to follow in general.  \"Fix\" sounds to me as if git's\ndefault behaviour is wrong and needs an option to make it work\ncorrectly, though.  It's too broad a term.\n\nI think the fixing, tweaking or even breaking will be done by the user,\nwhen editing the attribute files in the work tree.  git then only\napplies or evaluates these attributes, creating the archive using a\ndifferent source of meta data.  \"--worktree-attributes\" captures this\nnicely.\n\nRené\n"},{"id":"111557","messageId":"7vocuuzqwx.fsf@gitster.siamese.dyndns.org","threadId":"18782","inReplyTo":"49E8E368.2010703@lsrfire.ath.cx","subject":"Re: [PATCH 3/8] archive: add a failure test wrt .gitattributes misreading","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-18T01:33:50Z","receivedAt":"2009-04-18T01:33:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> I think the fixing, tweaking or even breaking will be done by the user,\n> when editing the attribute files in the work tree.  git then only\n> applies or evaluates these attributes, creating the archive using a\n> different source of meta data.  \"--worktree-attributes\" captures this\n> nicely.\n\nYeah, that sounds like a sane idea.  I see you already made it so with\nyour v2 4/5.\n\nThanks.\n"}]}