{"thread":{"id":"6829","subject":"[PATCH] Dissociating a repository from its alternates","startedAt":"2007-02-15T07:51:13Z","lastAt":"2007-10-23T00:13:31Z","messageCount":9,"participants":["Junio C Hamano","Johannes Schindelin","James Cloos","Michael Hendricks"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"34680","messageId":"7vabzfhn9q.fsf@assigned-by-dhcp.cox.net","threadId":"6829","inReplyTo":null,"subject":"[PATCH] Dissociating a repository from its alternates","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T07:51:13Z","receivedAt":"2007-02-15T07:51:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"People often start out with \"clone -l -s\" (or --reference) and\nlater wish to dissociate the repository from its alternates.\nThe new option -A to \"git repack\" lets you do so.\n\nWhat it does:\n\n - git-pack-objects gets a new option --ignore-alternate-pack.\n   The command used in git-repack is told to pack only unpacked\n   objects in general, but also is told to pretend objects in\n   packs in the local repository are unpacked (this is necessary\n   to keep historical huge packs marked with .keep files without\n   repacking).  This new option tells it to also pretend that\n   objects from packs in alternate repositories are unpacked, to\n   make them subject to packing.\n\n - code to parse revision traversal options gets an additional\n   bit, ignore_alternate_pack.\n\n - has_sha1_pack() function gets an additional argument for that\n   bit.  Existing callers pass 0 to it (they continue to behave\n   as before).\n\n - git-repack obviously understands the new -A option.  When it\n   is given, it passes --ignore-alternate-pack option to\n   git-pack-objects to include objects from borrowed packs in\n   the result, and $GIT_OBJECT_DIRECTORY/info/alternates file is\n   removed at the end.\n\nThe patch was tested very lightly, and I haven't verified the\ninteractions between various options git-repack takes, and\noptions it passes to git-pack-objects (especially, I think\ninteraction with --local and --incremental might be dubious).\n\nBecause a bug in git-repack has real risk of corrupting\nrepository in a bad way, somebody else needs to double check\nthis patch, if we were to do this.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n builtin-count-objects.c |    2 +-\n builtin-pack-objects.c  |    1 +\n builtin-prune-packed.c  |    2 +-\n cache.h                 |    2 +-\n diff.c                  |    2 +-\n git-repack.sh           |   30 ++++++++++++++++++++++--------\n revision.c              |   12 +++++++++---\n revision.h              |    1 +\n sha1_file.c             |   16 +++++++++-------\n 9 files changed, 46 insertions(+), 22 deletions(-)\n\ndiff --git a/builtin-count-objects.c b/builtin-count-objects.c\nindex f5b22bb..10c8860 100644\n--- a/builtin-count-objects.c\n+++ b/builtin-count-objects.c\n@@ -62,7 +62,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,\n \t\thex[40] = 0;\n \t\tif (get_sha1_hex(hex, sha1))\n \t\t\tdie(\"internal error\");\n-\t\tif (has_sha1_pack(sha1, NULL))\n+\t\tif (has_sha1_pack(sha1, NULL, 0))\n \t\t\t(*packed_loose)++;\n \t}\n }\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 3824ee3..0f5d72c 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1623,6 +1623,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!strcmp(\"--unpacked\", arg) ||\n \t\t    !strncmp(\"--unpacked=\", arg, 11) ||\n+\t\t    !strcmp(\"--ignore-alternate-pack\", arg) ||\n \t\t    !strcmp(\"--reflog\", arg) ||\n \t\t    !strcmp(\"--all\", arg)) {\n \t\t\tuse_internal_rev_list = 1;\ndiff --git a/builtin-prune-packed.c b/builtin-prune-packed.c\nindex 9777300..eb55c58 100644\n--- a/builtin-prune-packed.c\n+++ b/builtin-prune-packed.c\n@@ -20,7 +20,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)\n \t\tmemcpy(hex+2, de->d_name, 38);\n \t\tif (get_sha1_hex(hex, sha1))\n \t\t\tcontinue;\n-\t\tif (!has_sha1_pack(sha1, NULL))\n+\t\tif (!has_sha1_pack(sha1, NULL, 0))\n \t\t\tcontinue;\n \t\tmemcpy(pathname + len, de->d_name, 38);\n \t\tif (opts & DRY_RUN)\ndiff --git a/cache.h b/cache.h\nindex c62b0b0..0c24318 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -266,7 +266,7 @@ extern int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,\n extern int write_sha1_to_fd(int fd, const unsigned char *sha1);\n extern int move_temp_to_file(const char *tmpfile, const char *filename);\n \n-extern int has_sha1_pack(const unsigned char *sha1, const char **ignore);\n+extern int has_sha1_pack(const unsigned char *sha1, const char **ignore, int ignore_alternates);\n extern int has_sha1_file(const unsigned char *sha1);\n extern void *map_sha1_file(const unsigned char *sha1, unsigned long *);\n extern int legacy_loose_object(unsigned char *);\ndiff --git a/diff.c b/diff.c\nindex 12c8b2b..ee46960 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1254,7 +1254,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t * objects however would tend to be slower as they need\n \t * to be individually opened and inflated.\n \t */\n-\tif (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))\n+\tif (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL, 0))\n \t\treturn 0;\n \n \tlen = strlen(name);\ndiff --git a/git-repack.sh b/git-repack.sh\nindex ddfa8b4..774286e 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -3,17 +3,18 @@\n # Copyright (c) 2005 Linus Torvalds\n #\n \n-USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'\n+USAGE='[-a] [-A] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n-no_update_info= all_into_one= remove_redundant=\n+no_update_info= all_into_one= remove_redundant= nuke_alternates=\n local= quiet= no_reuse_delta= extra=\n while case \"$#\" in 0) break ;; esac\n do\n \tcase \"$1\" in\n \t-n)\tno_update_info=t ;;\n \t-a)\tall_into_one=t ;;\n+\t-A)\tnuke_alternates=t ;;\n \t-d)\tremove_redundant=t ;;\n \t-q)\tquiet=-q ;;\n \t-f)\tno_reuse_delta=--no-reuse-delta ;;\n@@ -28,8 +29,7 @@ done\n # Later we will default repack.UseDeltaBaseOffset to true\n default_dbo=false\n \n-case \"`git config --bool repack.usedeltabaseoffset ||\n-       echo $default_dbo`\" in\n+case \"`git config --bool repack.usedeltabaseoffset || echo $default_dbo`\" in\n true)\n \textra=\"$extra --delta-base-offset\" ;;\n esac\n@@ -40,11 +40,14 @@ rm -f \"$PACKTMP\"-*\n trap 'rm -f \"$PACKTMP\"-*' 0 1 2 3 15\n \n # There will be more repacking strategies to come...\n-case \",$all_into_one,\" in\n-,,)\n+case \",$all_into_one,$nuke_alternates,\" in\n+,,,)\n \targs='--unpacked --incremental'\n \t;;\n-,t,)\n+,,t,)\n+\targs='--incremental --ignore-alternate-pack'\n+\t;;\n+,t,*)\n \tif [ -d \"$PACKDIR\" ]; then\n \t\tfor e in `cd \"$PACKDIR\" && find . -type f -name '*.pack' \\\n \t\t\t| sed -e 's/^\\.\\///' -e 's/\\.pack$//'`\n@@ -57,7 +60,12 @@ case \",$all_into_one,\" in\n \t\t\tfi\n \t\tdone\n \tfi\n-\t[ -z \"$args\" ] && args='--unpacked --incremental'\n+\tcase \"$nuke_alternates\" in\n+\t'')\n+\t\t[ -z \"$args\" ] && args='--unpacked --incremental' ;;\n+\tt)\n+\t\targs=\"$args --ignore-alternate-pack\" ;;\n+\tesac\n \t;;\n esac\n \n@@ -113,6 +121,12 @@ then\n \tgit-prune-packed $quiet\n fi\n \n+case \"$nuke_alternates\" in\n+t)\n+\trm -f \"$GIT_OBJECT_DIRECTORY/info/alternates\"\n+\t;;\n+esac\n+\n case \"$no_update_info\" in\n t) : ;;\n *) git-update-server-info ;;\ndiff --git a/revision.c b/revision.c\nindex 5b1794b..b9e33c3 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -949,6 +949,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\tadd_ignore_packed(revs, arg+11);\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--ignore-alternate-pack\")) {\n+\t\t\t\trevs->ignore_alternate_pack = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"-r\")) {\n \t\t\t\trevs->diff = 1;\n \t\t\t\trevs->diffopt.recursive = 1;\n@@ -1240,9 +1244,11 @@ static struct commit *get_revision_1(struct rev_info *revs)\n \t\tif (commit->object.flags & SHOWN)\n \t\t\tcontinue;\n \n-\t\tif (revs->unpacked && has_sha1_pack(commit->object.sha1,\n-\t\t\t\t\t\t    revs->ignore_packed))\n-\t\t    continue;\n+\t\tif ((revs->unpacked || revs->ignore_alternate_pack) &&\n+\t\t    has_sha1_pack(commit->object.sha1,\n+\t\t\t\t  revs->ignore_packed,\n+\t\t\t\t  revs->ignore_alternate_pack))\n+\t\t\tcontinue;\n \n \t\t/* We want to show boundary commits only when their\n \t\t * children are shown.  When path-limiter is in effect,\ndiff --git a/revision.h b/revision.h\nindex 5fec184..ca6affd 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -40,6 +40,7 @@ struct rev_info {\n \t\t\tedge_hint:1,\n \t\t\tlimited:1,\n \t\t\tunpacked:1, /* see also ignore_packed below */\n+\t\t\tignore_alternate_pack:1,\n \t\t\tboundary:1,\n \t\t\tleft_right:1,\n \t\t\tparents:1,\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b83f59f..2d8c0f2 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1403,7 +1403,7 @@ static int matches_pack_name(struct packed_git *p, const char *ig)\n \treturn 1;\n }\n \n-static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)\n+static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed, int ignore_alternates)\n {\n \tstruct packed_git *p;\n \tunsigned long offset;\n@@ -1419,6 +1419,8 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons\n \t\t\tif (*ig)\n \t\t\t\tcontinue;\n \t\t}\n+\t\tif (ignore_alternates && !p->pack_local)\n+\t\t\tcontinue;\n \t\toffset = find_pack_entry_one(sha1, p);\n \t\tif (offset) {\n \t\t\t/*\n@@ -1485,9 +1487,9 @@ int sha1_object_info(const unsigned char *sha1, char *type, unsigned long *sizep\n {\n \tstruct pack_entry e;\n \n-\tif (!find_pack_entry(sha1, &e, NULL)) {\n+\tif (!find_pack_entry(sha1, &e, NULL, 0)) {\n \t\treprepare_packed_git();\n-\t\tif (!find_pack_entry(sha1, &e, NULL))\n+\t\tif (!find_pack_entry(sha1, &e, NULL, 0))\n \t\t\treturn sha1_loose_object_info(sha1, type, sizep);\n \t}\n \treturn packed_object_info(e.p, e.offset, type, sizep);\n@@ -1497,7 +1499,7 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo\n {\n \tstruct pack_entry e;\n \n-\tif (!find_pack_entry(sha1, &e, NULL))\n+\tif (!find_pack_entry(sha1, &e, NULL, 0))\n \t\treturn NULL;\n \telse\n \t\treturn unpack_entry(e.p, e.offset, type, size);\n@@ -2004,10 +2006,10 @@ int has_pack_file(const unsigned char *sha1)\n \treturn 1;\n }\n \n-int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed)\n+int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed, int ignore_alternates)\n {\n \tstruct pack_entry e;\n-\treturn find_pack_entry(sha1, &e, ignore_packed);\n+\treturn find_pack_entry(sha1, &e, ignore_packed, ignore_alternates);\n }\n \n int has_sha1_file(const unsigned char *sha1)\n@@ -2015,7 +2017,7 @@ int has_sha1_file(const unsigned char *sha1)\n \tstruct stat st;\n \tstruct pack_entry e;\n \n-\tif (find_pack_entry(sha1, &e, NULL))\n+\tif (find_pack_entry(sha1, &e, NULL, 0))\n \t\treturn 1;\n \treturn find_sha1_file(sha1, &st) ? 1 : 0;\n }\n"},{"id":"34684","messageId":"7vsld7g3sz.fsf@assigned-by-dhcp.cox.net","threadId":"6829","inReplyTo":"7vabzfhn9q.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH +1] Dissociating a repository from its alternates","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T09:37:00Z","receivedAt":"2007-02-15T09:37:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On top of the previous patch.  This is needed to:\n\n - reject \"repack -A -l\", which does not make any sense; you\n   want to repack the objects you borrow from the alternates.\n\n - make \"repack -A\" without \"-a\" to work.\n\nThese operations corrupted the repository with the previous\npatch alone.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n git-repack.sh |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 774286e..66b5039 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -25,6 +25,10 @@ do\n \tesac\n \tshift\n done\n+if test \"$nuke_alternates,$local\" = \"t,--local\"\n+then\n+\tdie \"-A and -l are incompatible\"\n+fi\n \n # Later we will default repack.UseDeltaBaseOffset to true\n default_dbo=false\n@@ -45,7 +49,7 @@ case \",$all_into_one,$nuke_alternates,\" in\n \targs='--unpacked --incremental'\n \t;;\n ,,t,)\n-\targs='--incremental --ignore-alternate-pack'\n+\targs='--ignore-alternate-pack'\n \t;;\n ,t,*)\n \tif [ -d \"$PACKDIR\" ]; then\n"},{"id":"34715","messageId":"Pine.LNX.4.63.0702151638130.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6829","inReplyTo":"7vabzfhn9q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-15T15:39:44Z","receivedAt":"2007-02-15T15:39:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> People often start out with \"clone -l -s\" (or --reference) and\n> later wish to dissociate the repository from its alternates.\n\nWhy not make a really dumb script which just _copies_ (or maybe \noptionally hard link) the objects from the alternate repo, and then kills \nthe alternatives file? That should be easier. You always can repack after \nthat.\n\nCiao,\nDscho\n"},{"id":"34824","messageId":"m3wt2h3ojt.fsf@lugabout.jhcloos.org","threadId":"6829","inReplyTo":"7vabzfhn9q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"James Cloos","fromEmail":"cloos@jhcloos.com","sentAt":"2007-02-16T19:11:27Z","receivedAt":"2007-02-16T19:11:27Z","isPatch":true,"sender":{"key":"cloos@jhcloos.com","avatar":"https://gravatar.com/avatar/ec9a05787d29afe41e243e4b60bd0e2f69d757688e8f0bfe5e78bc185a3e317f?d=mp&s=160"},"body":"[ARGH; hit r rather than f; cc-ing the list. -JimC]\n\nWierd.\n\nI was /just/ about to inquire on what the best method was for disassociating.\n\nAnd then I read this thread.\n\nEffective mind reading!  :)\n\nWRT Johannes's followup, I presume it will re-use the alternate packs,\nsuch that the computation is minimal?\n\n-JimC\n-- \nJames Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6\n"},{"id":"34828","messageId":"7v8xex50aa.fsf@assigned-by-dhcp.cox.net","threadId":"6829","inReplyTo":"Pine.LNX.4.63.0702151638130.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-16T20:13:01Z","receivedAt":"2007-02-16T20:13:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 14 Feb 2007, Junio C Hamano wrote:\n>\n>> People often start out with \"clone -l -s\" (or --reference) and\n>> later wish to dissociate the repository from its alternates.\n>\n> Why not make a really dumb script which just _copies_ (or maybe \n> optionally hard link) the objects from the alternate repo, and then kills \n> the alternatives file? That should be easier. You always can repack after \n> that.\n\nI think that is much safer.\n"},{"id":"56902","messageId":"20071022180424.GA17429@ginosko.local","threadId":"6829","inReplyTo":"7v8xex50aa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2007-10-22T18:04:28Z","receivedAt":"2007-10-22T18:04:28Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"On Fri, Feb 16, 2007 at 12:13:01PM -0800, Junio C Hamano wrote:\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Wed, 14 Feb 2007, Junio C Hamano wrote:\n> >\n> >> People often start out with \"clone -l -s\" (or --reference) and\n> >> later wish to dissociate the repository from its alternates.\n> >\n> > Why not make a really dumb script which just _copies_ (or maybe \n> > optionally hard link) the objects from the alternate repo, and then kills \n> > the alternatives file? That should be easier. You always can repack after \n> > that.\n> \n> I think that is much safer.\n\nWas such a script ever incorporated into Git?\n\n-- \nMichael\n"},{"id":"56905","messageId":"Pine.LNX.4.64.0710221957360.25221@racer.site","threadId":"6829","inReplyTo":"20071022180424.GA17429@ginosko.local","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-22T19:05:58Z","receivedAt":"2007-10-22T19:05:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Oct 2007, Michael Hendricks wrote:\n\n> On Fri, Feb 16, 2007 at 12:13:01PM -0800, Junio C Hamano wrote:\n> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> > \n> > > On Wed, 14 Feb 2007, Junio C Hamano wrote:\n> > >\n> > >> People often start out with \"clone -l -s\" (or --reference) and\n> > >> later wish to dissociate the repository from its alternates.\n> > >\n> > > Why not make a really dumb script which just _copies_ (or maybe \n> > > optionally hard link) the objects from the alternate repo, and then kills \n> > > the alternatives file? That should be easier. You always can repack after \n> > > that.\n> > \n> > I think that is much safer.\n> \n> Was such a script ever incorporated into Git?\n\nNot that I know of, but \"git repack -a && rm .git/objects/info/alternates\" \nshould do what you want.  You can even make a script of it, add some \ndocumentation and a test case, and earn git fame by posting a patch ;-)\n\nCiao,\nDscho\n"},{"id":"56926","messageId":"20071022233050.GA18430@ginosko.ndrix.org","threadId":"6829","inReplyTo":"Pine.LNX.4.64.0710221957360.25221@racer.site","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2007-10-22T23:30:51Z","receivedAt":"2007-10-22T23:30:51Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"On Mon, Oct 22, 2007 at 08:05:58PM +0100, Johannes Schindelin wrote:\n> On Mon, 22 Oct 2007, Michael Hendricks wrote:\n> > Was such a script ever incorporated into Git?\n> \n> Not that I know of, but \"git repack -a && rm\n> .git/objects/info/alternates\" should do what you want.  You can even\n> make a script of it, add some documentation and a test case, and earn\n> git fame by posting a patch ;-)\n\nWith 1.5.3.4, it doesn't appear to work:\n\n $ git clone -s git git2\n Initialized empty Git repository in /Users/michael/src/git2/.git/\n\n $ cd git2\n\n $ git repack -a && rm .git/objects/info/alternates\n Generating pack...\n Done counting 0 objects.\n Nothing new to pack.\n\n $ git status\n # On branch master\n fatal: bad object HEAD\n\n-- \nMichael\n"},{"id":"56931","messageId":"Pine.LNX.4.64.0710230112131.25221@racer.site","threadId":"6829","inReplyTo":"20071022233050.GA18430@ginosko.ndrix.org","subject":"Re: [PATCH] Dissociating a repository from its alternates","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-23T00:13:31Z","receivedAt":"2007-10-23T00:13:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Oct 2007, Michael Hendricks wrote:\n\n> On Mon, Oct 22, 2007 at 08:05:58PM +0100, Johannes Schindelin wrote:\n> > On Mon, 22 Oct 2007, Michael Hendricks wrote:\n> > > Was such a script ever incorporated into Git?\n> > \n> > Not that I know of, but \"git repack -a && rm\n> > .git/objects/info/alternates\" should do what you want.  You can even\n> > make a script of it, add some documentation and a test case, and earn\n> > git fame by posting a patch ;-)\n> \n> With 1.5.3.4, it doesn't appear to work:\n> \n>  $ git clone -s git git2\n>  Initialized empty Git repository in /Users/michael/src/git2/.git/\n> \n>  $ cd git2\n> \n>  $ git repack -a && rm .git/objects/info/alternates\n>  Generating pack...\n>  Done counting 0 objects.\n>  Nothing new to pack.\n> \n>  $ git status\n>  # On branch master\n>  fatal: bad object HEAD\n\nIndeed.  Seems that somewhere along the line, repack learnt to imply \"-l\" \nby \"-a\" or something.  Try this instead of \"git repack -a\":\n\n\tgit rev-parse --all |\n\t\tgit pack-objects --revs .git/objects/pack/pack\n\n(And make sure you read the relevant parts of the documentation to \nunderstand what you're doing ;-)\n\nHth,\nDscho\n"}]}