diff options
| author | Junio C Hamano <gitster@pobox.com> | 2008-06-22 14:46:11 -0700 | 
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2008-06-22 14:46:11 -0700 | 
| commit | 9523298c95467e014daf5ed108cfcbe75a0d918d (patch) | |
| tree | 9c60c33033a704ae1321b2919f315309c90fac31 | |
| parent | 159e639e5bf24d78b22802934ae335413b2aa6ae (diff) | |
| parent | 008d896df5deaa967d4d86306b408333e8ef34c3 (diff) | |
| download | git-9523298c95467e014daf5ed108cfcbe75a0d918d.tar.gz | |
Merge branch 'rs/archive-ignore'
* rs/archive-ignore:
  Teach new attribute 'export-ignore' to git-archive
| -rw-r--r-- | Documentation/gitattributes.txt | 6 | ||||
| -rw-r--r-- | archive-tar.c | 2 | ||||
| -rw-r--r-- | archive-zip.c | 2 | ||||
| -rw-r--r-- | archive.c | 13 | ||||
| -rw-r--r-- | archive.h | 1 | ||||
| -rwxr-xr-x | t/t5000-tar-tree.sh | 9 | 
6 files changed, 33 insertions, 0 deletions
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 471754eb12..6e67990f64 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -502,6 +502,12 @@ frotz	unspecified  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 d7598f907d..99db58f1cf 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -247,6 +247,8 @@ static int write_tar_entry(const unsigned char *sha1,  	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 18c0f8710c..5742762ac3 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -176,6 +176,8 @@ static int write_zip_entry(const unsigned char *sha1,  	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) { @@ -82,3 +82,16 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1,  	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); +} @@ -44,5 +44,6 @@ extern int write_zip_archive(struct archiver_args *);  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 9b0baac8db..3f1e25d921 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -45,6 +45,11 @@ test_expect_success \       (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 &&       find a -type l | xargs git update-index --add && @@ -54,6 +59,10 @@ test_expect_success \       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'  | 
