From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Renaming files with git not all that bad? Date: Wed, 8 Dec 2021 19:20:26 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17661"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mathias Dahl To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 09 04:21:04 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 1mv9zU-0004Rb-Mk for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 04:21:04 +0100 Original-Received: from localhost ([::1]:33892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv9zS-00017l-PB for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Dec 2021 22:21:02 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv9yv-0000Mo-L9 for emacs-devel@gnu.org; Wed, 08 Dec 2021 22:20:29 -0500 Original-Received: from mail-pj1-f52.google.com ([209.85.216.52]:54013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv9yt-00031q-Sm for emacs-devel@gnu.org; Wed, 08 Dec 2021 22:20:29 -0500 Original-Received: by mail-pj1-f52.google.com with SMTP id iq11so3396266pjb.3 for ; Wed, 08 Dec 2021 19:20:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=rvapb7eUiXFoOh/seMQrlJ3ToYbCOcjMt+xrPQXhlS4=; b=a3hPs9HxSm9wyt29fuXbIi6vcyw5fIUYU16FyQwp6fPWKvDGQ1iSfqmEQQPwq7c1rv n7UOC85vSWTNhOfmzD3Z/g0ShlBIN/swCEyyWFhvdVmqVDjc9XEtP9TkZT5uaWJ4IiSj Mv0P/YqdWEAp4YEIS/gInW0BRCaEZLOOUouleZHOlMEZ0PAj2vsctuHacBIx5BMtNvn8 KghEAEDFy1kqK0Brf7SzkP/4pQV6vS0zaE1Q3KFNVgh2jCPAV1S0p/F194Mq1/u9eLZG N8PabjZjU9b8+YbackYSGkbLGWJDSKvB9fYcz6YkUKY3cxQXPdP6/RnuvtIYkXsWamlt 20mQ== X-Gm-Message-State: AOAM5329LieBXmNt/4UIYsvxu/5vfyLuxhJ4gFM37nkQ9kOTulblNFQm +HXKGsfk2zZb0xG6PdgJgT0bCBSjRKFNLXLCMRfSnPpE X-Google-Smtp-Source: ABdhPJxOKVi5MD1Sd8yDV+99tJRBB1EQXD3kuGJHhwRMTTUWODVB+06/CBdtM3i6jWAsbvMhD2Er+hvSWXJRJVvulLo= X-Received: by 2002:a17:90b:1e0e:: with SMTP id pg14mr12189491pjb.143.1639020026627; Wed, 08 Dec 2021 19:20:26 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 8 Dec 2021 19:20:26 -0800 In-Reply-To: Received-SPF: pass client-ip=209.85.216.52; envelope-from=stefankangas@gmail.com; helo=mail-pj1-f52.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:281428 Archived-At: Stefan Kangas writes: > The big drawback here is that we will lose the git history. I tested this just now, and unless I'm missing something, a rename actually doesn't have to be all that bad. It turns out that vc-annotate, magit-blame and vc-region-history have little trouble handling a rename if its done properly. In any case, I made a commit containing no other changes than git mv lisp/image-dired.el lisp/image and in the new file, I get history and blame in the new file all the way back to 2007, when the file was last renamed. Even vc-print-log works, but I first have to say (setq vc-git-print-log-follow t) though that option is not without its caveats (it skips merge commits). (See the comment in vc-git.el.) 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. And then most of the stuff we care about will work seamlessly, or nearly seamlessly as seems to be the case with vc-print-log. It looks like CONTRIBUTE already has the necessary advice here (though I have no idea why it's talking about creating a feature branch, which doesn't seem necessary). I'm not sure if this is new to anyone else than me, but I was positively surprised with how well git handled this. I'm not sure if I just never figured out to do this properly, if git got better, or what.