{"thread":{"id":"5729","subject":"[PATCH 1/3] Add pack-refs and show-ref test cases.","startedAt":"2006-09-28T04:58:03Z","lastAt":"2007-03-24T05:34:13Z","messageCount":3,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"27871","messageId":"20060928065803.2774a63c.chriscool@tuxfamily.org","threadId":"5729","inReplyTo":null,"subject":"[PATCH 1/3] Add pack-refs and show-ref test cases.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-28T04:58:03Z","receivedAt":"2006-09-28T04:58:03Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Some of these test cases are from Junio.\nOne test case is commented out because it doesn't work right now.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t3210-pack-refs.sh |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 70 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh\nnew file mode 100755\nindex 0000000..2cc03e6\n--- /dev/null\n+++ b/t/t3210-pack-refs.sh\n@@ -0,0 +1,70 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Amos Waterland\n+# Copyright (c) 2006 Christian Couder\n+#\n+\n+test_description='git pack-refs should not change the branch semantic\n+\n+This test runs git pack-refs and git show-ref and checks that the branch\n+semantic is still the same.\n+'\n+. ./test-lib.sh\n+\n+test_expect_success \\\n+    'prepare a trivial repository' \\\n+    'echo Hello > A &&\n+     git-update-index --add A &&\n+     git-commit -m \"Initial commit.\" &&\n+     HEAD=$(git-rev-parse --verify HEAD)'\n+\n+SHA1=\n+\n+test_expect_success \\\n+    'see if git show-ref works as expected' \\\n+    'git-branch a &&\n+     SHA1=$(< .git/refs/heads/a) &&\n+     echo \"$SHA1 refs/heads/a\" >expect &&\n+     git-show-ref a >result &&\n+     diff expect result'\n+\n+test_expect_success \\\n+    'see if a branch still exists when packed' \\\n+    'git-branch b &&\n+     git-pack-refs &&\n+     rm .git/refs/heads/b &&\n+     echo \"$SHA1 refs/heads/b\" >expect &&\n+     git-show-ref b >result &&\n+     diff expect result'\n+\n+# test_expect_failure \\\n+#     'git branch c/d should barf if branch c exists' \\\n+#     'git-branch c &&\n+#      git-pack-refs &&\n+#      rm .git/refs/heads/c &&\n+#      git-branch c/d'\n+\n+test_expect_success \\\n+    'see if a branch still exists after git pack-refs --prune' \\\n+    'git-branch e &&\n+     git-pack-refs --prune &&\n+     echo \"$SHA1 refs/heads/e\" >expect &&\n+     git-show-ref e >result &&\n+     diff expect result'\n+\n+test_expect_failure \\\n+    'see if git pack-refs --prune remove ref files' \\\n+    'git-branch f &&\n+     git-pack-refs --prune &&\n+     ls .git/refs/heads/f'\n+\n+test_expect_success \\\n+    'git branch g should work when git branch g/h has been deleted' \\\n+    'git-branch g/h &&\n+     git-pack-refs --prune &&\n+     git-branch -d g/h &&\n+     git-branch g &&\n+     git-pack-refs &&\n+     git-branch -d g'\n+\n+test_done\n-- \n1.4.2.1.g4f95-dirty\n"},{"id":"37856","messageId":"20070324063010.a114722e.chriscool@tuxfamily.org","threadId":"5729","inReplyTo":"20060928065803.2774a63c.chriscool@tuxfamily.org","subject":"[PATCH 2/3] When creating branch c/d check that branch c does not already exists.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-03-24T05:30:10Z","receivedAt":"2007-03-24T05:30:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"With packed refs, there may not be a \".git/refs/heads/c\" file\nwhen branch c exists. And currently in this case, there is no check\nto prevent creation of branch c/d.\n\nThis should probably be rewritten in C and done after the ref lock\nhas been taken to make sure no race exists though.\n\nThis is mainly to make all test cases in \"t3210-pack-refs.sh\" work.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-branch.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex 4826c75..4a1e7d9 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -122,6 +122,16 @@ then\n \tdone\n fi\n \n+branchdir=$(dirname $branchname)\n+while test \"$branchdir\" != \".\"\n+do\n+\tif git-show-ref --verify --quiet -- \"refs/heads/$branchdir\"\n+\tthen\n+\t\tdie \"$branchdir already exists.\"\n+\tfi\n+\tbranchdir=$(dirname $branchdir)\n+done\n+\n if git-show-ref --verify --quiet -- \"refs/heads/$branchname\"\n then\n \tif test '' = \"$force\"\n-- \n1.4.2.1.g3bab\n"},{"id":"37861","messageId":"200703240634.14284.chriscool@tuxfamily.org","threadId":"5729","inReplyTo":"20070324063010.a114722e.chriscool@tuxfamily.org","subject":"Re: [PATCH 2/3] When creating branch c/d check that branch c does not already exists.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-03-24T05:34:13Z","receivedAt":"2007-03-24T05:34:13Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Oops, sorry this is an old mail that was in my Draft folder and should not \nhave been sent...\n\nChristian.\n\nLe samedi 24 mars 2007 06:30, Christian Couder a écrit :\n> With packed refs, there may not be a \".git/refs/heads/c\" file\n> when branch c exists. And currently in this case, there is no check\n> to prevent creation of branch c/d.\n>\n> This should probably be rewritten in C and done after the ref lock\n> has been taken to make sure no race exists though.\n>\n> This is mainly to make all test cases in \"t3210-pack-refs.sh\" work.\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  git-branch.sh |   10 ++++++++++\n>  1 files changed, 10 insertions(+), 0 deletions(-)\n>\n> diff --git a/git-branch.sh b/git-branch.sh\n> index 4826c75..4a1e7d9 100755\n> --- a/git-branch.sh\n> +++ b/git-branch.sh\n> @@ -122,6 +122,16 @@ then\n>  \tdone\n>  fi\n>\n> +branchdir=$(dirname $branchname)\n> +while test \"$branchdir\" != \".\"\n> +do\n> +\tif git-show-ref --verify --quiet -- \"refs/heads/$branchdir\"\n> +\tthen\n> +\t\tdie \"$branchdir already exists.\"\n> +\tfi\n> +\tbranchdir=$(dirname $branchdir)\n> +done\n> +\n>  if git-show-ref --verify --quiet -- \"refs/heads/$branchname\"\n>  then\n>  \tif test '' = \"$force\"\n"}]}