git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Carlos Rica" <jasampler@gmail.com>
To: "Kristian Høgsberg" <krh@redhat.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Implement git commit as a builtin.
Date: Wed, 18 Jul 2007 23:27:42 +0200	[thread overview]
Message-ID: <1b46aba20707181427y12bd8b62pe30df61219e7c1f7@mail.gmail.com> (raw)
In-Reply-To: <11847863792344-git-send-email-krh@redhat.com>

2007/7/18, Kristian Høgsberg <krh@redhat.com>:
> +       if (buffer) {
> +               len = strip_lines(buffer, len);
> +
> +               if (fwrite(buffer, 1, len, fp) < len)
> +                       die("could not write commit template: %s\n",
> +                           strerror(errno));
> +       }
....
> +       len = strip_lines(buffer, len);
> +
> +       if (message_is_empty(buffer, len))
> +               die("* no commit message?  aborting commit.");
> +

Hi Kristian, you could call to the new stripspace() function
in builtin-stripspace.c, to reduce code in your file. The only
thing you should consider is that the new stripspace()
removes always the last '\n' in the file (if any), so you have to
add it when you need.

I sent a patch to change the name of read_pipe with read_fd
(not accepted yet), and to terminate the buffer with NUL
(although perhaps you don't need that), and to allow the
function to receive buffer NULL or size 0.
Your version was a lot different, therefore you would
need to set buffer and size before calling it
and free the buffer if reading failed after that:
http://article.gmane.org/gmane.comp.version-control.git/52835

Now I need to create the new file editor.c to group at
least three functions related with reading and editing text.
Those also will reduce the size of your code and also
can be reused from builtin-tag.c: launch_editor,
read_path (as read_file someone said), and stripspace.

The first problem now should be how to write a version for
launch_editor() which both builtins (yours and mine) could share,
because the references in your launch_editor() related to commits,
removed already in my version for git-tag.

I did this job trying to make easier your porting by moving
those parts shared with builtin-tag.c outside your code
and generating discussion on them, so you
can concentrate just in the specific parts and reuse
the rest. I hope those can help you.

---
Carlos Rica

  parent reply	other threads:[~2007-07-18 21:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 19:19 [PATCH] Implement git commit as a builtin Kristian Høgsberg
2007-07-18 19:43 ` Nicolas Pitre
2007-07-18 21:27 ` Carlos Rica [this message]
2007-07-20 14:45   ` Kristian Høgsberg

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=1b46aba20707181427y12bd8b62pe30df61219e7c1f7@mail.gmail.com \
    --to=jasampler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=krh@redhat.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).