|
|
|
|
|
by IceMichael
909 days ago
|
|
So what is the USP of this one against the others?
I tried my simple favorite one where all of these tools fail (prompt has more details): Write a script that converts git-diff output to a file that can be easily grepped by filename and linenumber. Never works. And I point then to the errors to clarify in quite a few iterations. Will never be fixed. I did not find any tool that can do that. The answer from this tool is just the same garbage than with ChatGPT. Not better, not worse, same shit. Maybe... we don't need more of these? |
|
# Check if a git repository if [ ! -d .git ]; then echo "This directory is not a git repository." exit 1 fi
# Filename for the output output_file="git_diff_searchable.txt"
# Empty the output file or create it if it doesn't exist > "$output_file"
# Process git diff output git diff --unified=0 | while read line; do # Check for filename line if [[ $line =~ ^diff ]]; then filename=$(echo $line | sed 's/diff --git a\/\(.\) b\/./\1/') elif [[ $line =~ ^@@ ]]; then # Extract line numbers line_numbers=$(echo $line | sed -E 's/@@ -[0-9]+(,[0-9]+)? \+([0-9]+)(,[0-9]+)? @@./\2/') else # Write filename and line number to the output file echo "$filename:$line_numbers: $line" >> "$output_file" fi done
echo "Output saved to $output_file"
I then ran the following egrep [corrected to egrep, after mistakenly putting that I used gawk] command egrep -e 'agent.rs:[0-9]{1,}' git_diff_searchable.txt* to see the results. Everything worked as I expected.
Now, I don't claim that this is what you intended to achieve but I prompted it with the context of what you asked: Write a script that converts git-diff output to a file that can be easily grepped by filename and linenumber.