summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 457bb45)
raw | patch | inline | side by side (parent: 457bb45)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 8 Jun 2008 16:42:33 +0000 (18:42 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 9 Jun 2008 21:53:46 +0000 (14:53 -0700) |
Paths marked with this attribute are not output to git-archive
output.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
output.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
index 471754eb12afa5862aa9c5e88ed3bfd2ee5cac7f..6e67990f64372855dd665da4747a7f7c235ac856 100644 (file)
Creating an archive
~~~~~~~~~~~~~~~~~~~
+`export-ignore`
+^^^^^^^^^^^^^^^
+
+Files and directories with the attribute `export-ignore` won't be added to
+archive files.
+
`export-subst`
^^^^^^^^^^^^^^
diff --git a/archive-tar.c b/archive-tar.c
index d7598f907d9f7fb40c24c8cef815f8fc33a8b19b..99db58f1cf21ee30f150c54acd6ffefbb14b6f57 100644 (file)
--- a/archive-tar.c
+++ b/archive-tar.c
strbuf_grow(&path, PATH_MAX);
strbuf_add(&path, base, baselen);
strbuf_addstr(&path, filename);
+ if (is_archive_path_ignored(path.buf + base_len))
+ return 0;
if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
strbuf_addch(&path, '/');
buffer = NULL;
diff --git a/archive-zip.c b/archive-zip.c
index 18c0f8710c6150e3b0211d311a70bf4b34608370..5742762ac30c92e796255b74d2ed1ea087f3fba0 100644 (file)
--- a/archive-zip.c
+++ b/archive-zip.c
crc = crc32(0, NULL, 0);
path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
+ if (is_archive_path_ignored(path + base_len))
+ return 0;
if (verbose)
fprintf(stderr, "%s\n", path);
if (pathlen > 0xffff) {
diff --git a/archive.c b/archive.c
index 7a32c19d3ca8043f3ca22dadfdbc60dbbb747d59..6502b76ef10a182e9d9f0e60ad926c55a31a737a 100644 (file)
--- a/archive.c
+++ b/archive.c
return buffer;
}
+int is_archive_path_ignored(const char *path)
+{
+ static struct git_attr *attr_export_ignore;
+ struct git_attr_check check[1];
+
+ if (!attr_export_ignore)
+ attr_export_ignore = git_attr("export-ignore", 13);
+
+ check[0].attr = attr_export_ignore;
+ if (git_checkattr(path, ARRAY_SIZE(check), check))
+ return 0;
+ return ATTR_TRUE(check[0].value);
+}
diff --git a/archive.h b/archive.h
index 5791e657e9a0c22081f4f42b9d8ca5b3c536baf2..ddf004acdfa2125a73df11e923eda902d3ca8277 100644 (file)
--- a/archive.h
+++ b/archive.h
extern void *parse_extra_zip_args(int argc, const char **argv);
extern void *sha1_file_to_archive(const char *path, const unsigned char *sha1, unsigned int mode, enum object_type *type, unsigned long *size, const struct commit *commit);
+extern int is_archive_path_ignored(const char *path);
#endif /* ARCHIVE_H */
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 9b0baac8db4b342206d37ab5eaff0b7a09d33967..3f1e25d921c2e90176d8487ae0519af2cbd1e17b 100755 (executable)
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
echo text >file_with_long_path) &&
(cd a && find .) | sort >a.lst'
+test_expect_success \
+ 'add ignored file' \
+ 'echo ignore me >a/ignored &&
+ echo ignored export-ignore >.gitattributes'
+
test_expect_success \
'add files to repository' \
'find a -type f | xargs git update-index --add &&
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
git commit-tree $treeid </dev/null)'
+test_expect_success \
+ 'remove ignored file' \
+ 'rm a/ignored'
+
test_expect_success \
'git archive' \
'git archive HEAD >b.tar'