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:
Alex Shvartzkop
2026-01-16 01:50:45 +03:00
parent 7a26dca71b
commit 523b1eb992
2 changed files with 13 additions and 13 deletions
+11
View File
@@ -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;
}
+2 -13
View File
@@ -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;