David Whetstone on Nostr: Ever wish you could see the history for just a single #Swift function in #git? You ...
Ever wish you could see the history for just a single #Swift function in #git? You can use:
git log -L :function:file
But git doesn’t know how to find Swift functions by default. You can help it by following these instructions to add “Better diff hunk headers with Swift”:
https://juripakaste.fi/swift-git-attributes/Then the following example would show you all the changes to the login function in APIClient.swift:
git log -L :login:APIClient.swift
Published at
2023-11-26 16:34:41Event JSON
{
"id": "fa7c0ed500900c7ce82a15daf6ef881fd1eb5a883b10d628bc139d377226c7e5",
"pubkey": "9273aba62d753ffb459dc610ca6922d7351738c9f7e8aa6aef68f2d1b3b478b4",
"created_at": 1701016481,
"kind": 1,
"tags": [
[
"t",
"swift"
],
[
"t",
"git"
],
[
"proxy",
"https://mastodon.online/users/humblehacker/statuses/111477816098649226",
"activitypub"
]
],
"content": "Ever wish you could see the history for just a single #Swift function in #git? You can use:\n\ngit log -L :function:file\n\nBut git doesn’t know how to find Swift functions by default. You can help it by following these instructions to add “Better diff hunk headers with Swift”: https://juripakaste.fi/swift-git-attributes/\n\nThen the following example would show you all the changes to the login function in APIClient.swift:\n\ngit log -L :login:APIClient.swift",
"sig": "d1b39259f126fd5df864ece9e0f4ec52de90858dd29be3367a2701b81707acbcda873ae764ef15686cfd470619694ce90e2ed9faacf5da5d00f8062deca69514"
}