From: Shourya Shukla <shouryashukla.oo@gmail.com>
To: shouryashukla.oo@gmail.com
Cc: Johannes.Schindelin@gmx.de, 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: Thu, 16 Jul 2020 00:11:53 +0530 [thread overview]
Message-ID: <20200715184153.GA52607@konoha> (raw)
In-Reply-To: <20200715145336.GA18071@konoha>
Ignore the above mail I sent, I am a big dimwit. I have tried to do this
and this works
---------------8<--------------
module_summary() {
struct object_id head;
....
....
if (!get_oid(argc ? argv[0] : "HEAD", &head_oid)) {
if (argc) {
argv++;
argc--;
}
} else if (!argc || !strcmp(argv[0], "HEAD")) {
/* before the first commit: compare with an empty tree */
oidcpy(&head_oid, the_hash_algo->empty_tree);
if (argc) {
argv++;
argc--;
}
} else {
get_oid("HEAD", &head_oid);
}
....
....
ret = compute_summary_module_list((diff_cmd == DIFF_FILES) ? NULL : &head_oid,
&info, diff_cmd);
return ret;
}
compute_summary_module_list() {
....
....
if (head_oid)
argv_array_push(&diff_args, oid_to_hex(head_oid));
....
....
}
--------------->8--------------
Obviousy I was making the grave mistake of declaring the aforementioned
struct as 'struct object_id *' which caused all these weird errors.
All tests pass now.
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?
Regards,
Shourya Shukla
next prev parent reply other threads:[~2020-07-15 18:42 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 [this message]
2020-08-10 13:24 ` 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=20200715184153.GA52607@konoha \
--to=shouryashukla.oo@gmail.com \
--cc=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=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.
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).