support WORKING and STAGED in three-dot revisions#11213
Conversation
|
@elianddb DOLT
|
WORKING and STAGED in three-dot revisions
| // must be non-nil for WORKING or STAGED, otherwise ResolveCommitSpecStr returns | ||
| // ErrOperationNotSupportedInDetachedHead. | ||
| func (ddb *DoltDB) ResolveCommitSpecStr(ctx context.Context, spec string, headRef ref.DoltRef) (*Commit, error) { | ||
| if IsWorkingSetRef(spec) { |
There was a problem hiding this comment.
I'm worried this change is overly broad and might result in us treating WORKING or STAGED as HEAD in places we probably shouldn't.
For instance, with this change, HAS_ANCESTOR('HEAD','WORKING') returns true, even though it shouldn't. I think it's debatable whether or not "STAGED" and "WORKING" should be valid values for the ancestor field here, but they definitely shouldn't be treated as "HEAD"
Similarly, DOLT_DIFF('STAGED...WORKING', ...) now uses HEAD as the merge base and will display already-staged changes in the diff. This seems wrong.
I think if the purpose of this function is to generate commits, then it shouldn't accept things that aren't refs to commits. WORKING and STAGED should be checked for at a level above this. Perhaps we need a wrapper around the MergeBase logic that accepts these strings.
I have a question: does this mean I cannot get the resulting diff to include the Or perhaps this was just when computing the base and I misunderstood? |
|
|
While this fixes the examples from my previous comment, I'm still a bit skeptical of the implementation. The additional checks make the logic more complicated and the comments are misleading. For instance, calling I think there's some things we can do to clean it up. ResolveCommitSpecStrForMergeBase probably shouldn't be a public function: it should be an implementation detail in how we compute merge bases. We can deduplicate the common logic in MERGE_BASE and DOLT_DIFF into a single function, where no references to the Commit values escape this new function. The use in DOLT_LOG might be a bit trickier to remove, but is worth attempting. |
Three-dot revisions such as
DOLT_DIFF('WORKING...bar')rejected theWORKINGandSTAGEDpseudo-refs with "branch not found". They now resolve to the branchHEADcommit when computing the merge base.Fix #11204