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

Re: [RFC PATCH v2 2/4] gitignore: read from index if .gitignore is assume-unchanged

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 11, 2009, 08:12 UTC
Message-ID
<alpine.DEB.1.00.0908111009010.4638@intel-tinevez-2-302>
In-Reply-To
<fcaeb9bf0908101857x7a44d3dfge20e45d24daee9bf@mail.gmail.com>
Hi,
On Tue, 11 Aug 2009, Nguyen Thai Ngoc Duy wrote:
Show 23 quoted lines
> 2009/8/10 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>
> > On Mon, 10 Aug 2009, Nguyễn Thái Ngọc Duy wrote:
> >
> >> @@ -212,27 +237,31 @@ static int add_excludes_from_file_1(const char *fname,
> >>
> >> [...]
> >>
> >>       if (buf_p)
> >>               *buf_p = buf;
> >> -     buf[size++] = '\n';
> >>       entry = buf;
> >> -     for (i = 0; i < size; i++) {
> >> -             if (buf[i] == '\n') {
> >> +     for (i = 0; i <= size; i++) {
> >> +             if (i == size || buf[i] == '\n') {
> >>                       if (entry != buf + i && entry[0] != '#') {
> >>                               buf[i - (i && buf[i-1] == '\r')] = 0;
> >>                               add_exclude(entry, base, baselen, which);
> >
> > Should this change not rather be a separate one?
> 
> You meant a separate patch?
Yes, sorry, I meant exactly that.
> It is tied to this patch, because if bus is read from read_index_data, 
> it does not have extra space for '\n' at the end.

But you could separate it out as a patch that just avoids writing to buf. IMHO this would make following the patch series easier.

Show 23 quoted lines
> >> @@ -241,17 +270,12 @@ static int add_excludes_from_file_1(const char *fname,
> >>               }
> >>       }
> >>       return 0;
> >> -
> >> - err:
> >> -     if (0 <= fd)
> >> -             close(fd);
> >> -     return -1;
> >>  }
> >>
> >>  void add_excludes_from_file(struct dir_struct *dir, const char *fname)
> >>  {
> >>       if (add_excludes_from_file_1(fname, "", 0, NULL,
> >> -                                  &dir->exclude_list[EXC_FILE]) < 0)
> >> +                                  &dir->exclude_list[EXC_FILE], 0) < 0)
> >
> > Could you mention in the commit message why this function does not 
> > want to check the index (I _guess_ it is because this code path only 
> > tries to read .git/info/exclude, but it would be better to be sure).
> 
> To retain old behaviour. But I have to check its callers. Maybe we
> want to check the index too.

Yes, it would be good to illustrate in the commit message which code paths want to check the index, and why.

Show 19 quoted lines
> >> @@ -85,6 +85,26 @@ test_expect_success \
> >>         >output &&
> >>       test_cmp expect output'
> >>
> >> +test_expect_success 'setup sparse gitignore' '
> >> +     git add .gitignore one/.gitignore one/two/.gitignore &&
> >> +     git update-index --assume-unchanged .gitignore one/.gitignore one/two/.gitignore &&
> >> +     rm .gitignore one/.gitignore one/two/.gitignore
> >> +'
> >
> > You're probably less sloppy than me; I'd have defined a variable like
> > this:
> >
> >        ignores=".gitignore one/.gitignore one/two/.gitignore"
> >
> > and used it for the three calls, just to make sure that I do not fsck
> > anything up there due to fat fingers.
> 
> I have slim ones :-)

Oh, don't get me wrong: my fingers are slim enough to play piano, and even to write pretty fast on my EeePC 701.

But darn, there are days when they feel as if they were thick like a brick.

Ciao, Dscho

Previous: Nguyen Thai Ngoc DuyNext: Johannes Schindelin
Message 16 of 19 in “Sparse checkout”
  1. 0/4 Sparse checkoutNguyễn Thái Ngọc Duy, Aug 10, 2009
  2. 1/4 Prevent diff machinery from examining assume-unchanged entries on worktreeNguyễn Thái Ngọc Duy, Aug 10, 2009
  3. 2/4 gitignore: read from index if .gitignore is assume-unchangedNguyễn Thái Ngọc Duy, Aug 10, 2009
  4. 3/4 unpack_trees(): add support for sparse checkoutNguyễn Thái Ngọc Duy, Aug 10, 2009
  5. 4/4 read-tree: add --no-sparse to turn off sparse hookNguyễn Thái Ngọc Duy, Aug 10, 2009
  6. Johannes SchindelinAug 10, 2009
  7. Nguyen Thai Ngoc DuyAug 11, 2009
  8. Junio C HamanoAug 11, 2009
  9. Johannes SchindelinAug 11, 2009
  10. Nguyen Thai Ngoc DuyAug 11, 2009
  11. Johannes SchindelinAug 10, 2009
  12. Nguyen Thai Ngoc DuyAug 11, 2009
  13. Johannes SchindelinAug 11, 2009
  14. Johannes SchindelinAug 10, 2009
  15. Nguyen Thai Ngoc DuyAug 11, 2009
  16. Johannes SchindelinAug 11, 2009
  17. Johannes SchindelinAug 10, 2009
  18. Nguyen Thai Ngoc DuyAug 11, 2009
  19. Johannes SchindelinAug 11, 2009

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.