Minecraft wiki entry for Anvil_mechanics, associated text: The material to use is specific for each item (see the table below). For many items, this is determined by its tier or armor material.
If the stack of raw material has been renamed, its prior work penalty is paid once regardless of the number of units being used in the repair.
Due to the rapid increase in prior work penalty for each repair, it is generally most effective to use an item almost to the breaking point and then repair using four units of raw material at once (or by combining with a newly crafted instance of the item).