@@ -289,6 +289,19 @@ export const gitStackedRebase = async (
289289
290290 const checkIsRegularRebaseStillInProgress = ( ) : boolean => fs . existsSync ( pathToRegularRebaseDirInsideDotGit ) ;
291291
292+ fs . mkdirSync ( pathToStackedRebaseDirInsideDotGit , { recursive : true } ) ;
293+
294+ const initialBranch : Git . Reference | void = await Git . Branch . lookup (
295+ repo , //
296+ nameOfInitialBranch ,
297+ Git . Branch . BRANCH . ALL
298+ ) ;
299+ if ( ! initialBranch ) {
300+ throw new Error ( "initialBranch lookup failed" ) ;
301+ }
302+
303+ const currentBranch : Git . Reference = await repo . getCurrentBranch ( ) ;
304+
292305 if ( fs . existsSync ( path . join ( pathToStackedRebaseDirInsideDotGit , filenames . willNeedToApply ) ) ) {
293306 _markThatNeedsToApply ( pathToStackedRebaseDirInsideDotGit ) ;
294307 }
@@ -300,6 +313,8 @@ export const gitStackedRebase = async (
300313 pathToStackedRebaseDirInsideDotGit, //
301314 rootLevelCommandName : "--apply" ,
302315 gitCmd : options . gitCmd ,
316+ initialBranch,
317+ currentBranch,
303318 } ) ;
304319 }
305320
@@ -327,6 +342,8 @@ export const gitStackedRebase = async (
327342 gitCmd : options . gitCmd ,
328343 autoApplyIfNeeded : configValues . autoApplyIfNeeded ,
329344 config,
345+ initialBranch,
346+ currentBranch,
330347 } ) ;
331348
332349 return ;
@@ -340,6 +357,8 @@ export const gitStackedRebase = async (
340357 gitCmd : options . gitCmd ,
341358 autoApplyIfNeeded : configValues . autoApplyIfNeeded ,
342359 config,
360+ initialBranch,
361+ currentBranch,
343362 } ) ;
344363
345364 if ( neededToApply && ! userAllowedToApplyAndWeApplied ) {
@@ -357,6 +376,8 @@ export const gitStackedRebase = async (
357376 pathToStackedRebaseDirInsideDotGit,
358377 rootLevelCommandName : "--push --force" ,
359378 gitCmd : options . gitCmd ,
379+ initialBranch,
380+ currentBranch,
360381 } ) ;
361382 }
362383
@@ -371,6 +392,8 @@ export const gitStackedRebase = async (
371392 actionInsideEachCheckedOutBranch : ( { execSyncInRepo : execS } ) => ( execS ( toExec ) , void 0 ) ,
372393 pathToStackedRebaseDirInsideDotGit,
373394 pathToStackedRebaseTodoFile,
395+ initialBranch,
396+ currentBranch,
374397 } ) ;
375398 } else {
376399 /**
@@ -382,15 +405,6 @@ export const gitStackedRebase = async (
382405 }
383406 }
384407
385- fs . mkdirSync ( pathToStackedRebaseDirInsideDotGit , { recursive : true } ) ;
386-
387- const initialBranch : Git . Reference | void = await Git . Branch . lookup (
388- repo , //
389- nameOfInitialBranch ,
390- Git . Branch . BRANCH . ALL
391- ) ;
392- const currentBranch : Git . Reference = await repo . getCurrentBranch ( ) ;
393-
394408 const wasRegularRebaseInProgress : boolean = checkIsRegularRebaseStillInProgress ( ) ;
395409 // const
396410
@@ -905,6 +919,8 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}"
905919 gitCmd : options . gitCmd ,
906920 autoApplyIfNeeded : configValues . autoApplyIfNeeded ,
907921 config,
922+ initialBranch,
923+ currentBranch,
908924 } ) ;
909925 }
910926 }
@@ -1082,7 +1098,7 @@ type CommitAndBranchBoundary = {
10821098 branchEnd : Git . Reference | null ;
10831099} ;
10841100
1085- async function getWantedCommitsWithBranchBoundariesOurCustomImpl (
1101+ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl (
10861102 repo : Git . Repository , //
10871103 /** beginningBranch */
10881104 bb : Git . Reference ,
0 commit comments