{"thread":{"id":"4093","subject":"[PATCH] clone: keep --reference even with -l -s","startedAt":"2006-05-07T18:19:09Z","lastAt":"2006-05-07T18:19:09Z","messageCount":1,"participants":["Martin Waitz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"19656","messageId":"20060507181909.GB23738@admingilde.org","threadId":"4093","inReplyTo":null,"subject":"[PATCH] clone: keep --reference even with -l -s","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-05-07T18:19:09Z","receivedAt":"2006-05-07T18:19:09Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"Both -l -s and --reference update objects/info/alternates and used\nto write over each other.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n\n---\n\n git-clone.sh               |    2 +\n t/t5700-clone-reference.sh |   78 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 79 insertions(+), 1 deletions(-)\n create mode 100755 t/t5700-clone-reference.sh\n\n3410837e34357d43a38a170691ca45f8f3a82221\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 0805168..b785247 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -265,7 +265,7 @@ yes,yes)\n \t\ttest -f \"$repo/objects/info/alternates\" &&\n \t\tcat \"$repo/objects/info/alternates\";\n \t\techo \"$repo/objects\"\n-\t    } >\"$GIT_DIR/objects/info/alternates\"\n+\t    } >>\"$GIT_DIR/objects/info/alternates\"\n \t    ;;\n \tesac\n \tgit-ls-remote \"$repo\" >\"$GIT_DIR/CLONE_HEAD\"\ndiff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh\nnew file mode 100755\nindex 0000000..916ee15\n--- /dev/null\n+++ b/t/t5700-clone-reference.sh\n@@ -0,0 +1,78 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>\n+#\n+\n+test_description='test clone --reference'\n+. ./test-lib.sh\n+\n+base_dir=`pwd`\n+\n+test_expect_success 'preparing first repository' \\\n+'test_create_repo A && cd A &&\n+echo first > file1 &&\n+git add file1 &&\n+git commit -m initial'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'preparing second repository' \\\n+'git clone A B && cd B &&\n+echo second > file2 &&\n+git add file2 &&\n+git commit -m addition &&\n+git repack -a -d &&\n+git prune'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'cloning with reference' \\\n+'git clone -l -s --reference B A C'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'existance of info/alternates' \\\n+'test `wc -l <C/.git/objects/info/alternates` = 2'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'pulling from reference' \\\n+'cd C &&\n+git pull ../B'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'that reference gets used' \\\n+'cd C &&\n+echo \"0 objects, 0 kilobytes\" > expected &&\n+git count-objects > current &&\n+diff expected current'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'updating origin' \\\n+'cd A &&\n+echo third > file3 &&\n+git add file3 &&\n+git commit -m update &&\n+git repack -a -d &&\n+git prune'\n+\n+cd \"$base_dir\"\n+\n+test_expect_success 'pulling changes from origin' \\\n+'cd C &&\n+git pull origin'\n+\n+cd \"$base_dir\"\n+\n+# the 2 local objects are commit and tree from the merge\n+test_expect_success 'that alternate to origin gets used' \\\n+'cd C &&\n+echo \"2 objects\" > expected &&\n+git count-objects | cut -d, -f1 > current &&\n+diff expected current'\n+\n+cd \"$base_dir\"\n+\n+test_done\n-- \n1.3.1.g6ef7\n"}]}