mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-19 06:29:10 +03:00
Merge pull request #441 from Murmele/Settings
Fix used wrong config in ConfigDialog.cpp
This commit is contained in:
commit
f1b7aa977b
@ -100,17 +100,17 @@ public:
|
||||
|
||||
// Connect signals after initializing fields.
|
||||
connect(mName, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.gitConfig();
|
||||
config.setValue("user.name", text);
|
||||
});
|
||||
|
||||
connect(mEmail, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.gitConfig();
|
||||
config.setValue("user.email", text);
|
||||
});
|
||||
|
||||
connect(mFetch, &QCheckBox::toggled, view, [this, view](bool checked) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.appConfig();
|
||||
config.setValue("autofetch.enable", checked);
|
||||
view->startFetchTimer();
|
||||
});
|
||||
@ -118,28 +118,28 @@ public:
|
||||
using Signal = void (QSpinBox::*)(int);
|
||||
auto signal = static_cast<Signal>(&QSpinBox::valueChanged);
|
||||
connect(mFetchMinutes, signal, this, [this](int value) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.appConfig();
|
||||
config.setValue("autofetch.minutes", value);
|
||||
});
|
||||
|
||||
connect(mPushCommit, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.appConfig();
|
||||
config.setValue("autopush.enable", checked);
|
||||
});
|
||||
|
||||
connect(mPullUpdate, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.appConfig();
|
||||
config.setValue("autoupdate.enable", checked);
|
||||
});
|
||||
|
||||
connect(mAutoPrune, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.appConfig();
|
||||
config.setValue("autoprune.enable", checked);
|
||||
});
|
||||
}
|
||||
|
||||
void init() {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.gitConfig();
|
||||
mName->setText(config.value<QString>("user.name"));
|
||||
mEmail->setText(config.value<QString>("user.email"));
|
||||
|
||||
@ -158,6 +158,7 @@ public:
|
||||
git::Config app = mRepo.appConfig();
|
||||
mFetch->setChecked(app.value<bool>("autofetch.enable", fetch));
|
||||
mFetchMinutes->setValue(app.value<int>("autofetch.minutes", minutes));
|
||||
mFetchMinutes->setEnabled(mFetch->isChecked());
|
||||
mPushCommit->setChecked(app.value<bool>("autopush.enable", push));
|
||||
mPullUpdate->setChecked(app.value<bool>("autoupdate.enable", update));
|
||||
mAutoPrune->setChecked(app.value<bool>("autoprune.enable", prune));
|
||||
@ -605,7 +606,7 @@ public:
|
||||
QLineEdit *urlLineEdit =
|
||||
new QLineEdit(map.value("Endpoint").section(" ", 0, 0));
|
||||
connect(urlLineEdit, &QLineEdit::textChanged, [repo](const QString &text) {
|
||||
git::Config config = repo.config();
|
||||
git::Config config = repo.gitConfig();
|
||||
config.setValue("lfs.url", text);
|
||||
});
|
||||
|
||||
@ -614,7 +615,7 @@ public:
|
||||
pruneOffsetDays->setValue(map.value("PruneOffsetDays").toInt());
|
||||
auto signal = QOverload<int>::of(&QSpinBox::valueChanged);
|
||||
connect(pruneOffsetDays, signal, [repo](int value) {
|
||||
git::Config config = repo.config();
|
||||
git::Config config = repo.gitConfig();
|
||||
config.setValue("lfs.pruneoffsetdays", value);
|
||||
});
|
||||
QHBoxLayout *pruneOffsetLayout = new QHBoxLayout;
|
||||
@ -628,7 +629,7 @@ public:
|
||||
bool fetchRecentEnabled = map.value("FetchRecentAlways").contains("true");
|
||||
fetchRecentAlways->setChecked(fetchRecentEnabled);
|
||||
connect(fetchRecentAlways, &QCheckBox::toggled, [repo](bool checked) {
|
||||
git::Config config = repo.config();
|
||||
git::Config config = repo.gitConfig();
|
||||
config.setValue("lfs.fetchrecentalways", checked);
|
||||
});
|
||||
|
||||
@ -637,7 +638,7 @@ public:
|
||||
fetchRecentRefsDays->setValue(map.value("FetchRecentRefsDays").toInt());
|
||||
fetchRecentRefsDays->setEnabled(fetchRecentEnabled);
|
||||
connect(fetchRecentRefsDays, signal, [repo](int value) {
|
||||
git::Config config = repo.config();
|
||||
git::Config config = repo.gitConfig();
|
||||
config.setValue("lfs.fetchrecentrefsdays", value);
|
||||
});
|
||||
connect(fetchRecentAlways, &QCheckBox::toggled, this,
|
||||
@ -655,7 +656,7 @@ public:
|
||||
map.value("FetchRecentCommitsDays").toInt());
|
||||
fetchRecentCommitsDays->setEnabled(fetchRecentEnabled);
|
||||
connect(fetchRecentCommitsDays, signal, [repo](int value) {
|
||||
git::Config config = repo.config();
|
||||
git::Config config = repo.gitConfig();
|
||||
config.setValue("lfs.fetchrecentcommitsdays", value);
|
||||
});
|
||||
connect(fetchRecentAlways, &QCheckBox::toggled, this,
|
||||
|
@ -47,7 +47,7 @@ DeleteBranchDialog::DeleteBranchDialog(const git::Branch &branch,
|
||||
|
||||
QString name = upstream.name().section('/', 1);
|
||||
QString key = kBranchMergeFmt.arg(branch.name());
|
||||
QString upstreamName = repo.config().value<QString>(key);
|
||||
QString upstreamName = repo.gitConfig().value<QString>(key);
|
||||
|
||||
git::Remote remote = upstream.remote();
|
||||
QString remoteName = remote.name();
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <QTextCodec>
|
||||
|
||||
DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent)
|
||||
: QWidget(parent), mConfig(repo ? repo.config() : git::Config::global()) {
|
||||
: QWidget(parent),
|
||||
mConfig(repo ? repo.gitConfig() : git::Config::global()) {
|
||||
// diff context
|
||||
QSpinBox *context = new QSpinBox(this);
|
||||
QLabel *contextLabel = new QLabel(tr("lines"), this);
|
||||
|
@ -90,7 +90,7 @@ RemoteDialog::RemoteDialog(Kind kind, RepoView *parent) : QDialog(parent) {
|
||||
if (ref.isValid()) {
|
||||
QString key = QString("branch.%1.merge").arg(ref.name());
|
||||
git::Config config =
|
||||
RepoView::parentView(this)->repo().config();
|
||||
RepoView::parentView(this)->repo().gitConfig();
|
||||
value = config.value<QString>(key);
|
||||
}
|
||||
mRemoteRef->setText(value);
|
||||
|
@ -129,11 +129,11 @@ void Branch::remove(bool force) {
|
||||
}
|
||||
|
||||
bool Branch::isRebase() const {
|
||||
return repo().config().value<bool>(kRebaseFmt.arg(name()));
|
||||
return repo().gitConfig().value<bool>(kRebaseFmt.arg(name()));
|
||||
}
|
||||
|
||||
void Branch::setRebase(bool checked) {
|
||||
repo().config().setValue(kRebaseFmt.arg(name()), checked);
|
||||
repo().gitConfig().setValue(kRebaseFmt.arg(name()), checked);
|
||||
}
|
||||
|
||||
AnnotatedCommit Branch::annotatedCommitFromFetchHead() const {
|
||||
|
@ -423,7 +423,7 @@ int Remote::Callbacks::certificate(git_cert *cert, int valid, const char *host,
|
||||
return 0;
|
||||
|
||||
Repository repo = reinterpret_cast<Remote::Callbacks *>(payload)->repo();
|
||||
Config config = repo.isValid() ? repo.config() : Config::global();
|
||||
Config config = repo.isValid() ? repo.gitConfig() : Config::global();
|
||||
if (!config.value<bool>("http.sslVerify", true))
|
||||
return 0;
|
||||
|
||||
@ -596,7 +596,7 @@ Result Remote::push(Callbacks *callbacks, const Reference &src,
|
||||
refspec += ":" + dst;
|
||||
} else {
|
||||
QString key = QString("branch.%1.merge").arg(src.name());
|
||||
QString upstream = repo.config().value<QString>(key);
|
||||
QString upstream = repo.gitConfig().value<QString>(key);
|
||||
if (!upstream.isEmpty())
|
||||
refspec += ":" + upstream;
|
||||
}
|
||||
|
@ -173,12 +173,16 @@ QString Repository::message() const {
|
||||
return QString::fromUtf8(buf.ptr, buf.size);
|
||||
}
|
||||
|
||||
Config Repository::config() const {
|
||||
// Config file used for git specific configs
|
||||
// config file in <Repository>/.git/config
|
||||
Config Repository::gitConfig() const {
|
||||
git_config *config = nullptr;
|
||||
git_repository_config(&config, d->repo);
|
||||
return Config(config);
|
||||
}
|
||||
|
||||
// Config file used for app specific configs
|
||||
// config file in <Repository>/.git/gittyup/config
|
||||
Config Repository::appConfig() const {
|
||||
Config config = Config::appGlobal();
|
||||
QString path = appDir().filePath(kConfigFile);
|
||||
@ -1012,7 +1016,7 @@ void Repository::cleanupState() {
|
||||
}
|
||||
|
||||
QTextCodec *Repository::codec() const {
|
||||
QString encoding = config().value<QString>("gui.encoding");
|
||||
QString encoding = gitConfig().value<QString>("gui.encoding");
|
||||
QTextCodec *codec = QTextCodec::codecForName(encoding.toUtf8());
|
||||
return codec ? codec : QTextCodec::codecForLocale();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
QString message() const;
|
||||
|
||||
// config
|
||||
Config config() const;
|
||||
Config gitConfig() const;
|
||||
Config appConfig() const;
|
||||
|
||||
// bare
|
||||
|
@ -26,7 +26,7 @@ Submodule::operator git_submodule *() const { return d.data(); }
|
||||
bool Submodule::isInitialized() const {
|
||||
Repository repo(git_submodule_owner(d.data()));
|
||||
QString key = QString("submodule.%1.url").arg(name());
|
||||
return !repo.config().value<QString>(key).isEmpty();
|
||||
return !repo.gitConfig().value<QString>(key).isEmpty();
|
||||
}
|
||||
|
||||
void Submodule::initialize() const { git_submodule_init(d.data(), false); }
|
||||
@ -34,7 +34,7 @@ void Submodule::initialize() const { git_submodule_init(d.data(), false); }
|
||||
void Submodule::deinitialize() const {
|
||||
// Remove git config entry.
|
||||
Repository repo(git_submodule_owner(d.data()));
|
||||
Config config = repo.config();
|
||||
Config config = repo.gitConfig();
|
||||
QString regex = QString("submodule\\.%1\\..*").arg(name());
|
||||
Config::Iterator it = config.glob(regex);
|
||||
while (Config::Entry entry = it.next())
|
||||
|
@ -1397,7 +1397,7 @@ QString DetailView::overrideUser() const { return mOverrideUser; }
|
||||
QString DetailView::overrideEmail() const { return mOverrideEmail; }
|
||||
|
||||
void DetailView::updateAuthor() {
|
||||
git::Config config = RepoView::parentView(this)->repo().config();
|
||||
git::Config config = RepoView::parentView(this)->repo().gitConfig();
|
||||
|
||||
QString text = "<a href=\"changeAuthor\"><b>" + tr("Author:") + "</b></a> ";
|
||||
|
||||
|
@ -693,7 +693,7 @@ void RepoView::visitLink(const QString &link) {
|
||||
|
||||
if (action == "sslverifyrepo") {
|
||||
if (mRepo.isValid()) {
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.gitConfig();
|
||||
config.setValue<bool>("http.sslVerify", false);
|
||||
QMessageBox msg(QMessageBox::Icon::Information, tr("Certificate Error"),
|
||||
tr("SSL verification disabled for this repository"),
|
||||
@ -1003,7 +1003,7 @@ QFuture<git::Result> RepoView::fetch(const git::Remote &rmt, bool tags,
|
||||
// Add ssl hint.
|
||||
if (result.error() == -GIT_ERROR_SSL) {
|
||||
git::Config config =
|
||||
mRepo.isValid() ? mRepo.config() : git::Config::global();
|
||||
mRepo.isValid() ? mRepo.gitConfig() : git::Config::global();
|
||||
if (config.value<bool>("http.sslVerify", true)) {
|
||||
QString ssl =
|
||||
tr("You may disable ssl verification <a "
|
||||
@ -1112,7 +1112,7 @@ void RepoView::pull(MergeFlags flags, const git::Remote &rmt, bool tags,
|
||||
MergeFlags mf = flags;
|
||||
if (flags == Default) {
|
||||
// Read pull.rebase from config.
|
||||
git::Config config = mRepo.config();
|
||||
git::Config config = mRepo.gitConfig();
|
||||
bool rebase = config.value<bool>("pull.rebase");
|
||||
|
||||
// Read branch.<name>.rebase from config.
|
||||
|
@ -145,8 +145,8 @@ QString extractRepository(const QString &filename, bool useTempDir) {
|
||||
}
|
||||
|
||||
void initRepo(git::Repository &repo) {
|
||||
repo.config().setValue("user.name", QString("testuser"));
|
||||
repo.config().setValue("user.email", QString("test@user"));
|
||||
repo.gitConfig().setValue("user.name", QString("testuser"));
|
||||
repo.gitConfig().setValue("user.email", QString("test@user"));
|
||||
}
|
||||
|
||||
ScratchRepository::ScratchRepository(bool autoRemove) {
|
||||
|
Loading…
Reference in New Issue
Block a user