Merge pull request #172 from jesseduffield/hotfix/167-ambiguous-name-in-diff

167: Support File names that match Branch names
This commit is contained in:
Jesse Duffield 2018-08-19 14:53:14 +10:00 committed by GitHub
commit 60fc24eada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 215 additions and 6 deletions

View file

@ -486,15 +486,11 @@ func (c *GitCommand) Diff(file File) string {
// if the file is staged and has spaces in it, it comes pre-quoted
fileName = c.OSCommand.Quote(fileName)
}
deletedArg := ""
if file.Deleted {
deletedArg = "--"
}
trackedArg := ""
trackedArg := "--"
if !file.Tracked && !file.HasStagedChanges {
trackedArg = "--no-index /dev/null"
}
command := fmt.Sprintf("%s %s %s %s %s", "git diff --color ", cachedArg, deletedArg, trackedArg, fileName)
command := fmt.Sprintf("%s %s %s %s", "git diff --color ", cachedArg, trackedArg, fileName)
// for now we assume an error means the file was deleted
s, _ := c.OSCommand.RunCommandWithOutput(command)