Skip to content

Commit

Permalink
Only lookup oldHash when necessary for writing to reflog
Browse files Browse the repository at this point in the history
This fixes GitUnitOfWorkTest>>testMissingRefIsCached.
  • Loading branch information
MariusDoe committed Nov 18, 2024
1 parent b444cbb commit 3d2be42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,24 @@ updateRef: refPath to: target message: reflogMessageString isSymbolic: isSymboli
"Updates the reference denoted by refPath to reference the object with the sha1 name in hexHash and adds an entry in the reflog.
Symbolic references are resolved, so the non-symbolic reference is updated.
If the file denoted by refPath does not yet exist it will be created."
| oldHash targetRef hexHash refValue updaterAndTimestamp |
| updaterAndTimestamp hexHash refValue updateReflog targetRef |
repository validateReferenceOrReferenceName: refPath.
updaterAndTimestamp := GitStamp now.
hexHash := targetIsARefBoolean ifTrue: [self resolveRef: target] ifFalse: [target asHexHash].
refValue := targetIsARefBoolean ifTrue: [self withRefPrefix: target] ifFalse: [target asHexHash].
oldHash := (self resolveRef: refPath) ifNil: [0 asHexHash].
"also update the reflogs of all symbolic references dereferenced along the way"
updateReflog := reflogMessageString
ifNil: [[:ref | ]]
ifNotNil: [ | oldHash |
oldHash := (self resolveRef: refPath) ifNil: [0 asHexHash].
[:ref | (self reflogForReference: ref)
logUpdateFrom: oldHash
to: hexHash
by: updaterAndTimestamp
message: reflogMessageString]].
[targetRef := isSymbolicBoolean
ifTrue: [
reflogMessageString ifNotNil: [
(self reflogForReference: refPath)
logUpdateFrom: oldHash
to: hexHash
by: updaterAndTimestamp
message: reflogMessageString].
refPath]
ifFalse: [
self followSymbolicRefs: refPath do: [:each |
reflogMessageString ifNotNil: [
(self reflogForReference: each)
logUpdateFrom: oldHash
to: hexHash
by: updaterAndTimestamp
message: reflogMessageString]]].
ifTrue: [updateReflog value: refPath. refPath]
ifFalse: [self followSymbolicRefs: refPath do: updateReflog].
self basicUpdateRef: targetRef to: refValue]
on: Error do:
[:e | (repository baseDir resolve: refPath) isDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"updateRef:ofRemote:to:message:" : "jr 4/5/2017 12:27",
"updateRef:to:" : "mad 6/10/2023 14:57",
"updateRef:to:message:" : "mad 6/10/2023 14:58",
"updateRef:to:message:isSymbolic:targetIsARef:" : "mad 6/9/2023 20:54",
"updateRef:to:message:isSymbolic:targetIsARef:" : "mad 11/18/2024 13:06",
"updateRef:toRef:" : "mad 6/10/2023 14:59",
"updateSymbolicRef:to:message:" : "mad 6/10/2023 15:00",
"updateSymbolicRef:to:message:targetIsARef:" : "mad 6/10/2023 14:55",
Expand Down

0 comments on commit 3d2be42

Please sign in to comment.