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

code.editor config ignored #416

Closed
wants to merge 8 commits into from
Closed

Conversation

pm100
Copy link
Contributor

@pm100 pm100 commented Nov 10, 2020

#414

This PR fixes all 3 issues in the original bug

  • gitui does not look at code.editor setting
  • git2 config.get_str always fails
  • gitui doesnt like editors with spaces in their names (vscode sets itself in core.editor)

does not fix the potential error of editors setting with spaces in the args (as noted in the original comments)

does not change the other places where get_str is called - it probably should

I wanted to add a test for trying to read config str with non UTF8 string name (since this is a failure mode for git2) but this project bans unsafe. unsafe is needed to be able to create an illegal utf8 string

Also note that the code working with config.get_entry does not work how the git2 docs say it should (what errors occur when etc) but it actually works.

Finally: Reviewers, I am still learning my way around rusts idioms and would welcome feedback on how this code can be improved. In particular all the or_else, and_then, if_you_like ,... chaining

@pm100 pm100 closed this Nov 10, 2020
@pm100 pm100 reopened this Nov 10, 2020
@WizardOhio24
Copy link
Contributor

@pm100 You have included all the commits for fixing the missing cursor at the end of the line 😧, you might want to cherry pick this onto a new branch then force push that here.

Ok(None)
} else {
Ok(entry.value().map(|s| s.to_string()))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the above code, a more rust way to write this might be:

    if let Some(value) = repo.config()?.get_entry(key)?.value() {
        return Ok(Some(String::from(value)));
    }
    Ok(None);

If anyone else has any suggestions feel free.

@pm100
Copy link
Contributor Author

pm100 commented Nov 11, 2020

@WizardOhio24 aha, total git noob here (so why am i working on gitui, cos I like tui projects). I think i know my mistake. In my mind 'git branch foo' makes a new clean branch . I subconsciously though that it would be from master.

I assume I have to go

  • get checkout master
  • git branch foo
  • git checkout foo

Is there a magic command (rebase?) that will sort this out for me.

I will sort this out before looking at your other suggestions

@pm100 pm100 closed this Nov 11, 2020
@pm100 pm100 deleted the code-editor branch November 11, 2020 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants