$ 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