Skip to content

Commit

Permalink
fix: no need to run git clean -df since untracked changes are stashed
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 14, 2019
1 parent bc17363 commit 869bac6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/gitWorkflow.js
Expand Up @@ -68,16 +68,14 @@ class GitWorkflow {
debug('Done backing up merge state!')
}

// Get stash of entire original state, including unstaged changes
// Save stash of entire original state, including unstaged and untracked changes.
// This should remove all changes from the index.
// The `--keep-index` option cannot be used since it resurrects deleted files on
// git versions before v2.23.0 (https://github.com/git/git/blob/master/Documentation/RelNotes/2.23.0.txt#L322)
await this.execGit(['stash', 'save', '--quiet', '--include-untracked', STASH])
// Apply index from previous stash back to enable running tasks against
// staged files only. `git stash --keep-index` cannot be used here because of
// a bug affecting deleted files. The bug has been fixed in git v2.23.0
// See https://github.com/git/git/blob/master/Documentation/RelNotes/2.23.0.txt#L322
// Apply only the staged changes back to index
await this.execGit(['stash', 'apply', '--index', await this.getBackupStash()])
// Clear any unstaged changes since they are saved in the stash,
// and shouldn't be affected by tasks
await this.execGit(['clean', '-df'])
// Checkout everything just in case there are unstaged files left behind.
await this.execGit(['checkout', '.'])
// Since only staged files are now present, get a diff of unstaged changes
// by comparing current index against original stash, but in reverse
Expand Down

0 comments on commit 869bac6

Please sign in to comment.