From 827f5d7524fe0c9617a6fdbd3b7490520ce8c44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 6 Sep 2026 21:39:11 -0300 Subject: [PATCH] ecode: fix stale and symbolic remote branch entries Exclude symbolic remote refs such as origin/HEAD from the branch list. Remove the corresponding local remote-tracking ref after deleting a remote branch, and prune stale refs when pulling. --- src/tools/ecode/plugins/git/git.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/ecode/plugins/git/git.cpp b/src/tools/ecode/plugins/git/git.cpp index 29871d938..1c75c5105 100644 --- a/src/tools/ecode/plugins/git/git.cpp +++ b/src/tools/ecode/plugins/git/git.cpp @@ -774,7 +774,7 @@ std::string Git::setSafeDirectory( const std::string& projectDir ) const { } Git::Result Git::pull( const std::string& projectDir ) { - return gitSimple( "pull", projectDir ); + return gitSimple( "pull --prune", projectDir ); } Git::Result Git::push( const std::string& projectDir ) { @@ -979,6 +979,12 @@ Git::Result Git::deleteRemoteBranch( const std::string& remote, const std::strin const std::string& projectDir ) { Result result; result.returnCode = git( { "push", remote, "--delete", branch }, projectDir, result.result ); + if ( result.success() ) { + std::string cleanupResult; + result.returnCode = git( { "update-ref", "-d", "refs/remotes/" + remote + "/" + branch }, + projectDir, cleanupResult ); + result.result.append( cleanupResult ); + } return result; } @@ -1148,7 +1154,7 @@ Git::Branch parseLocalBranch( const std::string_view& raw ) { static Git::Branch parseRemoteBranch( std::string_view raw ) { auto split = String::split( raw, '\t', true ); - if ( split.size() < 4 ) + if ( split.size() < 4 || ( split.size() > 5 && !split[5].empty() ) ) return {}; std::string name( std::string{ split[1] } ); std::string remote( std::string{ split[1] } ); @@ -1176,7 +1182,7 @@ static Git::Branch parseTag( std::string_view raw ) { std::vector Git::getAllBranchesAndTags( RefType ref, std::string_view filterBranch, const std::string& projectDir ) { // clang-format off - std::string args( "for-each-ref --format '%(refname) %(refname:short) %(upstream:short) %(objectname) %(upstream:track,nobracket)' --sort=v:refname" ); + std::string args( "for-each-ref --format '%(refname) %(refname:short) %(upstream:short) %(objectname) %(upstream:track,nobracket) %(symref)' --sort=v:refname" ); // clang-format on if ( filterBranch.empty() ) {