git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Shourya Shukla <shouryashukla.oo@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com,
	gitster@pobox.com, liu.denton@gmail.com,
	kaartic.sivaraam@gmail.com, pc44800@gmail.com,
	sbeller@google.com, pclouds@gmail.com
Subject: Re: [PATCH 3/4] diff: change scope of the function count_lines()
Date: Fri, 3 Jul 2020 17:07:13 +0200 (CEST)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.2007031659580.50@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20200702192409.21865-4-shouryashukla.oo@gmail.com>

Hi Shourya,

On Fri, 3 Jul 2020, Shourya Shukla wrote:

> From: Prathamesh Chavan <pc44800@gmail.com>
>
> Change the scope of function count_lines for allowing the function
> to be reused in other parts of the code as well.

It may be just me, but I'd rather see the word "visibility" instead of
"scope" here. I mistook the subject line to indicate that the function is
changed to serve an (at least slightly) different purpose than before,
which is not actually the case.

Another alternative to "visibility" might be to imitate existing commit
messages, such as e4cb659ebdd (diff: export diffstat interface,
2019-11-13), 22184497a36 (factor out refresh_and_write_cache function,
2019-09-11) or ef283b3699f (apply: make parse_git_diff_header public,
2019-07-11).

In addition, as with all such changes, we need to be careful to consider
whether unrelated function names coming in from system headers might
clash. In this case, I think `count_lines()` is a bit too generic, but
will probably not clash. Personally, I would probably have opted for
`count_lines_in_string()`.

Ciao,
Johannes

>
> Mentored-by: Christian Couder <christian.couder@gmail.com>
> Mentored-by: Stefan Beller <sbeller@google.com>
> Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
> Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
> ---
>  diff.c | 2 +-
>  diff.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/diff.c b/diff.c
> index 4a2c631c37..39ddbcf451 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -547,7 +547,7 @@ struct emit_callback {
>  	struct strbuf *header;
>  };
>
> -static int count_lines(const char *data, int size)
> +int count_lines(const char *data, int size)
>  {
>  	int count, ch, completely_empty = 1, nl_just_seen = 0;
>  	count = 0;
> diff --git a/diff.h b/diff.h
> index 9443dc1b00..bd96c8c434 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -495,6 +495,7 @@ void free_diffstat_info(struct diffstat_t *diffstat);
>  int parse_long_opt(const char *opt, const char **argv,
>  		   const char **optarg);
>
> +int count_lines(const char *data, int size);
>  int git_diff_basic_config(const char *var, const char *value, void *cb);
>  int git_diff_heuristic_config(const char *var, const char *value, void *cb);
>  void init_diff_ui_defaults(void);
> --
> 2.27.0
>
>

  reply	other threads:[~2020-07-03 15:07 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 [this message]
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

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.2007031659580.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=pclouds@gmail.com \
    --cc=sbeller@google.com \
    --cc=shouryashukla.oo@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).