One secret of Stonewall Jackson's success was that he was such a strict disciplinarian. He did his duty himself and was ever at his post, and he expected and demanded of everybody to do the same thing. He would have a man shot at the drop of a hat, and drop it himself. The first army order that was ever read to us after being attached to his corps, was the shooting to death by musketry of two men who had stopped on the battlefield to carry off a wounded comrade. It was read to us in line of battle at Winchester.
Jackson was always ready to ride a horse where his men walked, I will give him that.
Longstreet was also shot by his own men.
This book points out that Lee put sharp shooter companies behind each brigade not just to shoot deserters, but also to shoot stragglers.