-
Notifications
You must be signed in to change notification settings - Fork 156
Add --no-filters option to git-add #880
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
base: master
Are you sure you want to change the base?
Add --no-filters option to git-add #880
Conversation
Welcome to GitGitGadgetHi @andrewshadura, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that your Pull Request has a good description, as it will be used as cover letter. Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):
To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
/allow |
User andrewshadura is now allowed to use GitGitGadget. WARNING: andrewshadura has no public email address set on GitHub |
bb31b25
to
0e113e9
Compare
/preview |
Preview email sent as pull.880.git.1613758137.gitgitgadget@gmail.com |
/submit |
Submitted as pull.880.git.1613758333.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
builtin/hash-object.c
Outdated
OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")), | ||
OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")), | ||
OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")), | ||
OPT_BIT(0 , "no-filters", &flags, N_("store file as is without filters"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style is:
OPT_BIT(0 , "no-filters", &flags, N_("store file as is without filters"), | |
OPT_BIT( 0 , "no-filters", &flags, N_("store file as is without filters"), |
to pad where the '
s go for short options, at least in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grepping buildins/*.c
shows that (0
is used at least 689 times, while ( 0
at most 23.
The coding guidelines don’t mention any rule mandating this space, but say: Use whitespace around operators and keywords, but not inside parentheses and not around functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I forgot to delete the other space.
0e113e9
to
4b46d2a
Compare
On the Git mailing list, "brian m. carlson" wrote (reply to this):
|
User |
On the Git mailing list, Andrej Shadura wrote (reply to this):
|
4b46d2a
to
d94b0e4
Compare
On the Git mailing list, Andrej Shadura wrote (reply to this):
|
On the Git mailing list, "brian m. carlson" wrote (reply to this):
|
d94b0e4
to
810d400
Compare
/preview |
Preview email sent as pull.880.v2.git.1613840479.gitgitgadget@gmail.com |
/submit |
Submitted as pull.880.v2.git.1613840865.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
810d400
to
2b721df
Compare
On the Git mailing list, Junio C Hamano wrote (reply to this):
|
It is possible for a user to disable attribute-based filtering when committing by doing one of the following: * Create .git/info/attributes unapplying all possible transforming attributes. * Use git hash-object and git update-index to stage files manually. Doing the former requires keeping an up-to-date list of all attributes which can transform files when committing or checking out. Doing the latter is difficult, error-prone and slow when done from scripts. Instead, similarly to git hash-object, --no-filter can be added to git add to enable temporarily disabling filtering in an easy to use way: * Add new flag ADD_CACHE_RAW to add_to_index() * Add new flag HASH_RAW to index_fd() Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
While setting path to NULL works and flips the condition in the right branch inside index_mem(), doing so isn’t obvious for the reader of the code. Since index_mem() now has an additional flag to disable filtering, use that instead. Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
2b721df
to
47207f3
Compare
It is possible for a user to disable attribute-based filtering when committing by doing one of the following:
Doing the former requires keeping an up-to-date list of all attributes which can transform files when committing or checking out.
Doing the latter is difficult, error-prone and slow when done from scripts.
Instead, similarly to git hash-object, --no-filter can be added to git add to enable temporarily disabling filtering in an easy to use way.
The use case here is mostly non-interactive use in scripts creating Git trees that need to exactly correspond to a working directory regardless of whether or not they have any .gitattributes files.
For example, for git-buildpackage or dgit, which facilitate Git workflows with Debian packages, want to ensure the contents of the
packages can be exactly reproduced, which is difficult if the upstream’s tarball has .gitattributes. It is possible to "defuse" the attributes as demonstrated above, but this will break if the user modifies the .git/i/a file or if Git adds more attribute-based conversions. This is what dgit currently does, and this is what git-buildpackage will soon do too.
Of course, this patch set only addresses staging files. While working on a patch to git-buildpackage to reproducibly import the contents of tarballs, I realised that the only realistic way seem to do that is to use hash-object + update-index manually, which is likely to come with a performance drop compared to git add (which is what gbp currently uses).
A workaround might be to use Dulwich (which would allow to do hash-object without fork/exec) or perhaps GitPython (which I haven’t really looked into), or maybe to use git fast-import, but all of these alternatives are quite complex and don’t guarantee the same performance.
Adding a new option to git add allows to keep the performance without having to ensure attributes are set to the right values. The attributes will likely have to be adjusted anyway for user’s convenience, but at least if they modify them afterwards, the tools won’t break.
These patches:
Changes since v1:
cc: "brian m. carlson" sandals@crustytoothpaste.net