As early as the end of the last century, the Hague Convention of 1899 established certain rules regulating the rights and responsibilities of belligerents in regard to prisoners of war. In pursuance of the provisions of the 1899 Convention, a number of States drew up the necessary instructions concerning the treatment of prisoners of war. A State may do everything necessary for the holding of prisoners, but nothing more. In any case, such work must not be detrimental to health and must not be of a humiliating nature. It must not contribute directly to military operations against the native country of the prisoners.
Prisoners of war lose their freedom but retain their rights.
In other words, military confinement is not an act of mercy on the part of the captor, but the right of disarmed persons. It may surprise you to learn that the instructions cited are those issued by the German General Staff in Volume 18 of the circular published in 1902 by the German General Staff. The principle of humane treatment of prisoners and wounded Servicemen was further developed in the Hague Convention of 1907 and the Geneva Convention of 1929. Germany's adherence to these conventions was definitely reflected in the German law regarding wartime courts martial. That was at a time when Hitlerite Germany had already begun the execution of her aggressive plans.