Reputation: 3397
I'm currently developing a Visual Studio extension. For a new feature I need to find out whether a given ProjectItem (file) was modified (has "Pending Changes" since the last commit). For this I would like to query the source control provider.
I can't seem to find anything online about this topic. How can I find out the modified state? Is it even possible?
Upvotes: 1
Views: 209
Reputation: 3397
After letting this topic sit for some time I recently came back to it and found the solution thanks to the help of my collegue. The problem was that I had no experience in bitwise comparison so I didn't know how to handle the response properly. Luckily my collegue gave me the right tip.
To interpret the result of status (thanks to @simon-mourier for the help on this code):
uint[] sccStatus = new uint[] { 0 };
if (VSConstants.S_OK == manager.GetSccGlyph(1, new[] { filePath }, new[] { VsStateIcon.STATEICON_NOSTATEICON }, sccStatus))
{
__SccStatus status = (__SccStatus)sccStatus[0];
}
One has to do bitwise comparison with the state of __SccStatus
you are looking for, for example:
if ((sccStatus[0] & (uint)__SccStatus.SCC_STATUS_RESERVED_2) != 0)
return true;
The comparison returns true
in case the state is set. If you need help on what specific state combinations can mean, just comment here and I can help on that.
Upvotes: 2