Article View: linux.kernel.git
Article #24Re: [PATCH] combine-diff: honor --relative when printing paths
From: Junio C Hamano
Date: Wed, 07 Oct 2026 14:45
Date: Wed, 07 Oct 2026 14:45
54 lines
11783 bytes
11783 bytes
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?
Technical Details
Message-ID:
<xmqqld89bmd1.fsf@gitster.g>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71373-linux-kernel-git=dewy.ruReferences:
<20261007051734.62590-1-dilsheddilu123@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71373-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] combine-diff: honor --relative when printing paths
Date: Wed, 07 Oct 2026 07:45:30 -0700
Organization: Usenet Network
Message-ID: <xmqqld89bmd1.fsf@gitster.g>
References: <20261007051734.62590-1-dilsheddilu123@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
logging-data="666668"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3KKzxFC3i6pC+LSEWUkqbktg9xk= sha256:bWFlE1yO7VQ7TkR52l80i1s6pz/XoK+HeyEZ7JQ2vQ8=
sha1:wFkL4PGKRklf+heZLgbfUBv4vlY= sha256:aULLCKI4z9SJJZ7WMcyWE7kBiYWnCBK9Phdd+VgF+OM=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 6821F10F191; Wed, 7 Oct 2026 17:46:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.85
X-Spam-Status: No, score=-0.85 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=pobox.com header.b=YcuJrlLe; dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=nXdph2+U
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id jQ9vFWYyOG3R;
Wed, 7 Oct 2026 17:46:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-71373-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 478A310F190; Wed, 7 Oct 2026 17:45:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sto.lore.kernel.org (Postfix) with ESMTP id C5BA66047F4; Wed, 7 Oct 2026 14:45:47 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id F01B61A6823;
Wed, 7 Oct 2026 14:45:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="YcuJrlLe";
dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nXdph2+U"
X-Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 492AD381B04
for <git@vger.kernel.org>; Wed, 7 Oct 2026 14:45:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791384341; cv=none; b=YKBApTwvrwcza52FLsTlYLEfmzL556oafBWWICR4Po02Pgezf+pY332aAyqk6Q7i0ktBAjuE0eOC5nlj+Uf2vFsI2N9WX7tBpyqNMEzoQe3aPGwFfMRer/o/mUYlEzktPIE5ZUoP+PfM2YIYPouyg9ZVZYHUcbTtPWsZhK93RI8=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791384341; c=relaxed/simple;
bh=xTokpMs9Jq7EAR7Vsx7xagMPxFq9U/kH/bmhsMn8yaw=;
h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
MIME-Version:Content-Type; b=EvpMgpUcXmn6PPHmStUmZiIRkIaJX3QWSpalNz3HSxI6Asd3lp/9Kdy32Lguth3XSzMoHiBw+1LJSJ5oFlYyTwM3x3LJsNGtdAIxIX406hCik5RdslZs5ZFNnay1LeafSf2qV/g/fLo+kq6iG21U+qTqWqEmjGlwNNUvKHuZ0/4=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=YcuJrlLe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nXdph2+U; arc=none smtp.client-ip=103.168.172.149
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49])
by mailfout.phl.internal (Postfix) with ESMTP id F038DEC0403
for <git@vger.kernel.org>; Wed, 7 Oct 2026 10:45:31 -0400 (EDT)
X-Received: from phl-frontend-02 ([10.202.2.161])
by phl-compute-09.internal (MEProxy); Wed, 07 Oct 2026 10:45:31 -0400
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
:cc:content-type:content-type:date:date:from:from:in-reply-to
:in-reply-to:message-id:mime-version:references:reply-to:subject
:subject:to:to; s=fm1; t=1791384331; x=1791470731; bh=Y75WWf8X2G
8eLCNDuEq0PI55alXmP1EFV7eZnf0HdmU=; b=YcuJrlLeouS+Tk6FtPeX6tITsz
IEc4l6u7UV7O6SXQDomLiVCIKxgk/64gWFjcK3dNkskMYs78TpVzKnfQt5cH+T+c
899U48d5ZiK/lBp/7Y3KkbEf6XRPoftxdv/fBZrShEgkVBjCsEGxvzB1RhjB87Rh
Lm+l1XMRfj0AIb7jPbZKZopbwN41N629Q3XstD3UccXep1v7IGvsG/zpN17InuF6
QkWI1/kRG8pfsElaTt8Id+sUaPSLWqAAwD0suudNsHRVz5HRcEfjaVw0HiOg9F77
FzlXOLttgIHLMuuFiGT0WQNjptWXA28b1ivil2aMxxzBR5dojP6Sab4J8FSg==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:cc:content-type:content-type:date:date
:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=
1791384331; x=1791470731; bh=Y75WWf8X2G8eLCNDuEq0PI55alXmP1EFV7e
Znf0HdmU=; b=nXdph2+UesUAxDnjyUMhHHc8krIrHe3MEAmYt7z4PiNlpeduXxm
95870B9YYpaYcX74OiZ1Ec84qT3qc9dieEjmyOd0cP5EyhidGr8VTGoFtdKtuDOV
3yw/GSC9DGf/HYpFlVVHSKJFf99WDrOnfrjuh/wwOA5bkAHdCVsdiCOlJrkFxyQO
P2g9Lrsnsv82+7p6oZTUnp9enrvbdY+4HX/3eRQGLtrMlqIii2rMqXLE95t+WD0E
8P3RlLOm1ois8+Q3dF1x8Mrz5S9xIOUjDH01B2iTeRdnBLKus7EPIpzxHxbm6avp
Rdu0DTuzx02JVMV9A0/bD2WY9LhmpByaIqw==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox;
action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1791384331; d=pobox.com;
mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
s=fm1:rsa-sha256:YQt8iDO2BjviLFiBxXFy8MGh2L/7VMU6TsJdMECdK2YnLMY
fsR3EpthC5JFJXSJZTI7NpjipGedztIi2XY3FSqUxkwGc5EQ5Btok+TVGQmiqIui
4E43MthHakELrZ+PfynrSuz5e8vR518rU/txo7ODh8Y93g088XFIzabf3m6KRkkT
9VFR6Pvpmszi+u53U6e3cwL7cDxpu2mYj+xks14zbO3m0KuMOpK4mCwzznUi7p7G
HyrXvRvlzBUXOpCVV1q7zQRUEx/1D7aLBoOnAzpcaeSFD6kCgqdYXLPmzY18kaOa
O4Oy8LB51pce2PRBzMc4tu0ynctJ4uE+tSduUxQ==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox;
action=mi-m=1; hc=12;
hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:FWCJdYbBhloMTzTy2y7WkSqeTsD+qEGikZYsWKcuWCA=:xTokpMs9Jq7EAR7Vsx7xagMPxFq9U/kH/bmhsMn8yaw=;
X-ME-Sender: <xms:C1vGaolzCLEdw3ny-rLoFH0ctxoeK-7VrmL7q7BOEFYpMvzUtA8hzw>
<xme:C1vGavQ-hPomihIjtSjI20T8Wp7x0-fmj-yFu-_zrOH8fb5EtGlR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hX3hG-7DpSh7tkqvMUKHElU-fA>
<xmx:C1vGanKmUQVYKkCJI_2fvngB-tZjTpDsdGqJlhxqkkNwf-OTqiGgwQ>
<xmx:C1vGajSiZoWXmzdPx6O9qPqJEPepNqkBGgOsksBijmPmSHWAqeg91K1w>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed,
7 Oct 2026 10:45:31 -0400 (EDT)
X-Cc: git@vger.kernel.org
X-In-Reply-To: <20261007051734.62590-1-dilsheddilu123@gmail.com> (Muhammed
Dilshad A.'s message of "Wed, 7 Oct 2026 10:47:34 +0530")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>