git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/4] gitignore: read from index if .gitignore is  assume-unchanged
Date: Tue, 11 Aug 2009 08:57:30 +0700	[thread overview]
Message-ID: <fcaeb9bf0908101857x7a44d3dfge20e45d24daee9bf@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0908101826250.8324@intel-tinevez-2-302>

2009/8/10 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Hi,
>
> On Mon, 10 Aug 2009, Nguyễn Thái Ngọc Duy wrote:
>
>> diff --git a/dir.c b/dir.c
>> index e05b850..e55344f 100644
>> --- a/dir.c
>> +++ b/dir.c
>> @@ -200,11 +200,36 @@ void add_exclude(const char *string, const char *base,
>>       which->excludes[which->nr++] = x;
>>  }
>>
>> +static void *read_index_data(const char *path, size_t *size)
>
> How about calling it "read_assume_unchanged_from_index()" instead?  I
> suggest this because it does not read the index from the data if the path
> is not marked assume unchanged...

Agree.

>> @@ -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? 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.

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

>> @@ -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 :-) But "git add $ignores && git update-index
$ignores && rm $ignores" is easier to read.
-- 
Duy

  reply	other threads:[~2009-08-11  1:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10 15:19 [RFC PATCH v2 0/4] Sparse checkout Nguyễn Thái Ngọc Duy
2009-08-10 15:19 ` [RFC PATCH v2 1/4] Prevent diff machinery from examining assume-unchanged entries on worktree Nguyễn Thái Ngọc Duy
2009-08-10 15:19   ` [RFC PATCH v2 2/4] gitignore: read from index if .gitignore is assume-unchanged Nguyễn Thái Ngọc Duy
2009-08-10 15:19     ` [RFC PATCH v2 3/4] unpack_trees(): add support for sparse checkout Nguyễn Thái Ngọc Duy
2009-08-10 15:19       ` [RFC PATCH v2 4/4] read-tree: add --no-sparse to turn off sparse hook Nguyễn Thái Ngọc Duy
2009-08-10 16:46         ` Johannes Schindelin
2009-08-11  1:38           ` Nguyen Thai Ngoc Duy
2009-08-11  5:13             ` Junio C Hamano
2009-08-11  6:50               ` Johannes Schindelin
2009-08-11  7:08                 ` Nguyen Thai Ngoc Duy
2009-08-10 16:41       ` [RFC PATCH v2 3/4] unpack_trees(): add support for sparse checkout Johannes Schindelin
2009-08-11  1:47         ` Nguyen Thai Ngoc Duy
2009-08-11  7:02           ` Johannes Schindelin
2009-08-10 16:33     ` [RFC PATCH v2 2/4] gitignore: read from index if .gitignore is assume-unchanged Johannes Schindelin
2009-08-11  1:57       ` Nguyen Thai Ngoc Duy [this message]
2009-08-11  8:12         ` Johannes Schindelin
2009-08-10 16:20   ` [RFC PATCH v2 1/4] Prevent diff machinery from examining assume-unchanged entries on worktree Johannes Schindelin
2009-08-11  1:34     ` Nguyen Thai Ngoc Duy
2009-08-11  6:45       ` Johannes Schindelin

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=fcaeb9bf0908101857x7a44d3dfge20e45d24daee9bf@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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 NNTP newsgroup(s).