From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Shourya Shukla <shouryashukla.oo@gmail.com>
Cc: christian.couder@gmail.com, git@vger.kernel.org,
gitster@pobox.com, kaartic.sivaraam@gmail.com,
liu.denton@gmail.com, pc44800@gmail.com, stefanbeller@gmail.com
Subject: Re: [PATCH 4/4] submodule: port submodule subcommand 'summary' from shell to C
Date: Mon, 10 Aug 2020 15:24:03 +0200 (CEST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.2008101519090.50@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20200715184153.GA52607@konoha>
Hi Shourya,
On Thu, 16 Jul 2020, Shourya Shukla wrote:
> BTW in your review of my patch,
> https://lore.kernel.org/git/nycvar.QRO.7.76.6.2007031712160.50@tvgsbejvaqbjf.bet/
> you said this:
> --------------->8--------------
> > + */
> > + struct child_process cp_rev_parse = CHILD_PROCESS_INIT;
> > + struct strbuf sb_rev_parse = STRBUF_INIT;
> > +
> > + cp_rev_parse.git_cmd = 1;
> > + cp_rev_parse.no_stderr = 1;
> > + cp_rev_parse.dir = p->sm_path;
> > + prepare_submodule_repo_env(&cp_rev_parse.env_array);
> > +
> > + argv_array_pushl(&cp_rev_parse.args, "rev-parse",
> > + "HEAD", NULL);
> > + if (!capture_command(&cp_rev_parse, &sb_rev_parse, 0)) {
> > + strbuf_strip_suffix(&sb_rev_parse, "\n");
> > + get_oid_hex(sb_rev_parse.buf, &p->oid_dst);
> > + }
> > + strbuf_release(&sb_rev_parse);
> > + } else if (S_ISLNK(p->mod_dst) || S_ISREG(p->mod_dst)) {
> > + struct child_process cp_hash_object = CHILD_PROCESS_INIT;
> > + struct strbuf sb_hash_object = STRBUF_INIT;
> > +
> > + cp_hash_object.git_cmd = 1;
> > + argv_array_pushl(&cp_hash_object.args, "hash-object",
> > + p->sm_path, NULL);
> > + if (!capture_command(&cp_hash_object,
> > + &sb_hash_object, 0)) {
> > + strbuf_strip_suffix(&sb_hash_object, "\n");
> > + get_oid_hex(sb_hash_object.buf, &p->oid_dst);
> > + }
> > + strbuf_release(&sb_hash_object);
>
> It would probably be shorter, less error-prone, and quicker to use
> `index_fd()` directly.
> --------------->8--------------
>
> What exactly did you mean here and where should the index_fd() be used?
Well, `index_fd()` is the function that `git hash-object` uses to
calculate the hash of a given file (in this case, specified via the path
`p->sm_path`).
You could open an fd to that file directly, use `index_fd()` to calculate
the hash, and thereby avoid spawning another (totally unnecessary)
process.
Ciao,
Dscho
prev parent reply other threads:[~2020-08-10 13:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 19:24 [GSoC][PATCH 0/4] submodule: port 'summary' from Shell to C Shourya Shukla
2020-07-02 19:24 ` [PATCH 1/4] submodule: amend extra line feed between callback struct and macro Shourya Shukla
2020-07-03 14:57 ` Johannes Schindelin
2020-07-03 15:37 ` Philip Oakley
2020-07-04 15:21 ` Shourya Shukla
2020-07-04 15:39 ` Đoàn Trần Công Danh
2020-07-05 10:52 ` Philip Oakley
2020-07-02 19:24 ` [PATCH 2/4] submodule: rename helper functions to avoid ambiguity Shourya Shukla
2020-07-02 19:24 ` [PATCH 3/4] diff: change scope of the function count_lines() Shourya Shukla
2020-07-03 15:07 ` Johannes Schindelin
2020-07-04 15:28 ` Shourya Shukla
2020-07-04 21:46 ` Christian Couder
2020-07-02 19:24 ` [PATCH 4/4] submodule: port submodule subcommand 'summary' from shell to C Shourya Shukla
2020-07-03 20:46 ` Johannes Schindelin
2020-07-05 17:34 ` Shourya Shukla
2020-07-06 9:16 ` Kaartic Sivaraam
2020-07-06 11:15 ` Shourya Shukla
2020-07-12 0:46 ` Johannes Schindelin
2020-07-15 14:53 ` Shourya Shukla
2020-07-15 18:41 ` Shourya Shukla
2020-08-10 13:24 ` Johannes Schindelin [this message]
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=nycvar.QRO.7.76.6.2008101519090.50@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=liu.denton@gmail.com \
--cc=pc44800@gmail.com \
--cc=shouryashukla.oo@gmail.com \
--cc=stefanbeller@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).