From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Renaming files with git not all that bad? Date: Thu, 9 Dec 2021 16:50:01 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qxz24H2lzON4nWs3" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23497"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mathias Dahl , Emacs developers , Yuri Khan To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 09 16:51:33 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 1mvLhl-0005ww-Oo for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 16:51:33 +0100 Original-Received: from localhost ([::1]:55656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvLhk-0001ql-Bn for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Dec 2021 10:51:32 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvLgT-0000Ql-Hh for emacs-devel@gnu.org; Thu, 09 Dec 2021 10:50:13 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]:35076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvLgM-0003oH-47 for emacs-devel@gnu.org; Thu, 09 Dec 2021 10:50:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nNnqyoCAI2Zd8TtNva6YSeEEP7Ug52sZqlmjoE4HC3I=; b=hP4M3CgJi6nfj+7P13z9RIstV+ 26Hq4fpZsgeDulWSvnbGEhNm26G8OKg0YTpbyTlEr/DjS/HJKtSmJ/SjIs4IQpYlc0SXGtoN6jsG1 BsMlJqrIUFUWaescGiPth8v0ZcqJrVvSS1rADBw6IVEEtTddRntklKRykPzmVVTE6GbCvdr5Z9l7/ JI2V7HNR3JtfUkVJHpH3zVFp1VYg7dbuegNvAu1g3Y7EY9yiNx0v1AiTk8SSuPYBQejZ3QTUljg+y PaakB0rX+lRfXGSjltaYzmndHDrAeLYdVT/xs1VL0wIHLNZjmoXgAedJQ8PLS0fKaly4Fbq5wTbBH emU2C+9Q==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1mvLgH-0004lG-IQ; Thu, 09 Dec 2021 16:50:01 +0100 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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:281511 Archived-At: --qxz24H2lzON4nWs3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 09, 2021 at 03:55:34PM +0100, Stefan Kangas wrote: > Yuri Khan writes: >=20 > > There is also a trick to split a file into multiple parts where each > > part retains its history. >=20 > Thanks, I didn't know about this but will see if I can make it work > for the splitting up of image-dired.el. Based on [1], I once did: #+file: ~/bin/gitlib #+begin_src sh #!/bin/bash set -ex # FIXME sanity checks missing! # See git-sh-setup on some helpers for this if [ $# -lt 2 -o $# -gt 3 ] ; then echo "Usage: $0 orig copy [commit-message]" exit 1 fi =20 orig=3D"$1" copy=3D"$2" message=3D${3:-"split off $copy from $orig"} =20 if [ -e "$copy" ] ; then echo "$copy already exists: bailing out" exit 1 fi if [ ! -f "$orig" ] ; then echo "$orig isn't an existing file: bailing out" # FIXME might want to check that it /is/ a git file exit 1 fi =20 echo "$message" =20 git mv "$orig" "$copy" git commit -nm "$message" REV=3D$(git rev-parse HEAD) git reset --hard HEAD^ TMP=3D$(mktemp tmp-XXXXXX) # note that $TMP exists after the mktemp, thus -f git mv -f "$orig" "$TMP" git commit -nm "$message" # this fails because of conflicts: expected git merge "$REV" || true git commit -anm "$message" git mv "$TMP" "$orig" git commit -nm "$message" #+end_src This is based on two things: (1) if you happen to have a `git-foo' somewhere in your path, your git magically acquires a `foo' subcommand. (2) I have ~/bin/libgit in my PATH. It may be rough around the edges. It leaves a "smoke ring" in your history -- I didn't try to conceal that (basically, it bifurcates the repo, creating one version with the "first half" of a split and the other with the "second half" -- which actually, at this point are just copies under different names, and then merges this bifurcation): #+begin_quote * fb02315 (HEAD -> master) split-off keywords * 07fcba3 split-off keywords |\ * | fb9944d split-off keywords | * 44b4849 split-off keywords |/ * 8160976 Pass an expected failure * 86107d9 bulk-change all tests to our new test func #+end_quote After having done all of that, I somehow decided that it ain't worth the hassle and have used it very little. So please, use with care! Cheers [1] https://stackoverflow.com/questions/3887736/keep-git-history-when-split= ting-a-file/53849651#53849651 --=20 t --qxz24H2lzON4nWs3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCYbIlowAKCRAFyCz1etHa RsDmAJ92vzucoOrbtm1mqXIZsVgyyBPNiQCfXLeKAD6ffrDoTkB5QiuXzhkIfow= =TKe0 -----END PGP SIGNATURE----- --qxz24H2lzON4nWs3--