From: Christian Couder <christian.couder@gmail.com>
To: John Cai via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, John Cai <johncai86@gmail.com>
Subject: Re: [PATCH v3] attr: teach "--attr-source=<tree>" global option to "git"
Date: Fri, 28 Apr 2023 22:22:26 +0200 [thread overview]
Message-ID: <CAP8UFD0mfb1HSUGT3Bz1gHhH3fMpGDnMHVf2pT0CjirL0C5zuA@mail.gmail.com> (raw)
In-Reply-To: <pull.1470.v3.git.git.1682707848916.gitgitgadget@gmail.com>
> +--attr-source=<tree-ish>::
> -+ Read gitattributes from <tree-ish> instead of the worktree.
> ++ Read gitattributes from <tree-ish> instead of the worktree. See
> ++ linkgit:gitrevisions[7].
I think it's more sensible to link to gitattributes(5) instead of
gitrevisions(7)
> +static const char *default_attr_source_tree_object_name;
> +
> +void set_git_attr_source(const char *tree_object_name)
> +{
> + default_attr_source_tree_object_name = xstrdup(tree_object_name);
> +}
> +
> +
One empty line is enough here.
> +static void compute_default_attr_source(struct object_id *attr_source)
> +{
> + int from_env = 0;
> +
> + if (!default_attr_source_tree_object_name) {
> + default_attr_source_tree_object_name = getenv(GIT_ATTR_SOURCE);
> + from_env = 1;
> + }
> +
> + if (!default_attr_source_tree_object_name || !is_null_oid(attr_source))
> + return;
> +
> + if (repo_get_oid_treeish(the_repository, default_attr_source_tree_object_name, attr_source)) {
> + if (from_env)
> + die(_("bad --attr-source object"));
> + else
> + die(_("bad GIT_ATTR_SOURCE"));
I think it would be better to have just the following instead of the 4
lines above:
die(_("invalid tree object from --attr-source flag or GIT_ATTR_SOURCE
env variable"));
as a bad GIT_ATTR_SOURCE in a subprocess could come from a bad
--attr-source in the main process.
And this way the from_env variable is not needed.
> + }
> +}
The rest looks good to me, thanks!
next prev parent reply other threads:[~2023-04-28 20:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-18 3:25 [PATCH] attr: teach "--attr-source=<tree>" global option to "git" John Cai via GitGitGadget
2023-03-27 17:02 ` [PATCH v2] " John Cai via GitGitGadget
2023-03-27 18:29 ` Junio C Hamano
2023-03-27 19:40 ` John Cai
2023-04-27 14:02 ` Christian Couder
2023-04-27 14:07 ` Christian Couder
2023-04-28 18:50 ` [PATCH v3] " John Cai via GitGitGadget
2023-04-28 20:22 ` Christian Couder [this message]
2023-04-30 2:22 ` John Cai
2023-04-30 2:39 ` [PATCH v4] " John Cai via GitGitGadget
2023-05-01 16:21 ` Junio C Hamano
2023-05-03 15:10 ` Christian Couder
2023-05-03 18:40 ` John Cai
2023-05-03 20:09 ` [PATCH v5] " John Cai via GitGitGadget
2023-05-04 9:50 ` Christian Couder
2023-05-06 4:15 ` [PATCH v6] " John Cai via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP8UFD0mfb1HSUGT3Bz1gHhH3fMpGDnMHVf2pT0CjirL0C5zuA@mail.gmail.com \
--to=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johncai86@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).