I guess my actions would depend on the severity and speed of the other dog and how much time I have to react...
If I saw the loose dog from say, a block away, then I would stand still, calm, and as it approached I would in a deep commanding voice say GIT!
If the dog came up unexpectedly and a lot closer, I would move forward towards it and say GIT!
And last, if the dog was already engaging my dog - I would allow my dog to finish it.
We have LOTS of loose dogs out here in rural TN, unfortunately. People seem to think 'country' equals no rules for pets. But we still have leash laws in our county. And NO ANIMAL CONTROL.
I have been growled at by an agressive neighbor's dog. It's a large fluffy mix (think great pyrenees x something) around 80+ pounds. It somehow got through my fence and snuck up behind me while I was weedeating - I turned around to find this large dog growling at me, walking towards me stifflegged. I whipped the weedeater towards it and revved it up. It ran off. A few days later, it was on my farm again chasing my livestock - so I shot it.
The same neighbor who owned that dog at one time had 20 dogs total (living in cages). All are medium to large, they used to run loose as a pack. The pack chases deer, kills cats, chases horses/sheep/goats. I now carry my derringer or .45 when I am mowing or doing chores. There are only 7 dogs left. I am not the only person who has had to put down one of these agressive dogs. I don't like it, but even the cops told me to shoot them.
----------------------------------------------------------------------------------------
When Hagrid was a puppy, he was out with me while I was sweeping the barn. He never wandered far. But one of those dogs had gotten into my barn and was growling/barking agressively at the two of us. It would not go away even when I yelled at it. So, I picked up the nearest thing (which happened to be a hammer) and flung it at the dog. I missed, but the dog ran away scared. I did not have my gun on me that time.