git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: Paul Tan <pyokagan@gmail.com>
Cc: Git List <git@vger.kernel.org>, Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH/RFC/GSOC] make git-pull a builtin
Date: Sat, 21 Mar 2015 18:27:31 +0100	[thread overview]
Message-ID: <0c67273f0d1b8af3391db66617b24de5@www.dscho.org> (raw)
In-Reply-To: <CACRoPnQ4iJMn7+eujOXUN6dks2HMQYRw+nYfM1QvOD+k7BCtEQ@mail.gmail.com>

Hi Paul,

On 2015-03-21 15:00, Paul Tan wrote:

> Thanks for your suggestions, I agree with most of them :).
> 
> On Wed, Mar 18, 2015 at 5:00 PM, Johannes Schindelin
> <johannes.schindelin@gmx.de> wrote:
>>> +static int parse_opt_rebase(const struct option *opt, const char
>>> *arg, int unset)
>>> +{
>>> +     if (arg)
>>> +             *(int *)opt->value = parse_rebase(arg);
>>> +     else
>>> +             *(int *)opt->value = unset ? REBASE_FALSE : REBASE_TRUE;
>>> +     return (*(int *)opt->value) >= 0 ? 0 : -1;
>>> +}
>>
>> In this function (and also in other places below), there is this pattern that a `struct option` pointer is passed to the function, but then only `*(int *)opt->value` is written to. Therefore, I would suggest to change the signature of the function and pass `(int *)opt->value` as function parameter.
> 
> It's used as a callback for the argument parser though, so the
> callback signature is required.

Good point ;-)

For readability, I would then suggest to declare `int *result = (int *)opt->value;` on the top of the function and then use `*result = ...` later.

>>> +static int has_unstaged_changes(void)
>>
>> Yeah, this function, as well as the ones below it, look as if they are so common that they *should* be already somewhere in libgit.a. But I did not find them, either...
>>
>> Of course it *would* be nice to identify places where essentially the same code is needed, and refactor accordingly. But I think that is outside the scope of this project.
> 
> Actually, I think that identifying the places where code can be
> trivially shared (without requiring major refactoring) should be part
> of the project, otherwise lots of code may be duplicated and cause
> code bloat. The obvious one would be fork_point() in this patch, which
> is copied from the merge-base builtin and not accessible because it
> has static linkage. The project should, at the very least, allow the
> function to be shared between git-pull and git-merge-base, as well as
> to modify the function so that it can fail without die()-ing.

Yes, I agree wholeheartedly. But I like your choice to strike a balance for the sake of a proof-of-concept.

Ciao,
Johannes

  reply	other threads:[~2015-03-21 17:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 13:57 [PATCH/RFC/GSOC] make git-pull a builtin Paul Tan
2015-03-18  8:38 ` Stephen Robin
2015-03-18  9:24   ` Johannes Schindelin
2015-03-18  9:00 ` Johannes Schindelin
2015-03-21 14:00   ` Paul Tan
2015-03-21 17:27     ` Johannes Schindelin [this message]
2015-03-18 17:52 ` Matthieu Moy
2015-03-21 13:23   ` Paul Tan
2015-03-21 17:35     ` Johannes Schindelin
2015-03-22 17:39       ` Paul Tan
2015-03-23  9:07         ` Johannes Schindelin
2015-03-23 10:18     ` Duy Nguyen
2015-03-24 15:58       ` Paul Tan
2015-03-18 22:26 ` Junio C Hamano
2015-03-21 13:40   ` Paul Tan

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=0c67273f0d1b8af3391db66617b24de5@www.dscho.org \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=pyokagan@gmail.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).