While Congress has been fashioning legislation to deregulate trucking, a bruising fight on the sidelines has been waged by two powerful wings of the food industry: the manufacturers and the distributors.

At issue is an old averaging rule under which every wholesaler customer pays a manufacturer the same price for the same quantity of groceries in the same geographic delivery zone, no matter the distance between the seller's loading dock and the buyer's warehouse.

The rule makes some people happy because when trucking costs are the same for all, they cannot become a weapon in price competition among wholesalers and retailers. But it makes others unhappy because large buyers, particularly supermarket chains that want to use their own truck fleets, can't get discounts related to the distances between the docks and their warehouses.

The chains, with help from the resourceful Sen. Russell B. Long (D-La.), want to change the rule so they get the discounts. They say they could save their customers money that way.

But critics say the chains could use their advantages to squeeze out smaller competitors, then squeeze the manufacturers as well by denying them shelf space. They see the amendment as a power play.

In a worst-case scenario, critics say, a chain with a warehouse 50 miles from a dock and a wholesaler with a warehouse 10 miles away send trucks to pick up some coffee. On the way back from the dock, the chain's truck drops a box off at one of its stores. Down the block is an independent store that gets a box of the same coffee from the wholesaler. But he independent must pay more for its coffee because its supplier's warehouse is closer to the dock than the chain's, and so the wholesaler's discount is smaller, than the chain's.

Possibilities like this have incited opposition to the Long amendment from the Consumer Federation of America and the Federal Trade Commission, which has said since 1967 that rebates for buyers in the same zone must be identical to avoid potential violations of the Robinson-Patman Act, an antitrust law intended to protect small businessmen from illegal price discrimination.

Normally, the Grocery Manufacturers of America and the other food industry trade associations of chains (which include many huge private-label manufacturers), wholesalers and retailers are as close on legislative and regulatory issues as peas in a Washington pod.

But while the GMA is leading the fight against the amendment, the Food Marketing Institute and the other associations are carrying the banner for it.

It's a battle between giants.

The GMA has a $3 million budget, the FMI an $8 million one. The GMA's top 20 members had 1979 sales of $83.8 billion, the FMI's $64.2 bilion.

The key argument made for the amendment is efficiency: trucks otherwise traveling empty after unloading at stores could return full, reducing fuel costs.

The counterargument is that other trucks, now traveling full, would have to travel empty. And FTC Chairman Michael Pertschuk wonders how sellers would determine "actual" delivery costs and how his agency could monitor many thousands of discounts based on these costs.

Both sides claim to be working for grocery shoppers. The advocates contend that fuel savings would translate into lower prices at the check-out counters.

Taking the advocates literally, Rep. Elliott M. Levitas (D-Ga.) proposed a surprise modification of the amendment, saying it is "the sense of Congress that any savings . . . should be passed on to the ultimate consumer."

The House Public Works and Transportation Committee wrote the modification into the House deregulation bill, but only after Rep. E. G. (Bud) Shuster (R-Pa.) protested that a business ought to be allowed "to retain and invest" the savings.

The amendment has clear potential advantages for chains and large wholesalers. Yet it's also wanted by every association of the supposed potential victims -- the smaller distributors and retailers. Indeed, the sole identified opponent among their tens of thousands of members is Albert N. Solomon of Atlanta, operator of So-Lo Foods, an independent supermarket with 1979 sales of $3.5 million.

Solomon, without supporting evidence, claims that many small retailers are "afraid" to speak out or are uninformed or misinformed about the amendment.

The proposal originally was offered as an amendment to an energy bill but got nowhere. Then, Long told a reporter, he decided to sponsor it. In the process, he met last September with 14 grocery industry representatives, including 10 based, or doing business in Louisiana.

One member of the delegation was a vice president of Winn-Dixie Stores, the fifth-largest grocery chain. After the meeting, the firm's political action committee, four of its top officiers and wo of the officier's wives contributed $9,000 to Long's reelection campaign. Was there a connection? None whatsoever," Long said.

With Long's backing, the Senate Commerce and Transportation Committee approved the amendment without objection or a hearing. On the Senate floor, no one spoke against it. in the House, however, the GMA has been fighting hard to stop it.

The battle began to turn bitter last March 26, when Safeway Stores chairman Peter A. Magowan, in a letter to GMA's member's, appealed for their "help in convincing GMA that their position is counterproductive to the entire industry."

Counterattacking the next day, GMA president George W. Koch asked GMA members to tell members of Congress that they oppose the amendment. But without explanation, Koch reversed himself a week later.

Koch declined to comment to a reporter. Some sources claimed that the Magowan letter made some GMA members fearful, and that Koch decided to take them off the hook and have GMA fight the battle alone.

A GMA spokesman told a reporter that its members are undivided in their opposition to the amendment. But in April, Thomas W. Wyman, then a member of the GMA board and vice chairman of the Pillsbury Co., wrote Safeway's Magowan that his company's position "does not coincide with GMA's" and that he will continue to try to end GMA's opposition.

The National Small Business Association and 39 allied groups oppose the amendment, saying that it would become a precedent for other industries and could sound the death knell of the Robinson-Patman law's protection of small business. Yet, NSBA president Herbert Liebenson admits, not one organization of small businessmen in the grocery business has come to his support.