Set git workdir to project path so we don't have to copy the project files to .history
See https://gitlab.com/kicad/code/kicad/-/issues/22588
This commit is contained in:
@@ -184,6 +184,17 @@ bool HISTORY_LOCK_MANAGER::openRepository()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to set workdir
|
||||
rc = git_repository_set_workdir( m_repo, m_projectPath.mb_str().data(), false );
|
||||
|
||||
if( rc != 0 )
|
||||
{
|
||||
const git_error* err = git_error_last();
|
||||
m_lockError = wxString::Format( _( "Failed to set git repository workdir to %s: %s" ), m_projectPath,
|
||||
err ? wxString::FromUTF8( err->message ) : wxString( "Unknown error" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_repoOwned = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,19 +447,8 @@ static bool commitSnapshotWithLock( git_repository* repo, git_index* index,
|
||||
else
|
||||
relStr = src.GetFullName(); // Fallback (should not normally happen)
|
||||
|
||||
wxFileName dst( aHistoryPath + wxFILE_SEP_PATH + relStr );
|
||||
|
||||
// Ensure directory tree exists.
|
||||
wxFileName dstDir( dst );
|
||||
dstDir.SetFullName( wxEmptyString );
|
||||
wxFileName::Mkdir( dstDir.GetPath(), 0777, wxPATH_MKDIR_FULL );
|
||||
|
||||
// Copy file into history mirror.
|
||||
wxCopyFile( src.GetFullPath(), dst.GetFullPath(), true );
|
||||
|
||||
// Path inside repo (strip hist + '/').
|
||||
std::string rel = dst.GetFullPath().ToStdString().substr( aHistoryPath.length() + 1 );
|
||||
git_index_add_bypath( index, rel.c_str() );
|
||||
int rc = git_index_add_bypath( index, relStr.mb_str().data() );
|
||||
wxLogTrace( traceAutoSave, wxS( "Adding %s ret: %d" ), relStr, rc );
|
||||
}
|
||||
|
||||
git_oid tree_id;
|
||||
|
||||
Reference in New Issue
Block a user