git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karthik Nayak <karthik.188@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>,
	Matthieu Moy <matthieu.moy@grenoble-inp.fr>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH/RFC 08/10] ref-filter: introduce remote_ref_atom_parser()
Date: Sun, 13 Dec 2015 14:02:28 +0530	[thread overview]
Message-ID: <CAOLa=ZQD1ZhkOGr6Y3ZTwkRC--gMVjwXhpvGpBUGuoHjw9hoJQ@mail.gmail.com> (raw)
In-Reply-To: <CAOLa=ZQKR4+a-hpL-8xjE-93btWpUt4zAfCGTHBGWwhvLtQoRg@mail.gmail.com>

On Sun, Dec 13, 2015 at 11:32 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
> On Sun, Dec 13, 2015 at 6:23 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Wed, Nov 11, 2015 at 2:44 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
>>> Introduce remote_ref_atom_parser() which will parse the '%(upstream)'
>>> and '%(push)' atoms and store information into the 'used_atom'
>>> structure based on the modifiers used along with the corresponding
>>> atom.
>>>
>>> Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
>>> ---
>>> diff --git a/ref-filter.c b/ref-filter.c
>>> @@ -37,6 +37,11 @@ static struct used_atom {
>>>         union {
>>>                 const char *color;
>>>                 struct align align;
>>> +               struct {
>>> +                       unsigned int shorten : 1,
>>> +                               track : 1,
>>> +                               trackshort : 1;
>>> +               } remote_ref;
>>
>> Are 'shorten', 'track', and 'trackshort' mutually exclusive? If so, a
>> simple enum would be clearer than bitfields:
>>
>>     union {
>>         const char *color;
>>         struct align align;
>>         enum { RR_PLAIN, RR_SHORTEN, RR_TRACK, RR_TRACKSHORT }
>>             remote_ref;
>>     };
>>
>> Or something.
>>
>
> Sure, will do that.
>

There's also a slight problem with using enum's with the current implementation.
The problem is the enum is set to 0 by default (since we use memset).
so the first
value is set by default, not something we'd want. So either we stick
to the structure
with unsigned bits or we introduce a pseudo value in the enum. I
prefer the former.



On Sun, Dec 13, 2015 at 11:45 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Sun, Dec 13, 2015 at 1:02 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
>> On Sun, Dec 13, 2015 at 6:23 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>>> On Wed, Nov 11, 2015 at 2:44 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
>>>> +               if (!num_ours && !num_theirs)
>>>> +                       *s = "";
>>>> +               else if (!num_ours)
>>>> +                       *s = xstrfmt("[behind %d]", num_theirs);
>>>> +               else if (!num_theirs)
>>>> +                       *s = xstrfmt("[ahead %d]", num_ours);
>>>> +               else
>>>> +                       *s = xstrfmt("[ahead %d, behind %d]",
>>>> +                                    num_ours, num_theirs);
>>>
>>> Tangent: These xstrfmt()'d strings are getting leaked, right? Is that
>>> something that we need to worry about (if, for instance, a repository
>>> contains a lot of tracking refs)? Should there be a NEEDSWORK comment
>>> here regarding the issue?
>>
>> This is sort of a problem with most of the values in ref-filter, we dynamically
>> allocate memory and do not free it, since the program exits soon after and
>> we leave it to the Operating System to do the garbage collection.
>
> I'm not worried about memory dynamically allocated for the used_atom[]
> array being leaked (and cleaned up automatically at program exit), but
> rather about memory being leaked for each processed reference, which
> might become substantial for a project with a lot of references.
>
>> Not sure if we'd want to work on this though.
>
> It's likely outside the scope of the current patch series anyhow, and
> probably not something that needs to be tackled right away (or perhaps
> ever), which is why a NEEDSWORK comment might be appropriate, as a
> reminder that the situation could be improved.

Yes I got what you're saying. I'm talking about other values which are
dynamically
allocated in ref-filter itself.

For e.g.

When we use the deref option
v->s = xstrfmt("%s^{}", refname);

or the color option
v->s = xstrdup(color);

So seems like we need a way to go around all of these.

-- 
Regards,
Karthik Nayak

  parent reply	other threads:[~2015-12-13  8:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 19:44 [PATCH/RFC 00/10] ref-filter: use parsing functions Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 01/10] ref-filter: introduce a parsing function for each atom in valid_atom Karthik Nayak
2015-11-23 23:44   ` Eric Sunshine
2015-11-25 12:10     ` Karthik Nayak
2015-11-25 19:41       ` Eric Sunshine
2015-11-26 18:01         ` Karthik Nayak
2015-12-11 22:18           ` Junio C Hamano
2015-12-12 16:05             ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 02/10] ref-filter: introduce struct used_atom Karthik Nayak
2015-12-01 23:00   ` Eric Sunshine
2015-11-11 19:44 ` [PATCH/RFC 03/10] ref-fitler: bump match_atom() name to the top Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 04/10] ref-filter: skip deref specifier in match_atom_name() Karthik Nayak
2015-12-01 23:11   ` Eric Sunshine
2015-12-03  6:34     ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 05/10] ref-filter: introduce color_atom_parser() Karthik Nayak
2015-12-01 23:27   ` Eric Sunshine
2015-12-03 13:35     ` Karthik Nayak
2015-12-13  6:05       ` Eric Sunshine
2015-12-13 18:46         ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 06/10] strbuf: introduce strbuf_split_str_without_term() Karthik Nayak
2015-12-02  8:04   ` Eric Sunshine
2015-12-03 18:12     ` Karthik Nayak
2015-12-11 22:31       ` Junio C Hamano
2015-12-12 16:04         ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 07/10] ref-filter: introduce align_atom_parser() Karthik Nayak
2015-12-02 21:23   ` Eric Sunshine
2015-12-07 17:00     ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 08/10] ref-filter: introduce remote_ref_atom_parser() Karthik Nayak
2015-12-13  0:53   ` Eric Sunshine
2015-12-13  6:02     ` Karthik Nayak
2015-12-13  6:15       ` Eric Sunshine
2015-12-13  8:32       ` Karthik Nayak [this message]
2015-12-13  8:45         ` Eric Sunshine
2015-12-13  8:53           ` Karthik Nayak
2015-11-11 19:44 ` [PATCH/RFC 09/10] ref-filter: introduce contents_atom_parser() Karthik Nayak
2015-12-13  3:10   ` Eric Sunshine
2015-12-13  4:41     ` Eric Sunshine
2015-12-13 19:36       ` Karthik Nayak
2015-12-13 19:33     ` Karthik Nayak
2015-11-24 21:48 ` [PATCH/RFC 00/10] ref-filter: use parsing functions Jeff King
2015-11-25 12:07   ` Karthik Nayak
2015-11-25 13:44   ` [PATCH/RFC 10/10] ref-filter: introduce objectname_atom_parser() Karthik Nayak
2015-12-13  4:49     ` Eric Sunshine
2015-12-13 19:40       ` Karthik Nayak
2015-12-11 22:49 ` [PATCH/RFC 00/10] ref-filter: use parsing functions Junio C Hamano
2015-12-13  5:40   ` Eric Sunshine
2015-12-13  9:31     ` Karthik Nayak
2015-12-13 21:55       ` Eric Sunshine
2015-12-16 14:45         ` Karthik Nayak
2015-12-14 19:06     ` Junio C Hamano

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='CAOLa=ZQD1ZhkOGr6Y3ZTwkRC--gMVjwXhpvGpBUGuoHjw9hoJQ@mail.gmail.com' \
    --to=karthik.188@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=matthieu.moy@grenoble-inp.fr \
    --cc=sunshine@sunshineco.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 NNTP newsgroup(s).