all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Stefan Kangas <stefan@marxist.se>
Cc: Mathias Dahl <mathias.dahl@gmail.com>, emacs-devel@gnu.org
Subject: Re: Renaming files with git not all that bad?
Date: Thu, 09 Dec 2021 16:56:05 +1300	[thread overview]
Message-ID: <19fed68e4cabf6148ef8f2d18e852d97@webmail.orcon.net.nz> (raw)
In-Reply-To: <CADwFkmm5XcOzA9GNCBRFsDH4dkFtnGiRYMNrvV2Zk10vEZ46Kg@mail.gmail.com>

On 2021-12-09 16:20, Stefan Kangas wrote:
> The key thing seems to be making sure to make no other changes
> than the actual moving of the file in a single commit.  This
> is to make it easy for the git heuristics to notice that the
> file was moved.

That's the right process IMO.  If ever I'm going to rename a
file which has uncommitted changes, I'll stash my changes and
introduce a separate rename commit for the original file content
before continuing, for the exact reason of maximising Git's
ability to detect it.

Git does seem fairly good at calling things a rename even if
I've forgotten to do it separately -- it seems to notice when
the old and the new are very similar, and make the assumption --
but if the old and new files are literally the same then Git
will be dealing with an identical hash for that blob; and so if
a commit is deleting a filename for that blob and also adding
a filename for the identical blob, Git doesn't have to work
very hard to decide that it's a rename!  (For the same reason
I would assume that it's also more efficient to follow renames
when they are done this way).

It should be noted that (IIRC) it isn't *default* behaviour for
Git to follow changes across renames[1], but AFAIK the "--follow"
option is the typical way to ask it to do so, and the likes of
vc and magit can ensure that this is used automatically in cases
where it's necessary.

[1] Not for all commands, at least.  Offhand I know that git
blame does follow renames by default, and there might be others.


-Phil




  reply	other threads:[~2021-12-09  3:56 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 21:50 Splitting image-dired.el into smaller files Stefan Kangas
2021-12-08 22:24 ` Stefan Monnier
2021-12-08 22:54   ` Stefan Kangas
2021-12-09  1:05 ` Lars Ingebrigtsen
2021-12-09  7:28   ` Eli Zaretskii
2021-12-09 13:58     ` Stefan Kangas
2021-12-09 14:03       ` Eli Zaretskii
2022-01-27 21:26         ` Mathias Dahl
2021-12-09  3:20 ` Renaming files with git not all that bad? Stefan Kangas
2021-12-09  3:56   ` Phil Sainty [this message]
2021-12-09  8:43     ` Andreas Schwab
2021-12-09  9:00       ` tomas
2021-12-09  9:24     ` Eli Zaretskii
2021-12-09 13:57       ` Stefan Kangas
2021-12-09  5:40   ` Yuri Khan
2021-12-09  6:02     ` Tassilo Horn
2021-12-09  6:35       ` Yuri Khan
2021-12-09  7:04         ` Tassilo Horn
2021-12-09  7:28           ` Yuri Khan
2021-12-09 22:03         ` Stefan Kangas
2021-12-10 12:28           ` Tassilo Horn
2021-12-11 12:11           ` Yuri Khan
2021-12-09 14:55     ` Stefan Kangas
2021-12-09 15:50       ` tomas
2021-12-09 22:18         ` Stefan Kangas
2021-12-10  8:17           ` tomas
2022-08-21  0:56 ` Splitting image-dired.el into smaller files Stefan Kangas
2022-08-21  5:50   ` Eli Zaretskii
2022-08-21 14:32     ` Stefan Kangas
2022-08-21 14:35       ` Eli Zaretskii
2022-08-21 15:11         ` Stefan Kangas
2022-08-21 15:16           ` Lars Ingebrigtsen
2022-08-21 15:20           ` Eli Zaretskii
2022-08-21 15:22             ` Lars Ingebrigtsen
2022-08-21 17:02             ` Stefan Monnier
2022-08-23 19:02             ` Stefan Kangas
2022-08-23 19:09               ` Eli Zaretskii
2022-08-23 19:53                 ` Stefan Kangas
2022-08-21 16:20   ` Juri Linkov
2022-08-22 13:08     ` Stefan Kangas
2022-08-22 15:18       ` Eli Zaretskii

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=19fed68e4cabf6148ef8f2d18e852d97@webmail.orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=emacs-devel@gnu.org \
    --cc=mathias.dahl@gmail.com \
    --cc=stefan@marxist.se \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.