$ git update-index --chmod +x ./scripts/movefile.sh code example

Example 1: $ git update-index --chmod +x ./scripts/moveFile.sh

# branch.oid 47648eb505277e044a5794f97312a5d669d79ca7
# branch.head master
# branch.upstream origin/master
# branch.ab +0 -0

Example 2: $ git update-index --chmod +x ./scripts/moveFile.sh

2018-01-28T06:54:31.644Z - error: [ui] `git commit -F -` exited with an unexpected code: 1.
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

(The error was parsed as 16: There are no changes to commit.)

Example 3: $ git update-index --chmod +x ./scripts/moveFile.sh

$ git update-index --chmod +x ./scripts/moveFile.sh

Example 4: $ git update-index --chmod +x ./scripts/moveFile.sh

diff --git a/app/test/unit/git/commit-test.ts b/app/test/unit/git/commit-test.ts
index b5ac688e5..18002c38c 100644
--- a/app/test/unit/git/commit-test.ts
+++ b/app/test/unit/git/commit-test.ts
@@ -33,6 +33,8 @@ import {
 
 import * as fs from 'fs-extra'
 
+import * as Mode from 'stat-mode'
+
 async function getTextDiff(
   repo: Repository,
   file: WorkingDirectoryFileChange
@@ -476,6 +478,51 @@ describe('git/commit', () => {
   })
 
   describe('index corner cases', () => {
+    it('persists the --chmod=+x when set in the index', async () => {
+      let status,
+        files = null
+
+      const repo = await setupEmptyRepository()
+
+      const firstPath = path.join(repo.path, 'script.sh')
+      const secondPath = path.join(repo.path, 'README.md')
+
+      fs.writeFileSync(firstPath, `echo "Hello world!"\n`)
+      fs.writeFileSync(secondPath, '# README\n')
+
+      // commit the file with some content
+      await GitProcess.exec(['add', '.'], repo.path)
+      await GitProcess.exec(['commit', '-m', 'Initial commit'], repo.path)
+
+      // change the file permission
+      await GitProcess.exec(
+        ['update-index', '--chmod=+x', '--', 'script.sh'],
+        repo.path
+      )
+
+      // modify the other file
+      fs.writeFileSync(secondPath, '# Actually This Is The Readme\n')
+
+      status = await getStatus(repo)
+      files = status.workingDirectory.files
+
+      expect(files.length).to.equal(2)
+
+      const toCommit = status.workingDirectory.withIncludeAllFiles(true)
+
+      await createCommit(
+        repo,
+        'commit the chmod and content change',
+        toCommit.files
+      )
+
+      const stat = fs.statSync(firstPath)
+      const mode = new Mode(stat)
+      expect(mode.owner.execute).is.true
+      expect(mode.group.execute).is.true
+      expect(mode.others.execute).is.true
+    })
+
     it('can commit when staged new file is then deleted', async () => {
       let status,
         files = null

Example 5: $ git update-index --chmod +x ./scripts/moveFile.sh

# branch.oid 47648eb505277e044a5794f97312a5d669d79ca7
# branch.head master
# branch.upstream origin/master
# branch.ab +0 -0
1 M. N... 100644 100755 100755 ae2bd1f42ebe4eaf62cc6460765016cffa804247 ae2bd1f42ebe4eaf62cc6460765016cffa804247 test