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

Re: [PATCH tg/add-chmod+x-fix 2/2] t3700-add: protect one --chmod=+x test with POSIXPERM

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2016, 20:47 UTC
Message-ID
<xmqqa8f16kup.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqtwd986ml.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> ...  Comparing the index with the working tree using "status"
> is probably not how you would want to do so.  A future breakage may
> cause the indexed blob name to change by mistake, and status would
> happily report difference but you would not notice its output is
> saying "Hey, they are different between the index and the working
> tree", while you are expecting ONLY the change in the executable bit.
In other words, how about doing it this way?
-- >8 --
From: Johannes Sixt <j6t@kdbg.org>
Date: Tue, 20 Sep 2016 08:18:25 +0200
Subject: [PATCH] t3700-add: do not rely on executable bit of the working tree file

A recently introduced test checks the result of 'git status' after setting the executable bit on a file. This check does not yield the expected result when the filesystem does not support the executable bit.

The primary thing we care about is that a file added with --chmod=+x has executable bit in the index, not that it is registered in the index somehow differently from what is in the working tree, which is what the "status" output tries to catch. Let's check what we care about, i.e. the path is marked as an executable in the index.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t3700-add.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 16ab2da..1a733bb 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -361,13 +361,11 @@ test_expect_success 'git add --chmod=[+-]x changes index with already added file
 	test_mode_in_index 100644 xfoo3
 '
 
-test_expect_success 'file status is changed after git add --chmod=+x' '
-	echo "AM foo4" >expected &&
+test_expect_success 'git add --chmod=[+-]x changes index with newly added file' '
 	echo foo >foo4 &&
 	git add foo4 &&
 	git add --chmod=+x foo4 &&
-	git status -s foo4 >actual &&
-	test_cmp expected actual
+	test_mode_in_index 100755 foo4
 '
 
 test_expect_success 'no file status change if no pathspec is given' '
-- 
2.10.0-515-g9036219
Previous: Johannes SixtNext: Johannes Sixt
Message 6 of 11 in “t3700-add: create subdirectory gently”
  1. 1/2 t3700-add: create subdirectory gentlyJohannes Sixt, Sep 20, 2016
  2. 2/2 t3700-add: protect one --chmod=+x test with POSIXPERMJohannes Sixt, Sep 20, 2016
  3. Thomas GummererSep 20, 2016
  4. Junio C HamanoSep 21, 2016
  5. Johannes SixtSep 21, 2016
  6. Junio C HamanoSep 21, 2016
  7. Johannes SixtSep 21, 2016
  8. Junio C HamanoSep 21, 2016
  9. Johannes SixtSep 22, 2016
  10. Thomas GummererSep 22, 2016
  11. Thomas GummererSep 20, 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.