San Francisco police gave a judge numerous indications that a man who obtained a confidential police report on the death of Public Defender Jeff Adachi was a journalist when they applied for a search warrant to unmask his source, court records released Tuesday show.

But the warrant’s affidavit shows that San Francisco Superior Court Judge Victor Hwang nevertheless cleared police to raid Bryan Carmody’s office on May 10, despite California’s Shield Law, which protects journalists from being compelled to reveal confidential sources and unpublished material like notes and photographs. The law applies to freelancers and specifically bars police searches.

Sgt. Joseph Obidi wrote in the probable cause statement that Carmody said he “profits financially from every story that he covers,” and that Carmody “makes a career out of producing/selling hot news stories.” Obidi also referenced a memo by the San Francisco public defender’s office that identified Carmody as a “stringer,” which is an industry term for a freelance videographer who sells video footage to television news stations.

“This affidavit shows a wholesale failure by the San Francisco political establishment, the Police Department and the judiciary to recognize and protect the constitutional rights of Bryan Carmody, and by extension, all journalists,” said David Snyder, executive director of the First Amendment Coalition, which fought to have the records released. “The Police Department gave Judge Hwang ample evidence that Carmody is a journalist and that the material they wanted was his confidential sources.”

A spokesman for the courts said Hwang cannot comment beyond what he’s said in court.

The raid on Carmody’s home and office became a national controversy over possible First Amendment violations as police scrambled to identify the report’s leaker amid pressure from city officials. Many in City Hall believed the leak was an attempt to smear Adachi, who was an outspoken police critic. The report revealed that Adachi died in a mysterious apartment with a woman who was not his wife.

The warrant signed by Hwang, which police obtained after raiding Carmody’s home with a sledgehammer earlier in the day, shows for the first time that police were investigating two officers as the source of the leaked Adachi report. Carmody later sold the report to three television news stations.

Investigators in the department’s Internal Affairs Bureau obtained surveillance video showing an officer enter Central Police Station and then leave half an hour after communicating on the phone with Carmody, according to the affidavit. The officer, Obidi said, was not on assignment and didn’t respond to any calls near the station.

Obidi wrote he believed the officer’s “visit to Central Police Station was for the purpose of accessing the death investigation report.”

Hwang redacted the name of the officer. Chief Bill Scott said he wants to turn over the criminal investigation to an outside agency. But none of the evidence obtained in searches of Carmody’s property can legally be used by any new investigators because the warrants have been quashed. No outside agency has stepped up to take over the investigation.

Scott defended the raid for two weeks, but amid mounting criticism he changed course, apologizing and conceding the raid was wrong. He said he did so because he was “concerned by a lack of due diligence by department investigators in seeking search warrants.”

But the affidavit released Tuesday shows that the chief’s spokesman, David Stevenson, originally told investigators that Carmody sold the report to television stations. Obidi’s attorney said Stevenson never told investigators that Carmody had a department-issued press pass.

The Police Department had asked another judge to redact a portion of the warrant that mentioned the chief’s involvement in the investigation. The Chronicle last week obtained that redacted paragraph. Hwang did not redact the same passage.

The Chronicle also learned that Scott changed course after City Attorney Dennis Herrera told the chief he could not defend the raid, according to several sources with knowledge of the discussion. The sources spoke on the condition of anonymity because they were not authorized to speak publicly.

The Police Department did not respond to a request for comment.

In unsealing and quashing the May 10 warrant last week, Hwang joined three other Superior Court judges in conceding that Carmody was a journalist protected by the state’s shield law. Judges Gail Dekreon, Christopher Hite, Rochelle East and Hwang all said they were unaware Carmody had a press pass.

Investigators didn’t include that Carmody had a press pass in any of the warrants. In the warrants signed by East and Hite, police only identified him as a “Freelance Videographer/Communications manager, USO Bay Area.” The warrant Dekreon signed, which cleared police to search Carmody’s home, has not yet been released.

First Amendment advocates said that even though the warrant didn’t mention the press pass, the descriptions in the affidavit Hwang signed should have alerted the judge that Carmody was a journalist.

“This really brings full circle the failings at multiple junctures,” Snyder said. “It’s not just one rogue sergeant seeking a warrant that the SFPD wasn’t entitled to. It was multiple gates that this passed through, and San Francisco failed to protect a journalist at all of those gates.”

Carmody’s attorney, Ben Berkowitz, on Tuesday said he was “gratified” the judges quashed the “illegal search warrants.”

“It’s now clear from the unsealed warrant applications that the SFPD knew Bryan was a journalist when they sought these illegal warrants,” he said in a statement. “We continue to call on Mayor (London) Breed, the Board of Supervisors and Police Chief Scott to make real reforms. It should never be the case that law enforcement intentionally violates the protections of the First Amendment and California’s Shield Law to spy on a journalist.”

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: esernoffsky@sfchronicle.com Twitter: @EvanSernoffsky