Thread: Ignore Visual Studio's Temp Files While Working with PG on Windows

Hi Hackers, 

I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files. 

Looking forward to the PG guru's guidance! 

Regards...

Yasir Hussain
Principal Software Engineer
Bitnine Global Inc.

Attachment

Re: Ignore Visual Studio's Temp Files While Working with PG on Windows

From
Peter Eisentraut
Date:
On 17.05.24 08:09, Yasir wrote:
> I have been playing with PG on the Windows platform recently. An 
> annoying thing I faced is that a lot of Visual Studio's temp files kept 
> appearing in git changed files. Therefore, I am submitting this very 
> trivial patch to ignore these temp files.

Our general recommendation is that you put such things into your 
personal global git ignore file.

For example, I have in ~/.gitconfig

[core]
         excludesFile = ~/.gitexcludes

and then in ~/.gitexcludes I have various ignores that are specific to 
my local tooling.

That way we don't have to maintain ignore lists for all the tools in the 
world in the PostgreSQL source tree.




Nice approach! Thankyou Peter for the guidance. 

Regards...

Yasir

On Fri, May 17, 2024 at 11:34 AM Peter Eisentraut <peter@eisentraut.org> wrote:
On 17.05.24 08:09, Yasir wrote:
> I have been playing with PG on the Windows platform recently. An
> annoying thing I faced is that a lot of Visual Studio's temp files kept
> appearing in git changed files. Therefore, I am submitting this very
> trivial patch to ignore these temp files.

Our general recommendation is that you put such things into your
personal global git ignore file.

For example, I have in ~/.gitconfig

[core]
         excludesFile = ~/.gitexcludes

and then in ~/.gitexcludes I have various ignores that are specific to
my local tooling.

That way we don't have to maintain ignore lists for all the tools in the
world in the PostgreSQL source tree.

On 2024-05-17 Fr 02:34, Peter Eisentraut wrote:
> On 17.05.24 08:09, Yasir wrote:
>> I have been playing with PG on the Windows platform recently. An 
>> annoying thing I faced is that a lot of Visual Studio's temp files 
>> kept appearing in git changed files. Therefore, I am submitting this 
>> very trivial patch to ignore these temp files.
>
> Our general recommendation is that you put such things into your 
> personal global git ignore file.
>
> For example, I have in ~/.gitconfig
>
> [core]
>         excludesFile = ~/.gitexcludes
>
> and then in ~/.gitexcludes I have various ignores that are specific to 
> my local tooling.
>
> That way we don't have to maintain ignore lists for all the tools in 
> the world in the PostgreSQL source tree.
>
>
>

or if you want something repo-specific, you can add entries to 
.git/info/exclude


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual
Studio'stemp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore
thesetemp files. 

see
https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies

Anyway if those are not files specific to your setup (like editor
ones), but files which every PG hacker on Windows will generate as
well (which is this case IMHO), it will make sense to add it into
project's gitignore.

> Looking forward to the PG guru's guidance!
>
> Regards...
>
> Yasir Hussain
> Principal Software Engineer
> Bitnine Global Inc.
>





On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies

Anyway if those are not files specific to your setup (like editor
ones), but files which every PG hacker on Windows will generate as
well (which is this case IMHO), it will make sense to add it into
project's gitignore.
 
.vs directory and temp files within it are created once you open any of the .sln, .vcproj or .vcxproj files (created with build command when PWD is postgres/src/tools/msvc) in visual studio. It's a common practice that developers use visual studio on codebase as it's mostly the default c/c++ files/projects editor. 
So, it would be a common case for most of the developers with Windows platform to add it in project's .gitignore. 


> Looking forward to the PG guru's guidance!
>
> Regards...
>
> Yasir Hussain
> Principal Software Engineer
> Bitnine Global Inc.
>


On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies


We can add it to "~/.config/git/ignore" as it will ignore globally on windows which we don't want. Also we don't have ".git/info/exclude" in PG project's so the best place left is projects's .gitignore. That's what was patched. 
 
Anyway if those are not files specific to your setup (like editor
ones), but files which every PG hacker on Windows will generate as
well (which is this case IMHO), it will make sense to add it into
project's gitignore.

> Looking forward to the PG guru's guidance!
>
> Regards...
>
> Yasir Hussain
> Principal Software Engineer
> Bitnine Global Inc.
>
Yasir <yasir.hussain.shah@gmail.com> writes:
> We can add it to "~/.config/git/ignore" as it will ignore globally on
> windows which we don't want. Also we don't have ".git/info/exclude" in PG
> project's so the best place left is projects's .gitignore. That's what was
> patched.

As Peter said, we're not going to do that.  The intention with
the project's .gitignore files is to ignore files that are
intentionally built by our "make" targets (and, hopefully, will be
removed by "make maintainer-clean").  Anything else that you want
git to ignore should be in a personal ignore list; especially
files that are platform-specific.  The fact that it's reasonable
to ignore ".vs" files when working with your toolset doesn't mean
that it's reasonable to ignore them when working on some other
platform.

If we used some other policy, we'd have tons of debates about
which files were reasonable to exclude.  For myself, for example,
I exclude "*~" (Emacs backup files) and "*.orig" (patch(1)
backup files) but those choices are very much dependent on the
set of tools I choose to use.  Other developers have other
personal exclusion lists.  If we tried to make the project's
files be the union of all those lists, we'd be at serious risk
of ignoring stuff we absolutely shouldn't ignore in some contexts.

            regards, tom lane



so 18. 5. 2024 v 22:36 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>
> Yasir <yasir.hussain.shah@gmail.com> writes:
> > We can add it to "~/.config/git/ignore" as it will ignore globally on
> > windows which we don't want. Also we don't have ".git/info/exclude" in PG
> > project's so the best place left is projects's .gitignore. That's what was
> > patched.
>
> As Peter said, we're not going to do that.  The intention with
> the project's .gitignore files is to ignore files that are
> intentionally built by our "make" targets (and, hopefully, will be
> removed by "make maintainer-clean").  Anything else that you want
> git to ignore should be in a personal ignore list; especially
> files that are platform-specific.  The fact that it's reasonable
> to ignore ".vs" files when working with your toolset doesn't mean
> that it's reasonable to ignore them when working on some other
> platform.
>
> If we used some other policy, we'd have tons of debates about
> which files were reasonable to exclude.  For myself, for example,
> I exclude "*~" (Emacs backup files) and "*.orig" (patch(1)
> backup files) but those choices are very much dependent on the
> set of tools I choose to use.  Other developers have other
> personal exclusion lists.  If we tried to make the project's
> files be the union of all those lists, we'd be at serious risk
> of ignoring stuff we absolutely shouldn't ignore in some contexts.

But this is different. If I understand it well, just by following
https://www.postgresql.org/docs/16/install-windows-full.html you'll
get those files no matter what is your specific environment (or
specific set of tools).

>                         regards, tom lane




On 2024-05-18 Sa 15:43, Yasir wrote:


On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies


We can add it to "~/.config/git/ignore" as it will ignore globally on windows which we don't want. Also we don't have ".git/info/exclude" in PG project's so the best place left is projects's .gitignore. That's what was patched. 
 



eh? git creates .git/info/exclude in every git repository AFAIK. And it's referred to here: <https://git-scm.com/docs/gitignore>


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com


On Sun, May 19, 2024 at 1:45 AM Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-05-18 Sa 15:43, Yasir wrote:


On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies


We can add it to "~/.config/git/ignore" as it will ignore globally on windows which we don't want. Also we don't have ".git/info/exclude" in PG project's so the best place left is projects's .gitignore. That's what was patched. 
 



eh? git creates .git/info/exclude in every git repository AFAIK. And it's referred to here: <https://git-scm.com/docs/gitignore>


Yes, git creates .git/info/exclude but point is, it is not in PG maintained codebase repo. So, no point adding to it. 

BTW, Tom and Peter said it's not going to be added anyway!
 

cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
=?UTF-8?B?Sm9zZWYgxaBpbcOhbmVr?= <josef.simanek@gmail.com> writes:
> But this is different. If I understand it well, just by following
> https://www.postgresql.org/docs/16/install-windows-full.html you'll
> get those files no matter what is your specific environment (or
> specific set of tools).

Hm?  Visual Studio seems like quite a specific tool from here.

I did some googling around the question of project .gitignore
files ignoring .vs/, and was amused to come across this:

https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

which seems like a mighty fine example of where we *don't*
want to go.

            regards, tom lane



so 18. 5. 2024 v 23:16 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>
> =?UTF-8?B?Sm9zZWYgxaBpbcOhbmVr?= <josef.simanek@gmail.com> writes:
> > But this is different. If I understand it well, just by following
> > https://www.postgresql.org/docs/16/install-windows-full.html you'll
> > get those files no matter what is your specific environment (or
> > specific set of tools).
>
> Hm?  Visual Studio seems like quite a specific tool from here.

I initially thought the .vs folder is created just by compiling
PostgreSQL using build.bat (like without opening Visual Studio at
all). But I'm not 100% sure, I'll take a look and report back.

> I did some googling around the question of project .gitignore
> files ignoring .vs/, and was amused to come across this:
>
> https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
>
> which seems like a mighty fine example of where we *don't*
> want to go.

That's clearly a nightmare to maintain. But in this case it should be
all hidden within one .vs folder.

>                         regards, tom lane





On Sun, May 19, 2024 at 2:16 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Josef Šimánek <josef.simanek@gmail.com> writes:
> But this is different. If I understand it well, just by following
> https://www.postgresql.org/docs/16/install-windows-full.html you'll
> get those files no matter what is your specific environment (or
> specific set of tools).

Hm?  Visual Studio seems like quite a specific tool from here.

I did some googling around the question of project .gitignore
files ignoring .vs/, and was amused to come across this:

https://github.com/github/gitignore/blob/main/VisualStudio.gitignore


This is funny Tom. Adding an entry for each type of temp file in .gitignore is a childish thing, obviously.  

which seems like a mighty fine example of where we *don't*
want to go.

I agree we don't want to go in this direction.
 

                        regards, tom lane


On Sun, May 19, 2024 at 2:23 AM Josef Šimánek <josef.simanek@gmail.com> wrote:
so 18. 5. 2024 v 23:16 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>
> Josef Šimánek <josef.simanek@gmail.com> writes:
> > But this is different. If I understand it well, just by following
> > https://www.postgresql.org/docs/16/install-windows-full.html you'll
> > get those files no matter what is your specific environment (or
> > specific set of tools).
>
> Hm?  Visual Studio seems like quite a specific tool from here.

I initially thought the .vs folder is created just by compiling
PostgreSQL using build.bat (like without opening Visual Studio at
all). But I'm not 100% sure, I'll take a look and report back.

.vs folder is not created just by compiling PG. It is created if you open any of .sln, .vcproj or .vcxproj files. 
I have verified it. 
 

> I did some googling around the question of project .gitignore
> files ignoring .vs/, and was amused to come across this:
>
> https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
>
> which seems like a mighty fine example of where we *don't*
> want to go.

That's clearly a nightmare to maintain. But in this case it should be
all hidden within one .vs folder.

>                         regards, tom lane
so 18. 5. 2024 v 23:29 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
>
>
> On Sun, May 19, 2024 at 2:23 AM Josef Šimánek <josef.simanek@gmail.com> wrote:
>>
>> so 18. 5. 2024 v 23:16 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>> >
>> > =?UTF-8?B?Sm9zZWYgxaBpbcOhbmVr?= <josef.simanek@gmail.com> writes:
>> > > But this is different. If I understand it well, just by following
>> > > https://www.postgresql.org/docs/16/install-windows-full.html you'll
>> > > get those files no matter what is your specific environment (or
>> > > specific set of tools).
>> >
>> > Hm?  Visual Studio seems like quite a specific tool from here.
>>
>> I initially thought the .vs folder is created just by compiling
>> PostgreSQL using build.bat (like without opening Visual Studio at
>> all). But I'm not 100% sure, I'll take a look and report back.
>
>
> .vs folder is not created just by compiling PG. It is created if you open any of .sln, .vcproj or .vcxproj files.
> I have verified it.

Yes, I can confirm. Just running build.bat doesn't create .vs. I'm
sorry for confusion and I do agree ignoring ".vs" directory is a local
environment thing and doesn't belong to Postgres .gitignore.

>>
>>
>> > I did some googling around the question of project .gitignore
>> > files ignoring .vs/, and was amused to come across this:
>> >
>> > https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
>> >
>> > which seems like a mighty fine example of where we *don't*
>> > want to go.
>>
>> That's clearly a nightmare to maintain. But in this case it should be
>> all hidden within one .vs folder.
>>
>> >                         regards, tom lane




On 2024-05-18 Sa 16:54, Yasir wrote:


On Sun, May 19, 2024 at 1:45 AM Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-05-18 Sa 15:43, Yasir wrote:


On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies


We can add it to "~/.config/git/ignore" as it will ignore globally on windows which we don't want. Also we don't have ".git/info/exclude" in PG project's so the best place left is projects's .gitignore. That's what was patched. 
 



eh? git creates .git/info/exclude in every git repository AFAIK. And it's referred to here: <https://git-scm.com/docs/gitignore>


Yes, git creates .git/info/exclude but point is, it is not in PG maintained codebase repo. So, no point adding to it. 

BTW, Tom and Peter said it's not going to be added anyway!
 



You've completely missed my point, which is that *you* should be adding it to that file, as an alternative to using a (locally) global gitignore file.

I agree with Tom and Peter.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com


On Sun, May 19, 2024 at 2:35 AM Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-05-18 Sa 16:54, Yasir wrote:


On Sun, May 19, 2024 at 1:45 AM Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-05-18 Sa 15:43, Yasir wrote:


On Sat, May 18, 2024 at 7:27 PM Josef Šimánek <josef.simanek@gmail.com> wrote:
pá 17. 5. 2024 v 8:09 odesílatel Yasir <yasir.hussain.shah@gmail.com> napsal:
>
> Hi Hackers,
>
> I have been playing with PG on the Windows platform recently. An annoying thing I faced is that a lot of Visual Studio's temp files kept appearing in git changed files. Therefore, I am submitting this very trivial patch to ignore these temp files.

see https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
for various strategies


We can add it to "~/.config/git/ignore" as it will ignore globally on windows which we don't want. Also we don't have ".git/info/exclude" in PG project's so the best place left is projects's .gitignore. That's what was patched. 
 



eh? git creates .git/info/exclude in every git repository AFAIK. And it's referred to here: <https://git-scm.com/docs/gitignore>


Yes, git creates .git/info/exclude but point is, it is not in PG maintained codebase repo. So, no point adding to it. 

BTW, Tom and Peter said it's not going to be added anyway!
 



You've completely missed my point, which is that *you* should be adding it to that file, as an alternative to using a (locally) global gitignore file.

My bad Andrew.  

I agree with Tom and Peter.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com