git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Introduce "precious" file concept

From
Duy Nguyen <pclouds@gmail.com>
Date
Apr 10, 2019, 09:36 UTC
Message-ID
<CACsJy8Ct6A7a7FzzH7ZUv9R2+k=G6qhzZ8Yjq8GUDBdTr_QBQA@mail.gmail.com>
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:
Show 26 quoted lines
> > @@ -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
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 19 in “What's cooking in git.git (Apr 2019, #01; Thu, 4)”
  1. Junio C HamanoApr 4, 2019
  2. Duy NguyenApr 4, 2019
  3. Junio C HamanoApr 4, 2019
  4. Ævar Arnfjörð BjarmasonApr 6, 2019
  5. Junio C HamanoApr 8, 2019
  6. Introduce "precious" file conceptNguyễn Thái Ngọc Duy, Apr 9, 2019
  7. Junio C HamanoApr 9, 2019
  8. Duy NguyenApr 10, 2019
  9. Junio C HamanoApr 12, 2019
  10. Eric SunshineApr 9, 2019
  11. Ævar Arnfjörð BjarmasonApr 12, 2019
  12. Duy NguyenApr 13, 2019
  13. Todd ZullingerApr 5, 2019
  14. Junio C HamanoApr 5, 2019
  15. Ævar Arnfjörð BjarmasonApr 6, 2019
  16. Junio C HamanoApr 8, 2019
  17. Ævar Arnfjörð BjarmasonApr 6, 2019
  18. Junio C HamanoApr 8, 2019
  19. Josh SteadmonApr 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.