git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] Introduce "precious" file concept
Date: Wed, 10 Apr 2019 16:36:05 +0700	[thread overview]
Message-ID: <CACsJy8Ct6A7a7FzzH7ZUv9R2+k=G6qhzZ8Yjq8GUDBdTr_QBQA@mail.gmail.com> (raw)
In-Reply-To: <xmqqh8b75s9l.fsf@gitster-ct.c.googlers.com>

On Tue, Apr 9, 2019 at 6:31 PM Junio C Hamano <gitster@pobox.com> wrote:
> > @@ -193,9 +203,16 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
> >
> >               strbuf_setlen(path, len);
> >               strbuf_addstr(path, e->d_name);
> > -             if (lstat(path->buf, &st))
> > +             if (lstat(path->buf, &st)) {
> >                       ; /* fall thru */
> > -             else if (S_ISDIR(st.st_mode)) {
> > +             } else if ((!prefix && skip_precious_file(&the_index, path->buf)) ||
> > +                        (prefix && skip_prefix(path->buf, prefix, &rel_path) &&
> > +                         skip_precious_file(&the_index, rel_path))) {
> > +                     quote_path_relative(path->buf, prefix, &quoted);
> > +                     printf(dry_run ? _(msg_would_skip_precious) : _(msg_skip_precious), quoted.buf);
> > +                     *dir_gone = 0;
> > +                     continue;
>
> An attribute is given to something that can be tracked, and a
> directory would not get an attribute, because Git does not track
> directories (there is a reason why skip_precious_file() takes
> &the_index that is passed down the callchain to git_check_attr()).
>
> Triggering this logic before excluding S_ISDIR(st.st_mode) feels
> iffy.
>
> But let's assume that being able to say "this directory and anything
> (recursively) inside are precious" is a good idea and read on.

Hm... we do allow to set attributes on directories even though we
don't track them. I was under the impression that an attribute set on
a directory will be propagated to all files inside anyway, so this is
more of an (mis?-)optimization.

But gitattributes.txt explicitly says that it's wrong. One would need
to do "path/** precious" to achieve the same thing.

So yeah maybe doing this before S_ISDIR() is wrong. The definition of
`precious` also only says "... is set on _files_". Maybe best to
ignore attributes on directories? At least it looks like that's how
all other attributes do.
-- 
Duy

  reply	other threads:[~2019-04-10  9:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 10:28 What's cooking in git.git (Apr 2019, #01; Thu, 4) Junio C Hamano
2019-04-04 11:08 ` Duy Nguyen
2019-04-04 21:29   ` Junio C Hamano
2019-04-06 20:28     ` Ævar Arnfjörð Bjarmason
2019-04-08  4:14       ` Junio C Hamano
2019-04-09 10:26         ` [PATCH] Introduce "precious" file concept Nguyễn Thái Ngọc Duy
2019-04-09 11:31           ` Junio C Hamano
2019-04-10  9:36             ` Duy Nguyen [this message]
2019-04-12  1:28               ` Junio C Hamano
2019-04-09 17:44           ` Eric Sunshine
2019-04-12 21:54           ` Ævar Arnfjörð Bjarmason
2019-04-13 10:19             ` Duy Nguyen
2019-04-05  1:05 ` What's cooking in git.git (Apr 2019, #01; Thu, 4) Todd Zullinger
2019-04-05  5:41   ` Junio C Hamano
2019-04-06 19:28 ` Ævar Arnfjörð Bjarmason
2019-04-08  4:18   ` Junio C Hamano
2019-04-06 19:57 ` Ævar Arnfjörð Bjarmason
2019-04-08  4:28   ` Junio C Hamano
2019-04-08 21:18     ` Josh Steadmon

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACsJy8Ct6A7a7FzzH7ZUv9R2+k=G6qhzZ8Yjq8GUDBdTr_QBQA@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).