{"thread":{"id":"7699","subject":"[PATCH] Tests for core subproject support","startedAt":"2007-04-16T20:39:47Z","lastAt":"2007-04-16T20:39:47Z","messageCount":1,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39574","messageId":"20070416203947.GA22872@steel.home","threadId":"7699","inReplyTo":null,"subject":"[PATCH] Tests for core subproject support","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-16T20:39:47Z","receivedAt":"2007-04-16T20:39:47Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"The following tests available:\n\n- create subprojects: create a directory in the superproject,\n  initialize a git repo in it, and try adding it in super project.\n  Make a commit in superproject\n\n- check if fsck ignores the subprojects: it just should give no errors\n\n- check if commit in a subproject detected: make a commit in\n  subproject, git-diff-files in superproject should detect it\n\n- check if a changed subproject HEAD can be committed: try\n  \"git-commit -a\" in superproject. It should commit changed\n  HEAD of a subproject\n\n- check if diff-index works for subproject elements: compare the index\n  (changed by previuos tests) with the initial commit (which created\n  two subprojects). Should show a change for the recently changed subproject\n\n- check if diff-tree works for subproject elements: do the same, just use\n  git-diff-tree. This test is somewhat redundant, I just added it for\n  completeness (diff, diff-files, and diff-index are already used)\n\n- check if git diff works for subproject elements: try to limit\n  the diff for the name of a subproject in superproject:\n     git diff HEAD^ HEAD -- subproject\n\n- check if clone works: try a clone of superproject and compare\n  \"git ls-files -s\" output in superproject and cloned repo\n\n- removing and adding subproject: rename test. Currently implemented\n  as \"git-update-index --force-remove\", \"mv\" and \"git-add\".\n\n- checkout in superproject: try to checkout the initial commit\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nI should have missed something, I have that feeling...\n\n t/t3040-subprojects-basic.sh |   85 ++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 85 insertions(+), 0 deletions(-)\n create mode 100755 t/t3040-subprojects-basic.sh\n\ndiff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh\nnew file mode 100755\nindex 0000000..79b9f23\n--- /dev/null\n+++ b/t/t3040-subprojects-basic.sh\n@@ -0,0 +1,85 @@\n+#!/bin/sh\n+\n+test_description='Basic subproject functionality'\n+. ./test-lib.sh\n+\n+test_expect_success 'Super project creation' \\\n+    ': >Makefile &&\n+    git add Makefile &&\n+    git commit -m \"Superproject created\"'\n+\n+\n+cat >expected <<EOF\n+:000000 160000 00000... A\tsub1\n+:000000 160000 00000... A\tsub2\n+EOF\n+test_expect_success 'create subprojects' \\\n+    'mkdir sub1 &&\n+    ( cd sub1 && git init && : >Makefile && git add * &&\n+    git commit -q -m \"subproject 1\" ) &&\n+    mkdir sub2 &&\n+    ( cd sub2 && git init && : >Makefile && git add * &&\n+    git commit -q -m \"subproject 2\" ) &&\n+    git update-index --add sub1 &&\n+    git add sub2 &&\n+    git commit -q -m \"subprojects added\" &&\n+    git diff-tree --abbrev=5 HEAD^ HEAD |cut -d\" \" -f-3,5- >current &&\n+    git diff expected current'\n+\n+git branch save HEAD\n+\n+test_expect_success 'check if fsck ignores the subprojects' \\\n+    'git fsck --full'\n+\n+test_expect_success 'check if commit in a subproject detected' \\\n+    '( cd sub1 &&\n+    echo \"all:\" >>Makefile &&\n+    echo \"\ttrue\" >>Makefile &&\n+    git commit -q -a -m \"make all\" ) && {\n+        git diff-files --exit-code\n+\ttest $? = 1\n+    }'\n+\n+test_expect_success 'check if a changed subproject HEAD can be committed' \\\n+    'git commit -q -a -m \"sub1 changed\" && {\n+\tgit diff-tree --exit-code HEAD^ HEAD\n+\ttest $? = 1\n+    }'\n+\n+test_expect_success 'check if diff-index works for subproject elements' \\\n+    'git diff-index --exit-code --cached save -- sub1\n+    test $? = 1'\n+\n+test_expect_success 'check if diff-tree works for subproject elements' \\\n+    'git diff-tree --exit-code HEAD^ HEAD -- sub1\n+    test $? = 1'\n+\n+test_expect_success 'check if git diff works for subproject elements' \\\n+    'git diff --exit-code HEAD^ HEAD\n+    test $? = 1'\n+\n+test_expect_success 'check if clone works' \\\n+    'git ls-files -s >expected &&\n+    git clone -l -s . cloned &&\n+    ( cd cloned && git ls-files -s ) >current &&\n+    git diff expected current'\n+\n+test_expect_success 'removing and adding subproject' \\\n+    'git update-index --force-remove -- sub2 &&\n+    mv sub2 sub3 &&\n+    git add sub3 &&\n+    git commit -q -m \"renaming a subproject\" && {\n+\tgit diff -M --name-status --exit-code HEAD^ HEAD\n+\ttest $? = 1\n+    }'\n+\n+# the index must contain the object name the HEAD of the\n+# subproject sub1 was at the point \"save\"\n+test_expect_success 'checkout in superproject' \\\n+    'git checkout save &&\n+    git diff-index --exit-code --raw --cached save -- sub1'\n+\n+# just interesting what happened...\n+# git diff --name-status -M save master\n+\n+test_done\n-- \n1.5.1.1.819.gcfdd2\n"}]}