@@ -4,12 +4,13 @@ use anyhow::{anyhow, Context, Result};
44use bstr:: ByteSlice ;
55use gitbutler_branch:: {
66 self , Branch , BranchCreateRequest , SignaturePurpose , VirtualBranchesHandle ,
7- GITBUTLER_INTEGRATION_REFERENCE ,
7+ GITBUTLER_WORKSPACE_REFERENCE ,
88} ;
99use gitbutler_cherry_pick:: RepositoryExt as _;
1010use gitbutler_command_context:: CommandContext ;
1111use gitbutler_commit:: commit_ext:: CommitExt ;
1212use gitbutler_error:: error:: Marker ;
13+ use gitbutler_operating_modes:: OPEN_WORKSPACE_REFS ;
1314use gitbutler_project:: access:: WorktreeWritePermission ;
1415use gitbutler_repo:: { LogUntil , RepoActionsExt , RepositoryExt } ;
1516use tracing:: instrument;
@@ -94,9 +95,9 @@ pub(crate) fn get_workspace_head(ctx: &CommandContext) -> Result<git2::Oid> {
9495 Ok ( workspace_head_id)
9596}
9697
97- // Before switching the user to our gitbutler integration branch we save
98+ // Before switching the user to our gitbutler workspace branch we save
9899// the current branch into a text file. It is used in generating the commit
99- // message for integration branch, as a helpful hint about how to get back
100+ // message for workspace branch, as a helpful hint about how to get back
100101// to where you were.
101102struct PreviousHead {
102103 head : String ,
@@ -138,8 +139,8 @@ pub fn update_gitbutler_integration(
138139 let integration_filepath = repo. path ( ) . join ( "integration" ) ;
139140 let mut prev_branch = read_integration_file ( & integration_filepath) ?;
140141 if let Some ( branch) = & prev_branch {
141- if branch. head != GITBUTLER_INTEGRATION_REFERENCE . to_string ( ) {
142- // we are moving from a regular branch to our gitbutler integration branch, write a file to
142+ if branch. head != GITBUTLER_WORKSPACE_REFERENCE . to_string ( ) {
143+ // we are moving from a regular branch to our gitbutler workspace branch, write a file to
143144 // .git/integration with the previous head and name
144145 write_integration_file ( & head_ref, integration_filepath) ?;
145146 prev_branch = Some ( PreviousHead {
@@ -218,14 +219,14 @@ pub fn update_gitbutler_integration(
218219 parents. iter ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) ,
219220 ) ?;
220221
221- // Create or replace the integration branch reference, then set as HEAD.
222+ // Create or replace the workspace branch reference, then set as HEAD.
222223 repo. reference (
223- & GITBUTLER_INTEGRATION_REFERENCE . clone ( ) . to_string ( ) ,
224+ & GITBUTLER_WORKSPACE_REFERENCE . clone ( ) . to_string ( ) ,
224225 final_commit,
225226 true ,
226227 "updated integration commit" ,
227228 ) ?;
228- repo. set_head ( & GITBUTLER_INTEGRATION_REFERENCE . clone ( ) . to_string ( ) ) ?;
229+ repo. set_head ( & GITBUTLER_WORKSPACE_REFERENCE . clone ( ) . to_string ( ) ) ?;
229230
230231 let mut index = repo. index ( ) ?;
231232 index. read_tree ( & workspace_tree) ?;
@@ -285,21 +286,21 @@ fn verify_head_is_set(ctx: &CommandContext) -> Result<()> {
285286 . context ( "failed to get head" ) ?
286287 . name ( )
287288 {
288- Some ( refname) if * refname == GITBUTLER_INTEGRATION_REFERENCE . to_string ( ) => Ok ( ( ) ) ,
289+ Some ( refname) if OPEN_WORKSPACE_REFS . contains ( & refname ) => Ok ( ( ) ) ,
289290 Some ( head_name) => Err ( invalid_head_err ( head_name) ) ,
290291 None => Err ( anyhow ! (
291292 "project in detached head state. Please checkout {} to continue" ,
292- GITBUTLER_INTEGRATION_REFERENCE . branch( )
293+ GITBUTLER_WORKSPACE_REFERENCE . branch( )
293294 ) ) ,
294295 }
295296}
296297
297- // Returns an error if repo head is not pointing to the integration branch.
298+ // Returns an error if repo head is not pointing to the workspace branch.
298299fn verify_current_branch_name ( ctx : & CommandContext ) -> Result < & CommandContext > {
299300 match ctx. repository ( ) . head ( ) ?. name ( ) {
300301 Some ( head) => {
301302 let head_name = head. to_string ( ) ;
302- if head_name != GITBUTLER_INTEGRATION_REFERENCE . to_string ( ) {
303+ if ! OPEN_WORKSPACE_REFS . contains ( & head_name . as_str ( ) ) {
303304 return Err ( invalid_head_err ( & head_name) ) ;
304305 }
305306 Ok ( ctx)
@@ -408,6 +409,6 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
408409fn invalid_head_err ( head_name : & str ) -> anyhow:: Error {
409410 anyhow ! (
410411 "project is on {head_name}. Please checkout {} to continue" ,
411- GITBUTLER_INTEGRATION_REFERENCE . branch( )
412+ GITBUTLER_WORKSPACE_REFERENCE . branch( )
412413 )
413414}
0 commit comments