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

Re: [PATCH v4 2/2] interpret-trailers: add option for in-place editing

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2016, 22:09 UTC
Message-ID
<xmqqvb6p8bmm.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAPig+cRHTs9q4k=CqtY2j=ZtTYMU6_SPeCHkQe4m5AGXOjg_Ww@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 6 quoted lines
> You suspect correctly. It was exactly the comment added by f400e51c
> that misled me. (t/README does, on the other hand, mention "root", as
> I noticed after reading your previous response.)
>
> Thanks for spelling all this out. Hopefully, others reading your reply
> (now and later) will be less confused than I.
It is not too late to fix that, though.
-- >8 --
Subject: test-lib: clarify and tighten SANITY

f400e51c (test-lib.sh: set prerequisite SANITY by testing what we really need, 2015-01-27) improved the way SANITY prerequisite was determined, but made the resulting code (incorrectly) imply that SANITY is all about effects of permission bits of the containing directory has on the files contained in it by the comment it added, its log message and the actual tests.

By the way, while we are on the subject, POSIXPERM is more about "if we do chmod, does filesystem remember it so that ls -l reports the same?" Output from "git grep POSIXPERM t" shows that some users of it also assume that it requires "we can make something executable by doing chmod +x and unexecutable by doing chmod -x" (and that is fine--running tests as root would not make an unexecutable file executable). The tests that require POSIXPERM but not SANITY can be run by root (I am not saying that running tests as root is safe or sane, though) and are expected to produce the same result as they were run by a non-root user.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/test-lib.sh | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 446d8d5..68c31ae 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -997,20 +997,28 @@ test_lazy_prereq NOT_ROOT '
 	test "$uid" != 0
 '
 
-# On a filesystem that lacks SANITY, a file can be deleted even if
-# the containing directory doesn't have write permissions, or a file
-# can be accessed even if the containing directory doesn't have read
-# or execute permissions, causing our tests that validate that Git
-# works sensibly in such situations.
+# SANITY is about "can you correctly predict what the filesystem would
+# do by only looking at the permission bits of the files and
+# directories?"  A typical example of !SANITY is running the test
+# suite as root, where a test may expect "chmod -r file && cat file"
+# to fail because file is supposed to be unreadable after a successful
+# chmod.  In an environment (i.e. combination of what filesystem is
+# being used and who is running the tests) that lacks SANITY, you may
+# be able to delete or create a file when the containing directory
+# doesn't have write permissions, or access a file even if the
+# containing directory doesn't have read or execute permissions.
+
 test_lazy_prereq SANITY '
 	mkdir SANETESTD.1 SANETESTD.2 &&
 
 	chmod +w SANETESTD.1 SANETESTD.2 &&
 	>SANETESTD.1/x 2>SANETESTD.2/x &&
 	chmod -w SANETESTD.1 &&
+	chmod -r SANETESTD.1/x &&
 	chmod -rx SANETESTD.2 ||
 	error "bug in test sript: cannot prepare SANETESTD"
 
+	! test -r SANETESTD.1/x &&
 	! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
 	status=$?
 
Previous: Eric SunshineNext: Eric Sunshine
Message 14 of 17 in “Add in-place editing support to git interpret-trailers”
  1. 0/2 Add in-place editing support to git interpret-trailersTobias Klauser, Jan 14, 2016
  2. 1/2 trailer: allow to write to files other than stdoutTobias Klauser, Jan 14, 2016
  3. 2/2 interpret-trailers: add option for in-place editingTobias Klauser, Jan 14, 2016
  4. Junio C HamanoJan 14, 2016
  5. Tobias KlauserJan 15, 2016
  6. Junio C HamanoJan 15, 2016
  7. Tobias KlauserJan 15, 2016
  8. Eric SunshineJan 18, 2016
  9. Junio C HamanoJan 19, 2016
  10. Eric SunshineJan 19, 2016
  11. Eric SunshineJan 19, 2016
  12. Junio C HamanoJan 19, 2016
  13. Eric SunshineJan 19, 2016
  14. Junio C HamanoJan 19, 2016
  15. Eric SunshineJan 20, 2016
  16. Eric SunshineJan 18, 2016
  17. Tobias KlauserJan 19, 2016

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.