{"thread":{"id":"56728","subject":"Suggestion: Allow .gitattributes to specify executable mode","startedAt":"2021-10-17T20:56:10Z","lastAt":"2021-10-17T21:12:00Z","messageCount":2,"participants":["some-java-user-99206970363698485155@vodafonemail.de","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"438974","messageId":"a5a41a53a50448a0829dc3bb8681f5bc@vodafonemail.de","threadId":"56728","inReplyTo":null,"subject":"Suggestion: Allow .gitattributes to specify executable mode","fromName":"","fromEmail":"some-java-user-99206970363698485155@vodafonemail.de","sentAt":"2021-10-17T20:56:05Z","receivedAt":"2021-10-17T20:56:10Z","isPatch":false,"sender":{"key":"some-java-user-99206970363698485155@vodafonemail.de","avatar":null},"body":"Hello,\n\nsome build systems have script files with certain specific names which are always intended to be executable.\nFor example Gradle has a `gradlew` file, and Maven has a (currently unofficial) `mvnw` file.\n\nFor Windows users these script files often cause problems when checked in with Git and used by a CI (continuous\nintegration) system running Linux. The CI build usually fails because the script files do not have the executable\nflag set (Windows does not have this concept).\n\nWould it be possible to extend the `.gitattributes` file to allow specifying that files should automatically get\nthe executable flag when added to the index? For example Gradle's `gradle init` command already creates a\n`.gitattributes` file; it could then add such a default entry to ease development for Windows users to make sure\nthey add the `gradlew` script file with the correct file mode.\n\nAssuming the flag is called `exec`, Gradle could then create the following `.gitattributes` entry:\n```\ngradlew    text exec\n```\n\nIt might also help with questions such as https://stackoverflow.com/q/14267441.\n\nWhat do you think?\n\nMy C knowledge is rather limited, and I am not familiar with the Git source, so unfortunately I cannot submit a\npatch for this.\n\nKind regards\n\n\n"},{"id":"438975","messageId":"YWyRmT+ln6/p3DjF@camp.crustytoothpaste.net","threadId":"56728","inReplyTo":"a5a41a53a50448a0829dc3bb8681f5bc@vodafonemail.de","subject":"Re: Suggestion: Allow .gitattributes to specify executable mode","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-10-17T21:11:53Z","receivedAt":"2021-10-17T21:12:00Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-10-17 at 20:56:05, some-java-user-99206970363698485155@vodafonemail.de wrote:\n> Hello,\n> \n> some build systems have script files with certain specific names which are always intended to be executable.\n> For example Gradle has a `gradlew` file, and Maven has a (currently unofficial) `mvnw` file.\n> \n> For Windows users these script files often cause problems when checked in with Git and used by a CI (continuous\n> integration) system running Linux. The CI build usually fails because the script files do not have the executable\n> flag set (Windows does not have this concept).\n> \n> Would it be possible to extend the `.gitattributes` file to allow specifying that files should automatically get\n> the executable flag when added to the index? For example Gradle's `gradle init` command already creates a\n> `.gitattributes` file; it could then add such a default entry to ease development for Windows users to make sure\n> they add the `gradlew` script file with the correct file mode.\n> \n> Assuming the flag is called `exec`, Gradle could then create the following `.gitattributes` entry:\n> ```\n> gradlew    text exec\n> ```\n> \n> It might also help with questions such as https://stackoverflow.com/q/14267441.\n> \n> What do you think?\n\nI think this might end up being duplicative on Unix systems, but you\ncould implement this with a pre-commit hook if you wanted.  Something\nlike this might work:\n\n  #!/bin/sh\n  \n  files=$(git ls-files | git check-attr --stdin exec | grep 'exec: set$' | awk -F': ' '{print $1}')\n  files=$(git ls-files -s $files | grep '^100644' | awk -F'\\t' '{print $2}')\n  git update-index --chmod=+x $files\n  git add $files\n\nThis obviously doesn't handle filenames with spaces, so it would need\nsome improvements, but it might work for your case.\n\nIt may also be beneficial to actually check this in CI as a first sanity\ncheck, although it sounds like this CI system does this implicitly.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"}]}