From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.devel Subject: Re: Renaming files with git not all that =?UTF-8?Q?bad=3F?= Date: Thu, 09 Dec 2021 16:56:05 +1300 Message-ID: <19fed68e4cabf6148ef8f2d18e852d97@webmail.orcon.net.nz> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17784"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: Mathias Dahl , emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 09 04:57:18 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvAYX-0004SM-4P for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 04:57:17 +0100 Original-Received: from localhost ([::1]:41168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvAYV-0007zQ-Sq for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Dec 2021 22:57:15 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvAXh-0007Cu-Ee for emacs-devel@gnu.org; Wed, 08 Dec 2021 22:56:25 -0500 Original-Received: from smtp-2.orcon.net.nz ([60.234.4.43]:40901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvAXW-0007DH-2D for emacs-devel@gnu.org; Wed, 08 Dec 2021 22:56:25 -0500 Original-Received: from [10.253.37.70] (port=39237 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1mvAXN-0002MF-Qy; Thu, 09 Dec 2021 16:56:06 +1300 Original-Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Thu, 09 Dec 2021 16:56:05 +1300 In-Reply-To: X-Sender: psainty@orcon.net.nz X-GeoIP: -- Received-SPF: pass client-ip=60.234.4.43; envelope-from=psainty@orcon.net.nz; helo=smtp-2.orcon.net.nz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:281429 Archived-At: 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