The law of poreitz geder (breeching a fence)
The rabbis were ingenious in creating new laws and basing the novelty on some word or words in the Bible and hanging their creation on the biblical words by a very thin and fragile often invisible thread.
The Jerusalem Talmud Sanhedrin 2:5 derives the law of poreitz geder, that permission is given to kings to drive their cattle through the property of citizens without asking permission from I Samuel 30:20, not from the Five Books of Moses. “David took all the flocks and herds [that his band took as booty, and] drove them before the other cattle [the cattle snatched by the Amalekites from David’s camp that he saved when he fought the Amalekites], and they [David’s troop] said: ‘This is David’s spoil [meaning he can do what he wills with the cattle].’”
This verse served as the basis for the new law despite there being no mention of a gate, nor driving of cattle through land belonging to others, David was not a king at the time, no mention is made that David did not ask permission to move his cattle, and as seen in the final verses in the chapter David wanted to give the cattle to various people to ingratiate himself with the Judeans so that they would make him their king, and he certainly would not have driven cattle at this time on another’s property without permission and make the owner angry.