git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nathan Faulkner <natedogith1@gmail.com>
Cc: Ed Avis <ed.avis@qmaw.com>,
	 Philip Oakley <philipoakley@iee.email>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re*: git log --name-only improvement: show old file name in rename
Date: Fri, 17 May 2024 09:00:29 -0700	[thread overview]
Message-ID: <xmqqv83cl97m.fsf_-_@gitster.g> (raw)
In-Reply-To: <c239ab15-4d48-4328-8bd5-8e2d77163e03@gmail.com> (Nathan Faulkner's message of "Thu, 16 May 2024 19:13:34 -0400")

Nathan Faulkner <natedogith1@gmail.com> writes:

> The documentation for --name-only says "Show only names of changed
> files." I would interpret this to mean "output the names of all files
> that changed", not "output the names of all files that changed, unless
> git detected it as renamed".

Interesting observation, but we do show renamed files no?  Even when
there is no content changes?  A quick experiment tells me it does,
so "unless" is not quite correct.

    $ git mv COPYING RENAMING
    $ git diff --name-only -M HEAD
    RENAMING
    $ git diff --name-status -M HEAD
    R100	COPYING	RENAMING

I think that the source of the confusion is actually not renames or
copies but that the explanation does not say in which commit the
phrase "only names of changed files" applies to.

The answer to that question is: Show names of the changed paths in
the post-image tree, i.e. if comparing 'diff A B' (or when 'show B'
is comparing 'diff B^ B'), the names in tree B are shown.

But because that is not explicitly said, a reader can easily mislead
into thinking that we are showing the union of names of files in
both pre-image and post-image trees that were modified.

We'd need something like this, probably.

------- >8 ------------- >8 ------------- >8 -------
Subject: diff: document what --name-only shows

The "--name-only" option is about showing the name of each file in
the post-image tree that got changed and nothing else (like "was it
created?").  Unlike the "--name-status" option that tells how the
change happened (e.g., renamed with similarity), it does not give
anything else, like the name of the corresponding file in the old
tree.

Lack of the description of this fact has confused readers in the
past.  Even back when dda2d79a ([PATCH] Clean up diff option
descriptions., 2005-07-13) documented "--name-only", "git diff"
already supported the renames, so in a sense, from day one, this
should have been documented more clearly but it wasn't.

Belatedly clarify it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/diff-options.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git c/Documentation/diff-options.txt w/Documentation/diff-options.txt
index 0e9456957e..b9eaea32d9 100644
--- c/Documentation/diff-options.txt
+++ w/Documentation/diff-options.txt
@@ -329,7 +329,8 @@ explained for the configuration variable `core.quotePath` (see
 linkgit:git-config[1]).
 
 --name-only::
-	Show only names of changed files. The file names are often encoded in UTF-8.
+	Show only the name in the before-tree of changed files.
+	The file names are often encoded in UTF-8.
 	For more information see the discussion about encoding in the linkgit:git-log[1]
 	manual page.
 

  reply	other threads:[~2024-05-17 16:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 11:19 git log --name-only improvement: show old file name in rename Ed Avis
2020-06-11 23:16 ` Junio C Hamano
2020-06-12 14:18   ` Philip Oakley
2020-06-12 17:03     ` Junio C Hamano
2020-06-15  7:36       ` Ed Avis
2024-05-16 23:13         ` Nathan Faulkner
2024-05-17 16:00           ` Junio C Hamano [this message]
2024-05-18  0:24             ` Re*: " Nathan Faulkner
2024-05-18  2:05               ` Junio C Hamano

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=xmqqv83cl97m.fsf_-_@gitster.g \
    --to=gitster@pobox.com \
    --cc=ed.avis@qmaw.com \
    --cc=git@vger.kernel.org \
    --cc=natedogith1@gmail.com \
    --cc=philipoakley@iee.email \
    /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).