Use PowerShell to check an xml file in the Git staging area

I'm using Git with an ASP.Net web site with passwords stored in the web.config file. To keep those from getting committed, I set up configuration section encryption, so the connectionStrings section of the file is encrypted -- unless I decrypt it to fool around with it.

Then to prevent accidentally committing it un-encrypted, I wrote a little PowerShell script that my local pre-commit hook invokes:

# Verifies that web.config's connectionStrings is encrypted.

[xml]$config = get-content .\Code\SlicerWeb\web.config
if ($config.configuration.connectionStrings.EncryptedData) {
    exit 0
else {
    Write-Output "connectionStrings section is not encrypted."
    exit 1

And this works fine, and is probably good enough. But now I realize that what I really should do is check the contents of the file in the index (staging area), rather than the current file on disk.

How can I do a get-content of a file as it exists in the index?


You can use the : prefix to access objects in the current index. So this should work

[xml]$config = git show :./Code/SlicerWeb/web.config

(Backslashes in the path does not work here)

Need Your Help

Binding NSTextField's Enabled property to a BOOL property

objective-c cocoa binding nstextfield

I am a Mac dev newbie. I have a dialog with some set of controls. The controls needs to be enabled/disabled based on a radio selection. The way I did it is by creating IBOutlet variables for each of

google prettify: ada syntax

ada google-code-prettify

I am currently trying to highlight Ada code on my website using google prettify and a file I have found here.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.