@@ -638,9 +638,6 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}"
638638 const editorScriptPath : string = path . join ( dotGitDirPath , "editorScript.doActualRebase.sh" ) ;
639639 fs . writeFileSync ( editorScriptPath , editorScript , { mode : "777" } ) ;
640640
641- const referenceToOid = ( ref : Git . Reference ) : Promise < Git . Oid > =>
642- ref . peel ( Git . Object . TYPE . COMMIT ) . then ( ( x ) => x . id ( ) ) ;
643-
644641 const commitOfInitialBranch : Git . Oid = await referenceToOid ( initialBranch ) ; // bb
645642 const commitOfCurrentBranch : Git . Oid = await referenceToOid ( currentBranch ) ;
646643
@@ -833,6 +830,10 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}"
833830 }
834831} ;
835832
833+ function referenceToOid ( ref : Git . Reference ) : Promise < Git . Oid > {
834+ return ref . peel ( Git . Object . TYPE . COMMIT ) . then ( ( x ) => x . id ( ) ) ;
835+ }
836+
836837export function removeUndefinedProperties < T , K extends keyof Partial < T > > (
837838 object : Partial < T > //
838839) : Partial < T > {
@@ -1033,9 +1034,6 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
10331034 resolved : ( await bb . resolve ( ) ) . name ( ) ,
10341035 } ) ;
10351036
1036- const referenceToOid = ( ref : Git . Reference ) : Promise < Git . Oid > =>
1037- ref . peel ( Git . Object . TYPE . COMMIT ) . then ( ( x ) => x . id ( ) ) ;
1038-
10391037 const commitOfInitialBranch : Git . Oid = await referenceToOid ( bb ) ;
10401038 const commitOfCurrentBranch : Git . Oid = await referenceToOid ( currentBranch ) ;
10411039
@@ -1072,7 +1070,7 @@ export async function getWantedCommitsWithBranchBoundariesOurCustomImpl(
10721070 )
10731071 ) ;
10741072
1075- return extendCommitsWithBranchEnds ( repo , bb , wantedCommits ) ;
1073+ return extendCommitsWithBranchEnds ( repo , bb , currentBranch , wantedCommits ) ;
10761074}
10771075
10781076noop ( getWantedCommitsWithBranchBoundariesUsingNativeGitRebase ) ;
@@ -1251,6 +1249,7 @@ exit 1
12511249 const commitsWithBranchBoundaries : CommitAndBranchBoundary [ ] = await extendCommitsWithBranchEnds (
12521250 repo ,
12531251 initialBranch ,
1252+ currentBranch ,
12541253 commits ,
12551254 commandOrAliasNames
12561255 ) ;
@@ -1261,6 +1260,7 @@ exit 1
12611260async function extendCommitsWithBranchEnds (
12621261 repo : Git . Repository ,
12631262 initialBranch : Git . Reference ,
1263+ currentBranch : Git . Reference ,
12641264 commits : Git . Commit [ ] ,
12651265 /**
12661266 * used for properly assigning the command to a commit,
@@ -1280,6 +1280,8 @@ async function extendCommitsWithBranchEnds(
12801280 const removeLocalRegex = / ^ r e f s \/ h e a d s \/ / ;
12811281 const removeRemoteRegex = / ^ r e f s \/ r e m o t e s \/ [ ^ / ] * \/ / ;
12821282
1283+ const currentBranchCommit : Git . Oid = await referenceToOid ( currentBranch ) ;
1284+
12831285 const extend = ( c : Git . Commit , i : number ) : CommitAndBranchBoundary => (
12841286 ( matchedRefs = refs . filter ( ( ref ) => ! ! ref . target ( ) ?. equal ( c . id ( ) ) ) ) ,
12851287 /**
@@ -1314,7 +1316,7 @@ async function extendCommitsWithBranchEnds(
13141316 matchedRefs . length <= 1 ||
13151317 /**
13161318 * if it's more than 1,
1317- * it's only allowed all of the branches are the same ones,
1319+ * it's only allowed if all of the branches are the same ones,
13181320 * just on different remotes.
13191321 */
13201322 ( matchedRefs . length > 1 &&
@@ -1325,7 +1327,11 @@ async function extendCommitsWithBranchEnds(
13251327 . replace ( removeLocalRegex , "" )
13261328 . replace ( removeRemoteRegex , "" )
13271329 )
1328- ) . length === 1 ) ,
1330+ ) . length === 1 ) ||
1331+ /**
1332+ * or, if it's the root branch
1333+ */
1334+ ! c . id ( ) . cmp ( currentBranchCommit ) ,
13291335 "" +
13301336 "2 (or more) branches for the same commit, both in the same path - cannot continue" +
13311337 "(until explicit branch specifying is implemented)" +
0 commit comments