Git: Replace "SHA1" with "hash" in code and comments

Change-Id: Iaa6712338b86a5a7fd4889734d5650c6751fcf95
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Andre Hartmann
2024-09-09 20:37:46 +02:00
committed by André Hartmann
parent 7e70eefabe
commit eee38e585e
13 changed files with 44 additions and 44 deletions

View File

@@ -48,7 +48,7 @@ void CommitData::clear()
{ {
panelInfo.clear(); panelInfo.clear();
panelData.clear(); panelData.clear();
amendSHA1.clear(); amendHash.clear();
enablePush = false; enablePush = false;
files.clear(); files.clear();

View File

@@ -84,7 +84,7 @@ public:
static QString stateDisplayName(const FileStates &state); static QString stateDisplayName(const FileStates &state);
CommitType commitType; CommitType commitType;
QString amendSHA1; QString amendHash;
QTextCodec *commitEncoding = nullptr; QTextCodec *commitEncoding = nullptr;
GitSubmitEditorPanelInfo panelInfo; GitSubmitEditorPanelInfo panelInfo;
GitSubmitEditorPanelData panelData; GitSubmitEditorPanelData panelData;

View File

@@ -1608,7 +1608,7 @@ static QString msgParentRevisionFailed(const FilePath &workingDirectory,
const QString &revision, const QString &revision,
const QString &why) 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") return Tr::tr("Cannot find parent revisions of \"%1\" in \"%2\": %3")
.arg(revision, workingDirectory.toUserOutput(), why); .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. // leaving it in breaks command line quoting on Windows, see QTCREATORBUG-23208.
const QString quoteReplacement = "_-_"; const QString quoteReplacement = "_-_";
// Short SHA1, author, subject // Short hash, author, subject
const QString defaultShortLogFormat = "%h (%aN " + quoteReplacement + "%s"; const QString defaultShortLogFormat = "%h (%aN " + quoteReplacement + "%s";
const int maxShortLogLength = 120; const int maxShortLogLength = 120;
@@ -2661,7 +2661,7 @@ bool GitClient::readDataFromCommit(const FilePath &repoDirectory, const QString
CommitData &commitData, QString *errorMessage, CommitData &commitData, QString *errorMessage,
QString *commitTemplate) 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 QStringList arguments = {"log", "--max-count=1", "--pretty=format:%h\n%aN\n%aE\n%B", commit};
const CommandResult result = vcsSynchronousExec(repoDirectory, arguments, RunFlags::NoOutput); const CommandResult result = vcsSynchronousExec(repoDirectory, arguments, RunFlags::NoOutput);
@@ -2677,7 +2677,7 @@ bool GitClient::readDataFromCommit(const FilePath &repoDirectory, const QString
? QTextCodec::codecForName("UTF-8") ? QTextCodec::codecForName("UTF-8")
: commitData.commitEncoding; : commitData.commitEncoding;
QByteArray stdOut = result.rawStdOut(); QByteArray stdOut = result.rawStdOut();
commitData.amendSHA1 = QLatin1String(shiftLogLine(stdOut)); commitData.amendHash = QLatin1String(shiftLogLine(stdOut));
commitData.panelData.author = authorCodec->toUnicode(shiftLogLine(stdOut)); commitData.panelData.author = authorCodec->toUnicode(shiftLogLine(stdOut));
commitData.panelData.email = authorCodec->toUnicode(shiftLogLine(stdOut)); commitData.panelData.email = authorCodec->toUnicode(shiftLogLine(stdOut));
if (commitTemplate) 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) // For cherry-picked commit, read author data from the commit (but template from MERGE_MSG)
if (gitDir.pathAppended(CHERRY_PICK_HEAD).exists()) { if (gitDir.pathAppended(CHERRY_PICK_HEAD).exists()) {
authorFromCherryPick = readDataFromCommit(repoDirectory, CHERRY_PICK_HEAD, commitData); authorFromCherryPick = readDataFromCommit(repoDirectory, CHERRY_PICK_HEAD, commitData);
commitData.amendSHA1.clear(); commitData.amendHash.clear();
} }
if (!authorFromCherryPick) { if (!authorFromCherryPick) {
const Author author = getAuthor(workingDirectory); 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 // 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); return Tr::tr("Committed %n files.", nullptr, fileCount);
if (fileCount) if (fileCount)
return Tr::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1); return Tr::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendHash);
return Tr::tr("Amended \"%1\".").arg(amendSHA1); return Tr::tr("Amended \"%1\".").arg(amendHash);
} }
bool GitClient::addAndCommit(const FilePath &repositoryDirectory, bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
const GitSubmitEditorPanelData &data, const GitSubmitEditorPanelData &data,
CommitType commitType, CommitType commitType,
const QString &amendSHA1, const QString &amendHash,
const FilePath &messageFile, const FilePath &messageFile,
SubmitFileModel *model) SubmitFileModel *model)
{ {
@@ -2914,7 +2914,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
// Do the final commit // Do the final commit
QStringList arguments = {"commit"}; QStringList arguments = {"commit"};
if (commitType == FixupCommit) { if (commitType == FixupCommit) {
arguments << "--fixup" << amendSHA1; arguments << "--fixup" << amendHash;
} else { } else {
arguments << "-F" << messageFile.nativePath(); arguments << "-F" << messageFile.nativePath();
if (commitType == AmendCommit) if (commitType == AmendCommit)
@@ -2931,7 +2931,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory,
const CommandResult result = vcsSynchronousExec(repositoryDirectory, arguments, const CommandResult result = vcsSynchronousExec(repositoryDirectory, arguments,
RunFlags::UseEventLoop); RunFlags::UseEventLoop);
if (result.result() == ProcessResult::FinishedWithSuccess) { if (result.result() == ProcessResult::FinishedWithSuccess) {
VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount)); VcsOutputWindow::appendMessage(msgCommitted(amendHash, commitCount));
updateCurrentBranch(); updateCurrentBranch();
return true; 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 /* Parse a stash line in its 2 manifestations (with message/without message containing
* <base_sha1>+subject): * <base_hash>+subject):
\code \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> stash@{2}: On <branch>: <message>
\endcode */ \endcode */

View File

@@ -303,7 +303,7 @@ public:
bool addAndCommit(const Utils::FilePath &workingDirectory, bool addAndCommit(const Utils::FilePath &workingDirectory,
const GitSubmitEditorPanelData &data, const GitSubmitEditorPanelData &data,
CommitType commitType, CommitType commitType,
const QString &amendSHA1, const QString &amendHash,
const Utils::FilePath &messageFile, const Utils::FilePath &messageFile,
VcsBase::SubmitFileModel *model); VcsBase::SubmitFileModel *model);

View File

@@ -272,7 +272,7 @@ void GitEditorWidget::aboutToOpen(const FilePath &filePath, const FilePath &real
QString GitEditorWidget::decorateVersion(const QString &revision) const QString GitEditorWidget::decorateVersion(const QString &revision) const
{ {
// Format verbose, SHA1 being first token // Format verbose, hash being first token
return gitClient().synchronousShortDescription(sourceWorkingDirectory(), revision); return gitClient().synchronousShortDescription(sourceWorkingDirectory(), revision);
} }
@@ -280,7 +280,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
{ {
QStringList revisions; QStringList revisions;
QString errorMessage; QString errorMessage;
// Get the SHA1's of the file. // Get the hashes of the file.
if (!gitClient().synchronousParentRevisions( if (!gitClient().synchronousParentRevisions(
sourceWorkingDirectory(), revision, &revisions, &errorMessage)) { sourceWorkingDirectory(), revision, &revisions, &errorMessage)) {
VcsOutputWindow::appendSilently(errorMessage); VcsOutputWindow::appendSilently(errorMessage);

View File

@@ -1362,7 +1362,7 @@ IEditor *GitPluginPrivate::openSubmitEditor(const FilePath &fileName, const Comm
QString title; QString title;
switch (cd.commitType) { switch (cd.commitType) {
case AmendCommit: case AmendCommit:
title = Tr::tr("Amend %1").arg(cd.amendSHA1); title = Tr::tr("Amend %1").arg(cd.amendHash);
break; break;
case FixupCommit: case FixupCommit:
title = Tr::tr("Git Fixup Commit"); title = Tr::tr("Git Fixup Commit");
@@ -1393,14 +1393,14 @@ bool GitPluginPrivate::activateCommit()
auto model = qobject_cast<SubmitFileModel *>(editor->fileModel()); auto model = qobject_cast<SubmitFileModel *>(editor->fileModel());
const CommitType commitType = editor->commitType(); const CommitType commitType = editor->commitType();
const QString amendSHA1 = editor->amendSHA1(); const QString amendHash = editor->amendHash();
if (model->hasCheckedFiles() || !amendSHA1.isEmpty()) { if (model->hasCheckedFiles() || !amendHash.isEmpty()) {
// get message & commit // get message & commit
if (!DocumentManager::saveDocument(editorDocument)) if (!DocumentManager::saveDocument(editorDocument))
return false; return false;
if (!gitClient().addAndCommit(m_submitRepository, editor->panelData(), commitType, if (!gitClient().addAndCommit(m_submitRepository, editor->panelData(), commitType,
amendSHA1, m_commitMessageFileName, model)) { amendHash, m_commitMessageFileName, model)) {
editor->updateFileModel(); editor->updateFileModel();
return false; return false;
} }
@@ -1411,7 +1411,7 @@ bool GitPluginPrivate::activateCommit()
NoPrompt, editor->panelData().pushAction)) { NoPrompt, editor->panelData().pushAction)) {
return false; return false;
} }
gitClient().interactiveRebase(m_submitRepository, amendSHA1, true); gitClient().interactiveRebase(m_submitRepository, amendHash, true);
} else { } else {
gitClient().continueCommandIfNeeded(m_submitRepository); gitClient().continueCommandIfNeeded(m_submitRepository);
if (editor->panelData().pushAction == NormalPush) { if (editor->panelData().pushAction == NormalPush) {

View File

@@ -106,7 +106,7 @@ void GitSubmitEditor::setCommitData(const CommitData &d)
m_commitEncoding = d.commitEncoding; m_commitEncoding = d.commitEncoding;
m_workingDirectory = d.panelInfo.repository; m_workingDirectory = d.panelInfo.repository;
m_commitType = d.commitType; m_commitType = d.commitType;
m_amendSHA1 = d.amendSHA1; m_amenHash = d.amendHash;
GitSubmitEditorWidget *w = submitEditorWidget(); GitSubmitEditorWidget *w = submitEditorWidget();
w->initialize(m_workingDirectory, d); w->initialize(m_workingDirectory, d);
@@ -243,10 +243,10 @@ GitSubmitEditorPanelData GitSubmitEditor::panelData() const
return submitEditorWidget()->panelData(); return submitEditorWidget()->panelData();
} }
QString GitSubmitEditor::amendSHA1() const QString GitSubmitEditor::amendHash() const
{ {
const QString commit = submitEditorWidget()->amendSHA1(); const QString commit = submitEditorWidget()->amendHash();
return commit.isEmpty() ? m_amendSHA1 : commit; return commit.isEmpty() ? m_amenHash : commit;
} }
QByteArray GitSubmitEditor::fileContents() const QByteArray GitSubmitEditor::fileContents() const

View File

@@ -40,7 +40,7 @@ public:
void setCommitData(const CommitData &); void setCommitData(const CommitData &);
GitSubmitEditorPanelData panelData() const; GitSubmitEditorPanelData panelData() const;
CommitType commitType() const { return m_commitType; } CommitType commitType() const { return m_commitType; }
QString amendSHA1() const; QString amendHash() const;
void updateFileModel() override; void updateFileModel() override;
protected: protected:
@@ -58,7 +58,7 @@ private:
VcsBase::SubmitFileModel *m_model = nullptr; VcsBase::SubmitFileModel *m_model = nullptr;
QTextCodec *m_commitEncoding = nullptr; QTextCodec *m_commitEncoding = nullptr;
CommitType m_commitType = SimpleCommit; CommitType m_commitType = SimpleCommit;
QString m_amendSHA1; QString m_amenHash;
Utils::FilePath m_workingDirectory; Utils::FilePath m_workingDirectory;
bool m_firstUpdate = true; bool m_firstUpdate = true;
QFutureWatcher<CommitDataFetchResult> m_fetchWatcher; QFutureWatcher<CommitDataFetchResult> m_fetchWatcher;

View File

@@ -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(); return m_logChangeWidget ? m_logChangeWidget->commit() : QString();
} }

View File

@@ -39,7 +39,7 @@ public:
GitSubmitEditorWidget(); GitSubmitEditorWidget();
GitSubmitEditorPanelData panelData() const; GitSubmitEditorPanelData panelData() const;
QString amendSHA1() const; QString amendHash() const;
void setHasUnmerged(bool e); void setHasUnmerged(bool e);
void initialize(const Utils::FilePath &repository, const CommitData &data); void initialize(const Utils::FilePath &repository, const CommitData &data);
void refreshLog(const Utils::FilePath &repository); void refreshLog(const Utils::FilePath &repository);

View File

@@ -254,7 +254,7 @@ void InstantBlame::setup()
// Porcelain format of git blame output: // Porcelain format of git blame output:
// Consists of 12 or 13 lines (line 11 can be missing, "boundary", or "previous") // 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. // 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. // The last line starts with a tab and is followed by the actual file content.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -30,7 +30,7 @@ namespace Git::Internal {
enum Columns enum Columns
{ {
Sha1Column, HashColumn,
SubjectColumn, SubjectColumn,
ColumnCount ColumnCount
}; };
@@ -43,7 +43,7 @@ public:
QVariant data(const QModelIndex &index, int role) const override QVariant data(const QModelIndex &index, int role) const override
{ {
if (role == Qt::ToolTipRole) { 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); const auto it = m_descriptions.constFind(revision);
if (it != m_descriptions.constEnd()) if (it != m_descriptions.constEnd())
return *it; return *it;
@@ -92,8 +92,8 @@ bool LogChangeWidget::init(const FilePath &repository, const QString &commit, Lo
QString LogChangeWidget::commit() const QString LogChangeWidget::commit() const
{ {
if (const QStandardItem *sha1Item = currentItem(Sha1Column)) if (const QStandardItem *hashItem = currentItem(HashColumn))
return sha1Item->text(); return hashItem->text();
return {}; return {};
} }
@@ -109,7 +109,7 @@ QString LogChangeWidget::earliestCommit() const
{ {
int rows = m_model->rowCount(); int rows = m_model->rowCount();
if (rows) { 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 item->text();
} }
return {}; return {};
@@ -124,7 +124,7 @@ void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
void LogChangeWidget::emitCommitActivated(const QModelIndex &index) void LogChangeWidget::emitCommitActivated(const QModelIndex &index)
{ {
if (index.isValid()) { 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()) if (!commit.isEmpty())
emit commitActivated(commit); emit commitActivated(commit);
} }
@@ -157,7 +157,7 @@ bool LogChangeWidget::populateLog(const FilePath &repository, const QString &com
if (const int rowCount = m_model->rowCount()) if (const int rowCount = m_model->rowCount())
m_model->removeRows(0, 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; QStringList arguments;
arguments << "--max-count=1000" << "--format=%h:%s %d"; arguments << "--max-count=1000" << "--format=%h:%s %d";
arguments << (commit.isEmpty() ? "HEAD" : commit); arguments << (commit.isEmpty() ? "HEAD" : commit);
@@ -188,11 +188,11 @@ bool LogChangeWidget::populateLog(const FilePath &repository, const QString &com
} }
row.push_back(item); row.push_back(item);
} }
const QString sha1 = line.left(colonPos); const QString hash = line.left(colonPos);
row[Sha1Column]->setText(sha1); row[HashColumn]->setText(hash);
row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1)); row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1));
m_model->appendRow(row); m_model->appendRow(row);
if (selected == -1 && currentCommit == sha1) if (selected == -1 && currentCommit == hash)
selected = m_model->rowCount() - 1; selected = m_model->rowCount() - 1;
} }
} }

View File

@@ -22,7 +22,7 @@ namespace Git::Internal {
class LogChangeModel; 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 // Used for reset and interactive rebase
class LogChangeWidget : public Utils::TreeView class LogChangeWidget : public Utils::TreeView