Add git-relink-script to fix up missing hardlinks
PATCH 1/1 Add git-relink-script to fix up missing hardlinks
Add git-relink-script
This will scan 2 or more object repositories and look for common objects, check if they are hardlinked, and replace one with a hardlink to the other if not.
This version warns when skipping files because of size differences, and handle more than 2 repositories automatically.
Makefile +1 -1
@@ -25,7 +25,7 @@ SCRIPTS=git git-apply-patch-script git-m git-deltafy-script git-fetch-script git-status-script git-commit-script \ git-log-script git-shortlog git-cvsimport-script git-diff-script \ git-reset-script git-add-script git-checkout-script git-clone-script \ - gitk git-cherry git-rebase-script + gitk git-cherry git-rebase-script git-relink-script PROG= git-update-cache git-diff-files git-init-db git-write-tree \ git-read-tree git-commit-tree git-cat-file git-fsck-cache \
git-relink-script new file +173 -0
173 lines not on this page · raw message
Signature · 2 lines
Ryan Anderson sometimes Pug Majere
Quoted 9 lines · Ryan Anderson
Add git-relink-script
This will scan 2 or more object repositories and look for common objects, check if they are hardlinked, and replace one with a hardlink to the other if not.
This version warns when skipping files because of size differences, and handle more than 2 repositories automatically.
Signed-off-by Ryan Anderson <[email protected]>
Thanks for posting this.
Not that I think it matters that much anymore since I am proposing removal of "delta" support and Linus seems to be inclined in the same direction, but I said "most of the time" in the earlier message on this same topic for a reason:
Message-ID: <[email protected]>
Subject: Re: RFE: git relink
Date: Fri, 10 Jun 2005 20:44:01 -0700
References: <[email protected]>
Whoever is doing this script needs to be a bit careful.
...
Ryan Anderson code will notice delta vs full object case most of the time because it checks and makes sure the sizes of corresponding files from two repositories match. The problem with the code is that it dies, instead of just ignoring, when size differs....
Your latest version has an option not to die which is very good [*1*], but in a very narrow corner case, without comparing the file contents, I think the code would still do a wrong thing. Two trees can store the same object both in delitified form but based on different base objects, and the deltified representation still having the same length, no? And I suspect you would end up linking them together, corrupting one of the trees.
Of course, even when you do not have "delta", if an object in one tree is corrupted (but has the correct size), you would end up relinking the corrupt one into another tree, nuking a good copy, if you do not compare the file contents.
If/when/after the proposed removal of "delta" support happens, I think the correct way to do git-relink-script would be to keep most of your latest version intact, except:
(1) make it always die when you see differences in size. Without "delta" in the repository, SHA1 files that represent the same object must have the same size.
(2) make --safe also check on file contents. You do not need the flag for the "delta" reason anymore, so I am suggesting reusing the flag to detect file corruption, to be extra safe, when the user permits you to spend cycles to be more careful.
[Footnote]
*1* and other parts of the script all look nicely done.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"JCH" == Junio C Hamano <[email protected]> writes:
JCH> Your latest version has an option not to die which is very JCH> good, but in a very narrow corner case, without comparing JCH> the file contents, I think the code would still do a wrong JCH> thing.
Having said that, the corner case is narrow enough (and hopefully to be gone soon) that I think the current version is perfectly acceptable for inclusion.
Linus, please apply. What it does is useful to encourage the "one topic, one tree" use pattern, the officially recommended way IIUC.
I am a bit puzzled, though, why Jeff was the original requestor for this feature --- I thought he handles 50 heads in one repository which means there is no multiple repositories to relink across.
Quoted 4 lines · Junio C Hamano
I am a bit puzzled, though, why Jeff was the original requestor for this feature --- I thought he handles 50 heads in one repository which means there is no multiple repositories to relink across.
Sure there are. Just watching my submissions on the mailing list, you can see ones mentioned such as "misc-2.6", "libata-dev", "netdev-2.6", etc.:
[jgarzik@pretzel repo]$ ls -FC
config-2.4 ethtool/ libata-dev/ netdev-2.6/ sparse/ config-2.6 git/ linux-2.6/ old-SCM/ config-2.6-uml git-tools/ misc-2.6/ scsi-misc-2.6/
And I always keep an unmodified 'vanilla' tree from which everything is sourced (and hardlinked to).
It's a categorization system, a namespace. Top-level repositories are broad categories, and branches sub-divide those categories.
Jeff
Quoted 6 lines · Jeff Garzik
Quoted 4 lines · Junio C Hamano
I am a bit puzzled, though, why Jeff was the original requestor for this feature --- I thought he handles 50 heads in one repository which means there is no multiple repositories to relink across.
Quoted 7 lines
Sure there are. Just watching my submissions on the mailing list, you can see ones mentioned such as "misc-2.6", "libata-dev", "netdev-2.6", etc.:
[jgarzik@pretzel repo]$ ls -FC
config-2.4 ethtool/ libata-dev/ netdev-2.6/ sparse/ config-2.6 git/ linux-2.6/ old-SCM/ config-2.6-uml git-tools/ misc-2.6/ scsi-misc-2.6/
I actually have been using subdirectories in refs/heads with quite a bit of success. All of the core tools have no problem with them and only gitweb and gitk need some small changes to show them correctly.
The subdirectories in refs/heads are user specific in my case, this end up being pretty useful when combined with Coda's directory ACLs, each user can maintain their own branches, but cannot modify anyone elses. All developers have insert, read and lookup rights on the main objects repository, they can add new objects, but not remove or overwrite any existing ones.
My branch names end up looking something like 'jaharkes/wdonly', 'awolbach/expand', etc. and it works like a charm.
Jan