From: Junio C Hamano <gitster@pobox.com>
To: Muhammed Dilshad A <dilsheddilu123@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] combine-diff: honor --relative when printing paths
Date: Wed, 07 Oct 2026 07:45:30 -0700 [thread overview]
Message-ID: <xmqqld89bmd1.fsf@gitster.g> (raw)
In-Reply-To: <20261007051734.62590-1-dilsheddilu123@gmail.com> (Muhammed Dilshad A.'s message of "Wed, 7 Oct 2026 10:47:34 +0530")
Muhammed Dilshad A <dilsheddilu123@gmail.com> writes:
> +static const char *strip_relative_prefix(const struct diff_options *opt,
> + const char *path)
> +{
> + if (opt->prefix && skip_prefix(path, opt->prefix, &path) && *path == '/')
> + path++;
> + return path;
> +}
That's quite a long line. Read about coding guidelines in our
Documentation/ directory.
Also, do callers guarantee that path may have only up to one
trailing slashes and never two or more?
> @@ -932,6 +940,7 @@ static void show_combined_header(struct combine_diff_path *elem,
> const char *b_prefix = opt->b_prefix ? opt->b_prefix : "b/";
> const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);
> const char *c_reset = diff_get_color_opt(opt, DIFF_RESET);
> + const char *name = strip_relative_prefix(opt, elem->path);
> const char *abb;
> int added = 0;
> int deleted = 0;
> @@ -942,7 +951,7 @@ static void show_combined_header(struct combine_diff_path *elem,
> show_log(rev);
>
> dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
> - "", elem->path, line_prefix, c_meta, c_reset);
> + "", name, line_prefix, c_meta, c_reset);
> printf("%s%sindex ", line_prefix, c_meta);
> for (i = 0; i < num_parent; i++) {
> abb = repo_find_unique_abbrev(the_repository,
> @@ -987,6 +996,7 @@ static void show_combined_header(struct combine_diff_path *elem,
> const char *path = elem->parent[i].path ?
> elem->parent[i].path :
> elem->path;
> + path = strip_relative_prefix(opt, path);
When a rename is involved (e.g., originally the contents was in
here/file we have made our changes in place, while the other side
moved the file to there/file and made changes there, these were
matched up and are shown as a merge into here/file. Wouldn't a
elem->parent[].path point at here/file while another points at
there/file in such a case? What should happen when our prefix is in
"here/"? I know "here/file" should become "file", but what about
"there/file" that they bring into the picture?
Not striping anything does give consistent result and would not
mislead the readers as long as they understand --relative is
ignored. Contrasting to that, "we strip if the path is inside our
prefix, but otherwise we give full path" would give ambiguous
output, wouldn't it?
next prev parent reply other threads:[~2026-10-07 14:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 5:17 [PATCH] combine-diff: honor --relative when printing paths Muhammed Dilshad A
2026-10-07 14:45 ` Junio C Hamano [this message]
2026-10-07 16:35 ` [PATCH v2 0/2] combine-diff: honor relative paths consistently Muhammed Dilshad A
2026-10-07 16:35 ` [PATCH v2 1/2] combine-diff: honor --relative when printing paths Muhammed Dilshad A
2026-10-07 16:35 ` [PATCH v2 2/2] combine-diff: filter the fast scan by the relative prefix Muhammed Dilshad A
2026-10-07 17:53 ` [PATCH v2 0/2] combine-diff: honor relative paths consistently Junio C Hamano
2026-10-09 11:08 ` Muhammed Dilshad A
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=xmqqld89bmd1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=dilsheddilu123@gmail.com \
--cc=git@vger.kernel.org \
/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