git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/8] archive: disregard .gitattributes on working directory

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 8, 2009, 10:05 UTC
Message-ID
<1239185133-4181-8-git-send-email-pclouds@gmail.com>
In-Reply-To
<1239185133-4181-7-git-send-email-pclouds@gmail.com>

Some tests in t500-tar-tree.sh depends on in-worktree .gitattributes. Fix them too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 We could make an option to keep old behaviour. But is it worth it?
 archive.c               |    1 +
 t/t0024-crlf-archive.sh |    2 +-
 t/t5000-tar-tree.sh     |    6 +++++-
 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/archive.c b/archive.c
index 402f6d4..1ce644e 100644
--- a/archive.c
+++ b/archive.c
@@ -138,6 +138,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
 	path_without_prefix = path.buf + args->baselen;
 
 	setup_archive_check(check);
+	git_attr_set_direction(GIT_ATTR_INDEX, &the_index);
 	if (!git_checkattr(path_without_prefix, ARRAY_SIZE(check), check)) {
 		if (ATTR_TRUE(check[0].value))
 			return 0;
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index 1cbe511..bf531fc 100755
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -69,7 +69,7 @@ test_expect_success UNZIP 'zip archive' '
 
 '
 
-test_expect_failure '.gitattributes in workdir should not be consulted' '
+test_expect_success '.gitattributes in workdir should not be consulted' '
 	echo "sample -crlf" > .gitattributes &&
 	git archive --format=tar HEAD |
 	( mkdir untarred2 && cd untarred2 && "$TAR" -xf - )
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 7641e0d..420e7ad 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -56,6 +56,7 @@ 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 &&
+     git update-index --add .gitattributes &&
      treeid=`git write-tree` &&
      echo $treeid >treeid &&
      git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
@@ -140,6 +141,8 @@ test_expect_success \
 test_expect_success \
     'create archives with substfiles' \
     'echo "substfile?" export-subst >a/.gitattributes &&
+     git add a/.gitattributes &&
+     git commit -q -m new &&
      git archive HEAD >f.tar &&
      git archive --prefix=prefix/ HEAD >g.tar &&
      rm a/.gitattributes'
@@ -165,7 +168,8 @@ test_expect_success \
      'git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
       >g/prefix/a/substfile1.expected &&
       test_cmp g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&
-      test_cmp a/substfile2 g/prefix/a/substfile2
+      test_cmp a/substfile2 g/prefix/a/substfile2 &&
+      git reset HEAD^
 '
 
 test_expect_success \
-- 
1.6.2.2.602.g83ee9f
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 8 of 24 in “support "in-tree attributes" for git-archive”
  1. 0/8 support "in-tree attributes" for git-archiveNguyễn Thái Ngọc Duy, Apr 8, 2009
  2. 1/8 archive: add shortcuts for --format and --prefixNguyễn Thái Ngọc Duy, Apr 8, 2009
  3. 2/8 move prune_cache() to git libNguyễn Thái Ngọc Duy, Apr 8, 2009
  4. 3/8 archive: add a failure test wrt .gitattributes misreadingNguyễn Thái Ngọc Duy, Apr 8, 2009
  5. 4/8 archive: add tests for directory selectionNguyễn Thái Ngọc Duy, Apr 8, 2009
  6. 5/8 attr: add GIT_ATTR_INDEX "direction"Nguyễn Thái Ngọc Duy, Apr 8, 2009
  7. 6/8 archive: use index instead of parsing tree directlyNguyễn Thái Ngọc Duy, Apr 8, 2009
  8. 7/8 archive: disregard .gitattributes on working directoryNguyễn Thái Ngọc Duy, Apr 8, 2009
  9. 8/8 archive: support creating archives from indexNguyễn Thái Ngọc Duy, Apr 8, 2009
  10. René ScharfeApr 8, 2009
  11. Junio C HamanoApr 8, 2009
  12. Junio C HamanoApr 8, 2009
  13. René ScharfeApr 8, 2009
  14. René ScharfeApr 8, 2009
  15. René ScharfeApr 8, 2009
  16. Junio C HamanoApr 8, 2009
  17. René ScharfeApr 13, 2009
  18. Nguyen Thai Ngoc DuyApr 14, 2009
  19. René ScharfeApr 14, 2009
  20. Junio C HamanoApr 16, 2009
  21. René ScharfeApr 17, 2009
  22. Junio C HamanoApr 18, 2009
  23. Junio C HamanoApr 8, 2009
  24. René ScharfeApr 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.