From: Junio C Hamano Date: Wed, 07 Oct 2026 14:45:30 GMT Subject: Re: [PATCH] combine-diff: honor --relative when printing paths Message-ID: In-Reply-To: <20261007051734.62590-1-dilsheddilu123@gmail.com> Muhammed Dilshad A 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?