Git smudge run once per checkout or per commit?

49 Views Asked by At

I am trying to have duplicate repository of my source but duplicate has certain modifications that the source repo won't have. I make these modifications using clean/smudge filters. I want my smudge filter to run once per commit, i.e. if a pull contains four commits then I want the smudge filter to run four times (per commit being pulled/checkedout). This smudge filter currently runs only once per pull even if the pull contains multiple commits.

I want certain information about the commits written to a log file. My current smudge filter script looks like this:

full_commit=$(git log -1 --pretty=format:"%an|<%ae>|%ad|%H%n%B") # %n for new-line
commit_info=$(echo "$full_commit" | head -1)
commit_msg=$(echo "$full_commit" | tail -n +2)
IFS=$'|' read -r name mail dt hash <<< "$(echo $commit_info)" # get everything separated out

echo commit hash: $hash >> smudge-file.messages
echo commit author-name: $name, author-mail: $mail, commit-datetime: "$dt" >> smudge-file.messages
echo commit message: "$commit_msg" >> smudge-file.messages
echo "" >> smudge-file.messages
cat

Here I assume that as the smudge would run once per commit being pulled hence the git log -1 will output the current commit's details which I append to a log file. It makes sense that the smudge filter should run once per commit being pulled but this doesn't seem to be the case in reality as only the most recent commit information is being written to my log file.

Any help to make the smudge run per commit being checkedout or similar is appreciated.

0

There are 0 best solutions below