Did the codebreakers who broke Enigma in WWII, or higher ups in the Allied forces really get to decide basically which of their forces they would sacrifice to keep their knowledge of the German code a secret? Something I found unbelievable in The Imitation Game that they would decide on such a thing so I always wondered.
Not the codebreakers themselves, no, that scene in the Imitation Game is very much a dramatisation that, like most of the film, compresses the work of thousands of people into the handful seen on screen.
In more general terms, though, it was absolutely vital to conceal the source of Ultra intelligence (gained from Enigma and higher level coding machines). If the Germans were aware that their codes were compromised, they could have changed their procedures or machines to seriously hamper or completely prevent Allied codebreaking. If Allied convoys inexplicably changed direction to avoid U-boats, for example, or Axis convoys were unerringly targeted, it would be highly suspicious. In fact the Germans suspected intelligence leaks many times (see e.g. [ULTRA: Some Thoughts on its Impact on the Second World War] (http://www.airpower.maxwell.af.mil/airchronicles/aureview/1984/jul-aug/murray.html), Dr. Williamson Murray, that includes the text of an (ironically) intercepted message about a Mediterranean convoy: "the enemy activity today (...) lead to the conclusion that the course envisaged for convoy D and C was betrayed to the enemy"), but generally concluded that spies or traitors were responsible (within Italian High Command, in that example) rather than intercepted messages.
Dissemination of Ultra intelligence was tightly controlled through Special Liaison Units (SLUs), with as few people as possible aware of the origin of the intelligence. FW Winterbotham supervised the British distribution, and wrote one of the first books to reveal the breaking of Enigma, The Ultra Secret. In it, he says that Churchill was warned of the heavy attack on Coventry in November 1940, but deliberately took no action took to avoid arousing suspicion; this is disputed by others who were at Bletchley Park. US forces adopted the same SLU system, detailed in Synthesis of Experiences in the Use of Ultra Intelligence by U.S. Army Field Command in the European Theater of Operations. This mentions that a key use of Ultra was to allow the selection of correct information from a mass of other, sometimes contradictory, sources (prisoners of war, agents, reconnaissance and photographic reports), thus not revealing Ultra. Where corroborative sources were not available they could be manufactured, for example after decoding a signal indicating a strong concentration of vehicles near Marburg, rather than immediately attacking, a "routine" reconnaissance aircraft was despatched, followed by fighter-bombers once the pilot confirmed the presence of vehicles.