mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-02 12:06:48 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7002ee5d9b | ||
|
|
0687c07f50 | ||
|
|
922f4ed5a4 | ||
|
|
652237d48f | ||
|
|
6a3f8eefa5 | ||
|
|
8cc8c4c228 | ||
|
|
574b34930c |
+10
-5
@@ -327,7 +327,7 @@ func (c *GitCommand) CatFile(file string) (string, error) {
|
||||
|
||||
// StageFile stages a file
|
||||
func (c *GitCommand) StageFile(file string) error {
|
||||
return c.OSCommand.RunCommand("git add " + file)
|
||||
return c.OSCommand.RunCommand("git add " + c.OSCommand.Quote(file))
|
||||
}
|
||||
|
||||
// UnStageFile unstages a file
|
||||
@@ -474,18 +474,23 @@ func (c *GitCommand) Show(sha string) string {
|
||||
// Diff returns the diff of a file
|
||||
func (c *GitCommand) Diff(file File) string {
|
||||
cachedArg := ""
|
||||
fileName := file.Name
|
||||
if file.HasStagedChanges && !file.HasUnstagedChanges {
|
||||
cachedArg = "--cached "
|
||||
cachedArg = "--cached"
|
||||
} else {
|
||||
// if the file is staged and has spaces in it, it comes pre-quoted
|
||||
fileName = c.OSCommand.Quote(fileName)
|
||||
}
|
||||
deletedArg := ""
|
||||
if file.Deleted {
|
||||
deletedArg = "-- "
|
||||
deletedArg = "--"
|
||||
}
|
||||
trackedArg := ""
|
||||
if !file.Tracked && !file.HasStagedChanges {
|
||||
trackedArg = "--no-index /dev/null "
|
||||
trackedArg = "--no-index /dev/null"
|
||||
}
|
||||
command := "git diff --color " + cachedArg + deletedArg + trackedArg + file.Name
|
||||
command := fmt.Sprintf("%s %s %s %s %s", "git diff --color ", cachedArg, deletedArg, trackedArg, fileName)
|
||||
|
||||
// for now we assume an error means the file was deleted
|
||||
s, _ := c.OSCommand.RunCommandWithOutput(command)
|
||||
return s
|
||||
|
||||
@@ -39,7 +39,10 @@ func (b *BranchListBuilder) obtainCurrentBranch() commands.Branch {
|
||||
// even though you're on 'master'
|
||||
branchName, err := b.GitCommand.OSCommand.RunCommandWithOutput("git symbolic-ref --short HEAD")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
branchName, err = b.GitCommand.OSCommand.RunCommandWithOutput("git rev-parse --short HEAD")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
return commands.Branch{Name: strings.TrimSpace(branchName), Recency: " *"}
|
||||
}
|
||||
@@ -141,7 +144,7 @@ func branchInfoFromLine(line string) (string, string, string) {
|
||||
r := regexp.MustCompile("\\|.*\\s")
|
||||
line = r.ReplaceAllString(line, " ")
|
||||
words := strings.Split(line, " ")
|
||||
return words[0], words[1], words[3]
|
||||
return words[0], words[1], words[len(words)-1]
|
||||
}
|
||||
|
||||
func abbreviatedTimeUnit(timeUnit string) string {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ func NewGui(log *logrus.Logger, gitCommand *commands.GitCommand, oSCommand *comm
|
||||
Conflicts: make([]commands.Conflict, 0),
|
||||
EditHistory: stack.New(),
|
||||
Platform: *oSCommand.Platform,
|
||||
Version: "test version", // TODO: send version in
|
||||
Version: version,
|
||||
}
|
||||
|
||||
return &Gui{
|
||||
|
||||
Reference in New Issue
Block a user