Every scenario is different in the fiction, so every scenario is worth talking through.
I think so, anyway, and there's an extra important point to make here.
Anyway, as per over here lemme factor out things along the standard split and see how they apply to your scenario.
But here's your important point: respect intent. Your player wanted to get past the troll and succeeded, partially, so they should be more "past the troll" than they were at the beginning, if it were at all possible. Otherwise you're just making them roll twice for the same thing.
A hard bargain means you have something to give up. Rushing a troll on a featureless empty plain doesn't have any advantages to it, necessarily, but you might make use of one if there were some advantages in the scenario, such as preparation:
You absolutely can get by that troll, Sir Justice, but unless you want to get bit you're going to have to toss one of those bottles of alchemist's fire you had ready to burn out the whole troll nest. It'll be a great distraction.
Or the element of surprise (on the dungeon scale, at least):
You skip off the ground and cave wall like a well-pitched stone, Shanksworth, but catch a glimpse of something tied to the troll's belt on your way by. It looks like a watchman's alarm horn but scaled up for the proportional lung power of a troll. Man, if they sound off on that thing this entire mountainside will know something's up. You want to keep going or see if you can lift or disable it?
Or you can create an advantage to offer:
You're not the only one who has to get by, Fletcher. You dance away from a claw-swipe, and suddenly it strikes you that it would be really easy to occupy the troll's attention, if you wanted. So here's one for you: you can get on by, or you can be a distraction while Wizzrobe and his 8 Dex get by instead.
Since "get by the troll" is a given, you can make an ugly choice out of the various prices to pay.
You bull right into the troll's chest and keep going, Fightgar, but you've underestimated the reach on those big arms. They can either take a piece out of you, or a piece out of your backpack and you'll lose a random slot of loot. Your pick.
That handful of dust looks like it does the trick, Clericsdottir, and you're scampering on by when one grasping claw swipes blindly at you. Does it grab your mace, or does it grab your shield? And either way, do you let go and keep going?
Assuming there's some other threat already out there, you can also present a choice between the two:
Yeah, the thing about lullabies, Stringfellow, is that there's really no good way to hurry them. You can see the troll relax a little bit, but you can also hear the shouts of the goblins' Super Secret Stringfellow Search and Smash Squad getting closer. So which is it: do you run while you still can and eat a drowsy claw to the face, or do you play this out and give the goblins a chance to catch up to you?
But whatever happens you've got this one. As long as there's any daylight between crushing success and abject failure, you can pick a point and run with it.
And you were right to split things up into "you get by the troll" and "the troll doesn't hurt you", but the thing is, your player already decided they wanted to get by the troll. If you're going to make a decision on their behalf, make the decision that agrees with what they were trying to do in the first place.
How much damage is up to you and the circumstances at the time. If it was a pretty narrow dodge to begin with, full damage is probably going to seem alright. If not, you can apply worst of two damage rolls or strike a glancing blow (-1d6 damage).
The only way "you don't get by the troll but it doesn't hurt you" is a worse outcome that respects the player's intent is if you think it's just straight-up impossible to get past the troll in the first place.
You thought there was a gap there, Leafwillow. You honestly did. But somehow the troll was able to close it, and as you scramble back from a stomp you can see why. The earth itself is shifting to answer this troll. Crap.
Okay, so speed isn't going to work. What else have you got?
And that's reveal an unwelcome truth pretty straight-up, but that only works if you've sunk some prep into the idea of trolls who are kin to the earth and can ask it for favors or whatever. Just stopping play to devise something to put in your players' way really isn't going to fly.