forked from qt-creator/qt-creator
Git: Replace "SHA1" with "hash" in code and comments
Change-Id: Iaa6712338b86a5a7fd4889734d5650c6751fcf95 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
7e70eefabe
commit
eee38e585e
@@ -48,7 +48,7 @@ void CommitData::clear()
|
||||
{
|
||||
panelInfo.clear();
|
||||
panelData.clear();
|
||||
amendSHA1.clear();
|
||||
amendHash.clear();
|
||||
enablePush = false;
|
||||
|
||||
files.clear();
|
||||
|
@@ -84,7 +84,7 @@ public:
|
||||
static QString stateDisplayName(const FileStates &state);
|
||||
|
||||
CommitType commitType;
|
||||
QString amendSHA1;
|
||||
QString amendHash;
|
||||
QTextCodec *commitEncoding = nullptr;
|
||||
GitSubmitEditorPanelInfo panelInfo;
|
||||
GitSubmitEditorPanelData panelData;
|
||||
|
@@ -1608,7 +1608,7 @@ static QString msgParentRevisionFailed(const FilePath &workingDirectory,
|
||||
const QString &revision,
|
||||
const QString &why)
|
||||
{
|
||||
//: Failed to find parent revisions of a SHA1 for "annotate previous"
|
||||
//: Failed to find parent revisions of a hash for "annotate previous"
|
||||
return Tr::tr("Cannot find parent revisions of \"%1\" in \"%2\": %3")
|
||||
.arg(revision, workingDirectory.toUserOutput(), why);
|
||||
}
|
||||
@@ -1685,7 +1685,7 @@ QString GitClient::synchronousShortDescription(const FilePath &workingDirectory,
|
||||
// leaving it in breaks command line quoting on Windows, see QTCREATORBUG-23208.
|
||||
const QString quoteReplacement = "_-_";
|
||||
|
||||
// Short SHA1, author, subject
|
||||
// Short hash, author, subject
|
||||
const QString defaultShortLogFormat = "%h (%aN " + quoteReplacement + "%s";
|
||||
const int maxShortLogLength = 120;
|
||||
|
||||
@@ -2661,7 +2661,7 @@ bool GitClient::readDataFromCommit(const FilePath &repoDirectory, const QString
|
||||
CommitData &commitData, QString *errorMessage,
|
||||
QString *commitTemplate)
|
||||
{
|
||||
// Get commit data as "SHA1<lf>author<lf>email<lf>message".
|
||||
// Get commit data as "hash<lf>author<lf>email<lf>message".
|
||||
const QStringList arguments = {"log", "--max-count=1", "--pretty=format:%h\n%aN\n%aE\n%B", commit};
|
||||
const CommandResult result = vcsSynchronousExec(repoDirectory, arguments, RunFlags::NoOutput);
|
||||
|
||||
@@ -2677,7 +2677,7 @@ bool GitClient::readDataFromCommit(const FilePath &repoDirectory, const QString
|
||||
? QTextCodec::codecForName("UTF-8")
|
||||
: commitData.commitEncoding;
|
||||
QByteArray stdOut = result.rawStdOut();
|
||||
commitData.amendSHA1 = QLatin1String(shiftLogLine(stdOut));
|
||||
commitData.amendHash = QLatin1String(shiftLogLine(stdOut));
|
||||
commitData.panelData.author = authorCodec->toUnicode(shiftLogLine(stdOut));
|
||||
commitData.panelData.email = authorCodec->toUnicode(shiftLogLine(stdOut));
|
||||
if (commitTemplate)
|
||||
@@ -2800,7 +2800,7 @@ bool GitClient::getCommitData(const FilePath &workingDirectory,
|
||||
// For cherry-picked commit, read author data from the commit (but template from MERGE_MSG)
|
||||
if (gitDir.pathAppended(CHERRY_PICK_HEAD).exists()) {
|
||||
authorFromCherryPick = readDataFromCommit(repoDirectory, CHERRY_PICK_HEAD, commitData);
|
||||
commitData.amendSHA1.clear();
|
||||
commitData.amendHash.clear();
|
||||
}
|
||||
if (!authorFromCherryPick) {
|
||||
const Author author = getAuthor(workingDirectory);
|
||||
@@ -2839,19 +2839,19 @@ bool GitClient::getCommitData(const FilePath &workingDirectory,
|
||||
}
|
||||
|
||||
// Log message for commits/amended commits to go to output window
|
||||
static inline QString msgCommitted(const QString &amendSHA1, int fileCount)
|
||||
static inline QString msgCommitted(const QString &amendHash, int fileCount)
|
||||
{
|
||||
if (amendSHA1.isEmpty())
|
||||
if (amendHash.isEmpty())
|
||||
return Tr::tr("Committed %n files.", nullptr, fileCount);
|
||||
if (fileCount)
|
||||
return Tr::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1);
|
||||
return Tr::tr("Amended \"%1\".").arg(amendSHA1);
|
||||
return Tr::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendHash);
|
||||
return Tr::tr("Amended \"%1\".").arg(amendHash);
|
||||
}
|
||||
|
||||
bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
|
||||
const GitSubmitEditorPanelData &data,
|
||||
CommitType commitType,
|
||||
const QString &amendSHA1,
|
||||
const QString &amendHash,
|
||||
const FilePath &messageFile,
|
||||
SubmitFileModel *model)
|
||||
{
|
||||
@@ -2914,7 +2914,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
|
||||
// Do the final commit
|
||||
QStringList arguments = {"commit"};
|
||||
if (commitType == FixupCommit) {
|
||||
arguments << "--fixup" << amendSHA1;
|
||||
arguments << "--fixup" << amendHash;
|
||||
} else {
|
||||
arguments << "-F" << messageFile.nativePath();
|
||||
if (commitType == AmendCommit)
|
||||
@@ -2931,7 +2931,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
|
||||
const CommandResult result = vcsSynchronousExec(repositoryDirectory, arguments,
|
||||
RunFlags::UseEventLoop);
|
||||
if (result.result() == ProcessResult::FinishedWithSuccess) {
|
||||
VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount));
|
||||
VcsOutputWindow::appendMessage(msgCommitted(amendHash, commitCount));
|
||||
updateCurrentBranch();
|
||||
return true;
|
||||
}
|
||||
@@ -3449,9 +3449,9 @@ bool GitClient::synchronousStashRemove(const FilePath &workingDirectory, const Q
|
||||
}
|
||||
|
||||
/* Parse a stash line in its 2 manifestations (with message/without message containing
|
||||
* <base_sha1>+subject):
|
||||
* <base_hash>+subject):
|
||||
\code
|
||||
stash@{1}: WIP on <branch>: <base_sha1> <subject_base_sha1>
|
||||
stash@{1}: WIP on <branch>: <base_hash> <subject_base_hash>
|
||||
stash@{2}: On <branch>: <message>
|
||||
\endcode */
|
||||
|
||||
|
@@ -303,7 +303,7 @@ public:
|
||||
bool addAndCommit(const Utils::FilePath &workingDirectory,
|
||||
const GitSubmitEditorPanelData &data,
|
||||
CommitType commitType,
|
||||
const QString &amendSHA1,
|
||||
const QString &amendHash,
|
||||
const Utils::FilePath &messageFile,
|
||||
VcsBase::SubmitFileModel *model);
|
||||
|
||||
|
@@ -272,7 +272,7 @@ void GitEditorWidget::aboutToOpen(const FilePath &filePath, const FilePath &real
|
||||
|
||||
QString GitEditorWidget::decorateVersion(const QString &revision) const
|
||||
{
|
||||
// Format verbose, SHA1 being first token
|
||||
// Format verbose, hash being first token
|
||||
return gitClient().synchronousShortDescription(sourceWorkingDirectory(), revision);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
|
||||
{
|
||||
QStringList revisions;
|
||||
QString errorMessage;
|
||||
// Get the SHA1's of the file.
|
||||
// Get the hashes of the file.
|
||||
if (!gitClient().synchronousParentRevisions(
|
||||
sourceWorkingDirectory(), revision, &revisions, &errorMessage)) {
|
||||
VcsOutputWindow::appendSilently(errorMessage);
|
||||
|
@@ -1362,7 +1362,7 @@ IEditor *GitPluginPrivate::openSubmitEditor(const FilePath &fileName, const Comm
|
||||
QString title;
|
||||
switch (cd.commitType) {
|
||||
case AmendCommit:
|
||||
title = Tr::tr("Amend %1").arg(cd.amendSHA1);
|
||||
title = Tr::tr("Amend %1").arg(cd.amendHash);
|
||||
break;
|
||||
case FixupCommit:
|
||||
title = Tr::tr("Git Fixup Commit");
|
||||
@@ -1393,14 +1393,14 @@ bool GitPluginPrivate::activateCommit()
|
||||
|
||||
auto model = qobject_cast<SubmitFileModel *>(editor->fileModel());
|
||||
const CommitType commitType = editor->commitType();
|
||||
const QString amendSHA1 = editor->amendSHA1();
|
||||
if (model->hasCheckedFiles() || !amendSHA1.isEmpty()) {
|
||||
const QString amendHash = editor->amendHash();
|
||||
if (model->hasCheckedFiles() || !amendHash.isEmpty()) {
|
||||
// get message & commit
|
||||
if (!DocumentManager::saveDocument(editorDocument))
|
||||
return false;
|
||||
|
||||
if (!gitClient().addAndCommit(m_submitRepository, editor->panelData(), commitType,
|
||||
amendSHA1, m_commitMessageFileName, model)) {
|
||||
amendHash, m_commitMessageFileName, model)) {
|
||||
editor->updateFileModel();
|
||||
return false;
|
||||
}
|
||||
@@ -1411,7 +1411,7 @@ bool GitPluginPrivate::activateCommit()
|
||||
NoPrompt, editor->panelData().pushAction)) {
|
||||
return false;
|
||||
}
|
||||
gitClient().interactiveRebase(m_submitRepository, amendSHA1, true);
|
||||
gitClient().interactiveRebase(m_submitRepository, amendHash, true);
|
||||
} else {
|
||||
gitClient().continueCommandIfNeeded(m_submitRepository);
|
||||
if (editor->panelData().pushAction == NormalPush) {
|
||||
|
@@ -106,7 +106,7 @@ void GitSubmitEditor::setCommitData(const CommitData &d)
|
||||
m_commitEncoding = d.commitEncoding;
|
||||
m_workingDirectory = d.panelInfo.repository;
|
||||
m_commitType = d.commitType;
|
||||
m_amendSHA1 = d.amendSHA1;
|
||||
m_amenHash = d.amendHash;
|
||||
|
||||
GitSubmitEditorWidget *w = submitEditorWidget();
|
||||
w->initialize(m_workingDirectory, d);
|
||||
@@ -243,10 +243,10 @@ GitSubmitEditorPanelData GitSubmitEditor::panelData() const
|
||||
return submitEditorWidget()->panelData();
|
||||
}
|
||||
|
||||
QString GitSubmitEditor::amendSHA1() const
|
||||
QString GitSubmitEditor::amendHash() const
|
||||
{
|
||||
const QString commit = submitEditorWidget()->amendSHA1();
|
||||
return commit.isEmpty() ? m_amendSHA1 : commit;
|
||||
const QString commit = submitEditorWidget()->amendHash();
|
||||
return commit.isEmpty() ? m_amenHash : commit;
|
||||
}
|
||||
|
||||
QByteArray GitSubmitEditor::fileContents() const
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
void setCommitData(const CommitData &);
|
||||
GitSubmitEditorPanelData panelData() const;
|
||||
CommitType commitType() const { return m_commitType; }
|
||||
QString amendSHA1() const;
|
||||
QString amendHash() const;
|
||||
void updateFileModel() override;
|
||||
|
||||
protected:
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
VcsBase::SubmitFileModel *m_model = nullptr;
|
||||
QTextCodec *m_commitEncoding = nullptr;
|
||||
CommitType m_commitType = SimpleCommit;
|
||||
QString m_amendSHA1;
|
||||
QString m_amenHash;
|
||||
Utils::FilePath m_workingDirectory;
|
||||
bool m_firstUpdate = true;
|
||||
QFutureWatcher<CommitDataFetchResult> m_fetchWatcher;
|
||||
|
@@ -128,7 +128,7 @@ void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info)
|
||||
}
|
||||
}
|
||||
|
||||
QString GitSubmitEditorWidget::amendSHA1() const
|
||||
QString GitSubmitEditorWidget::amendHash() const
|
||||
{
|
||||
return m_logChangeWidget ? m_logChangeWidget->commit() : QString();
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
GitSubmitEditorWidget();
|
||||
|
||||
GitSubmitEditorPanelData panelData() const;
|
||||
QString amendSHA1() const;
|
||||
QString amendHash() const;
|
||||
void setHasUnmerged(bool e);
|
||||
void initialize(const Utils::FilePath &repository, const CommitData &data);
|
||||
void refreshLog(const Utils::FilePath &repository);
|
||||
|
@@ -254,7 +254,7 @@ void InstantBlame::setup()
|
||||
|
||||
// Porcelain format of git blame output:
|
||||
// Consists of 12 or 13 lines (line 11 can be missing, "boundary", or "previous")
|
||||
// The first line contains SHA-1, original line, current line,
|
||||
// The first line contains hash, original line, current line,
|
||||
// and optional the number of lines in this group when blaming multiple lines.
|
||||
// The last line starts with a tab and is followed by the actual file content.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -30,7 +30,7 @@ namespace Git::Internal {
|
||||
|
||||
enum Columns
|
||||
{
|
||||
Sha1Column,
|
||||
HashColumn,
|
||||
SubjectColumn,
|
||||
ColumnCount
|
||||
};
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
QVariant data(const QModelIndex &index, int role) const override
|
||||
{
|
||||
if (role == Qt::ToolTipRole) {
|
||||
const QString revision = index.sibling(index.row(), Sha1Column).data(Qt::EditRole).toString();
|
||||
const QString revision = index.sibling(index.row(), HashColumn).data(Qt::EditRole).toString();
|
||||
const auto it = m_descriptions.constFind(revision);
|
||||
if (it != m_descriptions.constEnd())
|
||||
return *it;
|
||||
@@ -92,8 +92,8 @@ bool LogChangeWidget::init(const FilePath &repository, const QString &commit, Lo
|
||||
|
||||
QString LogChangeWidget::commit() const
|
||||
{
|
||||
if (const QStandardItem *sha1Item = currentItem(Sha1Column))
|
||||
return sha1Item->text();
|
||||
if (const QStandardItem *hashItem = currentItem(HashColumn))
|
||||
return hashItem->text();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ QString LogChangeWidget::earliestCommit() const
|
||||
{
|
||||
int rows = m_model->rowCount();
|
||||
if (rows) {
|
||||
if (const QStandardItem *item = m_model->item(rows - 1, Sha1Column))
|
||||
if (const QStandardItem *item = m_model->item(rows - 1, HashColumn))
|
||||
return item->text();
|
||||
}
|
||||
return {};
|
||||
@@ -124,7 +124,7 @@ void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
|
||||
void LogChangeWidget::emitCommitActivated(const QModelIndex &index)
|
||||
{
|
||||
if (index.isValid()) {
|
||||
const QString commit = index.sibling(index.row(), Sha1Column).data().toString();
|
||||
const QString commit = index.sibling(index.row(), HashColumn).data().toString();
|
||||
if (!commit.isEmpty())
|
||||
emit commitActivated(commit);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ bool LogChangeWidget::populateLog(const FilePath &repository, const QString &com
|
||||
if (const int rowCount = m_model->rowCount())
|
||||
m_model->removeRows(0, rowCount);
|
||||
|
||||
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
|
||||
// Retrieve log using a custom format "Hash:Subject [(refs)]"
|
||||
QStringList arguments;
|
||||
arguments << "--max-count=1000" << "--format=%h:%s %d";
|
||||
arguments << (commit.isEmpty() ? "HEAD" : commit);
|
||||
@@ -188,11 +188,11 @@ bool LogChangeWidget::populateLog(const FilePath &repository, const QString &com
|
||||
}
|
||||
row.push_back(item);
|
||||
}
|
||||
const QString sha1 = line.left(colonPos);
|
||||
row[Sha1Column]->setText(sha1);
|
||||
const QString hash = line.left(colonPos);
|
||||
row[HashColumn]->setText(hash);
|
||||
row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1));
|
||||
m_model->appendRow(row);
|
||||
if (selected == -1 && currentCommit == sha1)
|
||||
if (selected == -1 && currentCommit == hash)
|
||||
selected = m_model->rowCount() - 1;
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ namespace Git::Internal {
|
||||
|
||||
class LogChangeModel;
|
||||
|
||||
// A widget that lists SHA1 and subject of the changes
|
||||
// A widget that lists hash and subject of the changes
|
||||
// Used for reset and interactive rebase
|
||||
|
||||
class LogChangeWidget : public Utils::TreeView
|
||||
|
Reference in New Issue
Block a user