From: Junio C Hamano <gitster@pobox.com>
To: Edward Thomson <ethomson@edwardthomson.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] add: add --chmod=+x / --chmod=-x options
Date: Wed, 25 May 2016 09:00:03 -0700 [thread overview]
Message-ID: <xmqqshx6162k.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqh9dm37xk.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Wed, 25 May 2016 00:36:55 -0700")
Junio C Hamano <gitster@pobox.com> writes:
>> @@ -661,6 +663,10 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
>>
>> if (trust_executable_bit && has_symlinks)
>> ce->ce_mode = create_ce_mode(st_mode);
>> + else if (force_executable)
>> + ce->ce_mode = create_ce_mode(0777);
>> + else if (force_notexecutable)
>> + ce->ce_mode = create_ce_mode(0666);
>
> This is an iffy design decision.
>
> Even when you are in core.filemode=true repository, if you
> explicitly said
>
> git add --chmod=+x READ.ME
>
> wouldn't you expect that the path would have executable bit in the
> index, whether it has it as executable in the filesystem? The above
> if/else cascade, because trust-executable-bit is tested first, will
> ignore force_* flags altogether, won't it? It also is strange that
> the decision to honor or ignore force_* flags is also tied to
> has_symlinks, which is a totally orthogonal concept.
Here is an additional patch to your tests. It repeats one of the
tests you added, but runs in a repository with core.filemode and
core.symlinks both enabled. The test fails to force executable bit
on platforms where it runs.
It passes with your patch if you drop core.symlinks, which is a good
demonstration why letting has_symlinks decide if force* is to be
honored is iffy.
t/t3700-add.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index e551eaf..2afcb74 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -351,4 +351,15 @@ test_expect_success 'git add --chmod=-x stages an executable file with -x' '
esac
'
+test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x' '
+ git config core.filemode 1 &&
+ git config core.symlinks 1 &&
+ echo foo >foo2 &&
+ git add --chmod=+x foo2 &&
+ case "$(git ls-files --stage foo2)" in
+ 100755" "*foo2) echo pass;;
+ *) echo fail; git ls-files --stage foo2; (exit 1);;
+ esac
+'
+
test_done
next prev parent reply other threads:[~2016-05-25 16:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 2:06 [PATCH] add: add --chmod=+x / --chmod=-x options Edward Thomson
2016-05-25 7:36 ` Junio C Hamano
2016-05-25 12:19 ` Johannes Schindelin
2016-05-25 16:10 ` Junio C Hamano
2016-05-25 16:49 ` Johannes Schindelin
2016-05-25 16:00 ` Junio C Hamano [this message]
2016-05-27 4:41 ` Edward Thomson
2016-05-27 5:12 ` Mike Hommey
2016-05-27 6:36 ` Junio C Hamano
2016-05-27 18:30 ` Junio C Hamano
2016-05-31 22:06 ` Edward Thomson
2016-05-25 7:46 ` Johannes Schindelin
2016-05-27 18:35 ` Junio C Hamano
2016-05-25 7:51 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2016-05-31 22:08 Edward Thomson
2016-05-31 22:34 ` Junio C Hamano
2016-06-01 7:23 ` Johannes Schindelin
2016-06-01 10:19 ` Johannes Schindelin
2016-06-01 16:00 ` Junio C Hamano
2016-06-07 22:59 ` Edward Thomson
2016-06-08 0:39 ` Junio C Hamano
2016-06-08 11:46 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqshx6162k.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=ethomson@edwardthomson.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.