Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git file-revision error #184

Open
Mctalian opened this issue Feb 7, 2025 · 0 comments
Open

Git file-revision error #184

Mctalian opened this issue Feb 7, 2025 · 0 comments

Comments

@Mctalian
Copy link

Mctalian commented Feb 7, 2025

I know that file-revision is more of a SVN paradigm, but as I was looking through the code I noticed:

si_file_timestamp=$( git -C "$_si_file_dir" log --max-count=1 --format="%at" -- "$_si_file" 2>/dev/null )
si_file_revision=$( git -C "$_si_file_dir" rev-list --count "$si_file_hash" 2>/dev/null ) # XXX checkout depth affects rev-list, see set_info_git
si_file_hash=$( git -C "$_si_file_dir" log --max-count=1 --format="%H" -- "$_si_file" 2>/dev/null )

$si_file_hash is referenced before it is set, so anyone using @file-revision@ in a git repository would actually be getting the file-revision of the file that was processed before it.

Pretty sure the fix is just swapping the lines. Happy to do that if you want!

Though in the Wiki (emphasis mine):

@file-revision@

Turns into the current revision of the file in integer form. e.g. 1234

Note: For Git, this will use the file hash.

So should the lines be swapped and si_file_revision=$si_file_hash to match what the Wiki says? Or is "this will use the file hash" truly literal in that the hash is used to determine the revision. The script has this comment instead: Turns into the commit count for the file's hash for Git.

I'm not familiar with SVN, but since the SVN logic for si_file_revision is awk'd off Last Changed Rev: - I think the file hash (the commit SHA in which the file was last changed) makes the most sense in this case.

Thanks to all the contributors who have worked on this! Super useful tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant