This is an archive of the discontinued LLVM Phabricator instance.

Make git ignore core files
AbandonedPublic

Authored by aidengrossman on Mar 25 2023, 10:42 AM.

Details

Summary

I have accidentally committed a core file once
(https://github.com/llvm/llvm-project/commit/af73834243a1035787935960bfd5a71713b89701)
due to not paying close enough attention to commit diffs and my CWD.
This patch adds rule in .gitignore to ignore core files so that the same
mistake is less likely to happen again.`

Diff Detail

Event Timeline

aidengrossman created this revision.Mar 25 2023, 10:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2023, 10:42 AM
aidengrossman requested review of this revision.Mar 25 2023, 10:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2023, 10:42 AM
JDevlieghere accepted this revision.Mar 27 2023, 6:22 PM
JDevlieghere added inline comments.
.gitignore
26

Should this be just core (i.e. without the *)? At least on Linux core is the default core file name, right? An on macOS they're off by default and end up under /cores anyway.

We have a few core files checked in as part of the LLDB test suite but they usually have a descriptive name, such as subject.core that would get matched with the current pattern.

This revision is now accepted and ready to land.Mar 27 2023, 6:22 PM
JDevlieghere requested changes to this revision.Mar 27 2023, 6:22 PM

Oops, meant to request changes rather than accept this.

This revision now requires changes to proceed.Mar 27 2023, 6:22 PM

IMHO .gitignore is for files that are strictly project-related. Everything else should go into local .git/info/exclude.

I have accidentally committed a core file once

You might as well have committed any arbitrary file, e.g. 1.txt. This does not mean '*.txt' should end up in .gitignore.
It is the committers responsibility to check that everything is OK, and there is also a review process.

aidengrossman updated this revision to Diff 509240.EditedMar 29 2023, 12:58 AM

Address reviewer feedback.

IMHO .gitignore is for files that are strictly project-related. Everything else should go into local .git/info/exclude.

For the most part, I agree. However, there are already some artifacts that might not be classified as strictly project related that are in the .gitignore. We have exceptions for things like artifacts produced by IDEs (VSCode, VS), tools like clangd, vim swap files, etc. I think it's sort of an arbitrary boundary on what we consider project related and what we don't. I thought this would be something reasonable to add, but I'm happy to hear feedback from the community and augment/abandon these if the consensus is against this.

You might as well have committed any arbitrary file, e.g. 1.txt. This does not mean '*.txt' should end up in .gitignore.
It is the committers responsibility to check that everything is OK, and there is also a review process.

Right, it could've been any arbitrary file. I have been making sure to check my commits more carefully as well. However, I think core files are slightly different. With Linux development, I think there's a reasonable expectation they'll pop up at some point in places they're not supposed to, they're large in size which impacts repository size when they end up in tree, and if there's just a file named core, it's almost certainly a core dump and not meant to end up in tree. I also don't think there's a large cost to adding it to the .gitignore as long as it doesn't create any off-target effects.

.gitignore
26

Good point. The default file name on Linux is just core. My original thinking was that this would still catch things if the default file name is modified (ie if a timestamp/PID/executable name gets appended which I think is a reasonably common configuration), but this definitely does increase the chance for offtarget effects.

I've changed it to match a file called core in any directory. I checked with git check-ignore across the whole monorepo and there were no off-target matches, and I think this should be reasonable, but I'd like your thoughts on this (e.g., if we want to restrict it further, maybe even to just the root directory).

MaskRay requested changes to this revision.Mar 29 2023, 8:44 PM

IMHO .gitignore is for files that are strictly project-related. Everything else should go into local .git/info/exclude.

I agree. core looks too special to ignore in the global configuration file.

I have accidentally committed a core file once

You might as well have committed any arbitrary file, e.g. 1.txt. This does not mean '*.txt' should end up in .gitignore.
It is the committers responsibility to check that everything is OK, and there is also a review process.

This revision now requires changes to proceed.Mar 29 2023, 8:44 PM
aidengrossman abandoned this revision.Mar 29 2023, 9:04 PM

I'll abandon this patch now based on feedback. Thank you everyone for the responses and your time in explaining the costs to such a change that I didn't realize. Sorry for taking up your time.