From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 4/5] archive: do not read .gitattributes in working directory
Date: Wed, 15 Apr 2009 19:28:36 -0700 [thread overview]
Message-ID: <1239848917-14399-5-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1239848917-14399-4-git-send-email-gitster@pobox.com>
From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
The old behaviour still remains with --fix-attributes, and it is always on
for the legacy "git tar-tree".
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-archive.txt | 5 ++++-
archive.c | 22 ++++++++++++++++++++++
archive.h | 1 +
builtin-tar-tree.c | 8 ++++++++
4 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index c1adf59..fd882bf 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -10,7 +10,7 @@ SYNOPSIS
--------
[verse]
'git archive' --format=<fmt> [--list] [--prefix=<prefix>/] [<extra>]
- [--output=<file>]
+ [--output=<file>] [--fix-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[path...]
@@ -51,6 +51,9 @@ OPTIONS
--output=<file>::
Write the archive to <file> instead of stdout.
+--fix-attributes::
+ Look for attributes in .gitattributes in working directory too.
+
<extra>::
This can be any options that the archiver backend understands.
See next section.
diff --git a/archive.c b/archive.c
index 96b62d4..0ce628b 100644
--- a/archive.c
+++ b/archive.c
@@ -4,6 +4,7 @@
#include "attr.h"
#include "archive.h"
#include "parse-options.h"
+#include "unpack-trees.h"
static char const * const archive_usage[] = {
"git archive [options] <tree-ish> [path...]",
@@ -150,6 +151,8 @@ int write_archive_entries(struct archiver_args *args,
write_archive_entry_fn_t write_entry)
{
struct archiver_context context;
+ struct unpack_trees_options opts;
+ struct tree_desc t;
int err;
if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
@@ -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);
+ }
+
err = read_tree_recursive(args->tree, args->base, args->baselen, 0,
args->pathspec, write_archive_entry, &context);
if (err == READ_TREE_RECURSIVE)
@@ -258,6 +277,7 @@ static int parse_archive_args(int argc, const char **argv,
int verbose = 0;
int i;
int list = 0;
+ int worktree_attributes = 0;
struct option opts[] = {
OPT_GROUP(""),
OPT_STRING(0, "format", &format, "fmt", "archive format"),
@@ -265,6 +285,7 @@ static int parse_archive_args(int argc, const char **argv,
"prepend prefix to each pathname in the archive"),
OPT_STRING(0, "output", &output, "file",
"write the archive to this file"),
+ OPT_BOOLEAN(0, "fix-attributes", &worktree_attributes, "read .gitattributes in working directory"),
OPT__VERBOSE(&verbose),
OPT__COMPR('0', &compression_level, "store only", 0),
OPT__COMPR('1', &compression_level, "compress faster", 1),
@@ -324,6 +345,7 @@ static int parse_archive_args(int argc, const char **argv,
args->verbose = verbose;
args->base = base;
args->baselen = strlen(base);
+ args->worktree_attributes = worktree_attributes;
return argc;
}
diff --git a/archive.h b/archive.h
index 0b15b35..038ac35 100644
--- a/archive.h
+++ b/archive.h
@@ -10,6 +10,7 @@ struct archiver_args {
time_t time;
const char **pathspec;
unsigned int verbose : 1;
+ unsigned int worktree_attributes : 1;
int compression_level;
};
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 0713bca..760ea9d 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -36,6 +36,14 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
argv++;
argc--;
}
+ if (2 <= argc && !strcmp(argv[1], "--fix-attributes")) {
+ argv++;
+ argc--;
+ }
+
+ /* tar-tree defaults to fix-attributes as before */
+ nargv[nargc++] = "--fix-attributes";
+
switch (argc) {
default:
usage(tar_tree_usage);
--
1.6.3.rc0.6.g08087
next prev parent reply other threads:[~2009-04-16 2:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-16 2:28 [PATCH 0/5] archive attribute series Junio C Hamano
2009-04-16 2:28 ` [PATCH 1/5] archive tests: do not use .gitattributes in working directory Junio C Hamano
2009-04-16 2:28 ` [PATCH 2/5] attr: add GIT_ATTR_INDEX "direction" Junio C Hamano
2009-04-16 2:28 ` [PATCH 3/5] unpack-trees: do not muck with attributes when we are not checking out Junio C Hamano
2009-04-16 2:28 ` Junio C Hamano [this message]
2009-04-16 2:28 ` [PATCH 5/5] archive test: test new --fix-attributes feature Junio C Hamano
2009-04-17 19:53 ` René Scharfe
2009-04-16 5:17 ` [PATCH 4/5] archive: do not read .gitattributes in working directory Junio C Hamano
2009-04-16 7:06 ` Jeff King
2009-04-16 7:29 ` Jakub Narebski
2009-04-16 10:50 ` Nguyen Thai Ngoc Duy
2009-04-16 12:38 ` Nguyen Thai Ngoc Duy
2009-04-17 20:33 ` [PATCH 2/5] attr: add GIT_ATTR_INDEX "direction" René Scharfe
2009-04-17 19:51 ` [PATCH 1/5] archive tests: do not use .gitattributes in working directory René Scharfe
2009-04-17 22:17 ` [PATCH v2 " René Scharfe
2009-04-17 22:17 ` [PATCH v2 2/5] attr: add GIT_ATTR_INDEX "direction" René Scharfe
2009-04-17 22:18 ` [PATCH v2 3/5] unpack-trees: do not muck with attributes when we are not checking out René Scharfe
2009-04-17 22:18 ` [PATCH v2 4/5] archive: do not read .gitattributes in working directory René Scharfe
2009-04-17 22:18 ` [PATCH v2 5/5] archive test: attributes René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239848917-14399-5-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).