Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find and open conflict files from root git directory #27

Merged
merged 1 commit into from
Mar 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions conflict/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ Run below command to change to a compatible conflict style

func Find() (err error) {
cwd, _ := os.Getwd()
stdout, stderr, _ := RunCommand("git", cwd, "--no-pager", "diff", "--check")

stdout, stderr, _ := RunCommand("git", cwd, "rev-parse", "--show-toplevel")
if len(stderr) != 0 {
return errors.New(stderr)
} else if len(stdout) == 0 {
return errors.New("no git top-level path")
}
topLevelPath := string(strings.Split(stdout, "\n")[0])

stdout, stderr, _ = RunCommand("git", cwd, "--no-pager", "diff", "--check")

if len(stderr) != 0 {
return errors.New(stderr)
Expand All @@ -172,7 +181,7 @@ func Find() (err error) {
}

for fname := range diffMap {
absPath := path.Join(cwd, fname)
absPath := path.Join(topLevelPath, fname)
if err = ReadFile(absPath); err != nil {
return
}
Expand Down