{"thread":{"id":"2070","subject":"[PATCH] Adapt tutorial to cygwin and add test case","startedAt":"2005-10-11T11:35:47Z","lastAt":"2005-10-12T11:08:54Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano","Matthias Urlichs"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9956","messageId":"Pine.LNX.4.63.0510111333160.27109@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2070","inReplyTo":null,"subject":"[PATCH] Adapt tutorial to cygwin and add test case","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-11T11:35:47Z","receivedAt":"2005-10-11T11:35:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Lacking reliable symlinks, the instructions in the tutorial did not work \nin a cygwin setup. Also, a few outputs were not correct.\n\nThis patch fixes these, and adds a test case which follows the \ninstructions of the tutorial (except git-clone, -fetch and -push, which I \nhave not done yet).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\n---\n\n Documentation/tutorial.txt |   71 ++++++++++++++------\n t/t1200-tutorial.sh        |  160 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 212 insertions(+), 19 deletions(-)\n\n\ndiff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt\nindex 19da3e2..7148da4 100644\n--- a/Documentation/tutorial.txt\n+++ b/Documentation/tutorial.txt\n@@ -51,7 +51,9 @@ your new project. You will now have a `.\n inspect that with `ls`. For your new empty project, it should show you\n three entries, among other things:\n \n- - a symlink called `HEAD`, pointing to `refs/heads/master`\n+ - a symlink called `HEAD`, pointing to `refs/heads/master` (if your\n+   platform does not have native symlinks, it is a file containing the\n+   line \"ref: refs/heads/master\")\n +\n Don't worry about the fact that the file that the `HEAD` link points to\n doesn't even exist yet -- you haven't created the commit that will\n@@ -227,6 +229,7 @@ which will spit out\n \n ------------\n diff --git a/hello b/hello\n+index 557db03..263414f 100644\n --- a/hello\n +++ b/hello\n @@ -1 +1,2 @@\n@@ -289,13 +292,14 @@ also wants to get a commit message\n on its standard input, and it will write out the resulting object name for the\n commit to its standard output.\n \n-And this is where we start using the `.git/HEAD` file. The `HEAD` file is\n+And this is where we create the `.git/refs/heads/master` file. This file is\n supposed to contain the reference to the top-of-tree, and since that's\n exactly what `git-commit-tree` spits out, we can do this all with a simple\n shell pipeline:\n \n ------------------------------------------------\n-echo \"Initial commit\" | git-commit-tree $(git-write-tree) > .git/HEAD\n+echo \"Initial commit\" | \\\n+\tgit-commit-tree $(git-write-tree) > .git/refs/heads/master\n ------------------------------------------------\n \n which will say:\n@@ -691,7 +695,9 @@ other point in the history than the curr\n just telling `git checkout` what the base of the checkout would be.\n In other words, if you have an earlier tag or branch, you'd just do\n \n-\tgit checkout -b mybranch earlier-commit\n+------------\n+git checkout -b mybranch earlier-commit\n+------------\n \n and it would create the new branch `mybranch` at the earlier commit,\n and check out the state at that time.\n@@ -699,17 +705,29 @@ and check out the state at that time.\n \n You can always just jump back to your original `master` branch by doing\n \n-\tgit checkout master\n+------------\n+git checkout master\n+------------\n \n (or any other branch-name, for that matter) and if you forget which\n branch you happen to be on, a simple\n \n-\tls -l .git/HEAD\n+------------\n+ls -l .git/HEAD\n+------------\n \n-will tell you where it's pointing. To get the list of branches\n-you have, you can say\n+will tell you where it's pointing (Note that on platforms with bad or no\n+symlink support, you have to execute\n \n-\tgit branch\n+------------\n+cat .git/HEAD\n+------------\n+\n+instead). To get the list of branches you have, you can say\n+\n+------------\n+git branch\n+------------\n \n which is nothing more than a simple script around `ls .git/refs/heads`.\n There will be asterisk in front of the branch you are currently on.\n@@ -717,7 +735,9 @@ There will be asterisk in front of the b\n Sometimes you may wish to create a new branch _without_ actually\n checking it out and switching to it. If so, just use the command\n \n-\tgit branch <branchname> [startingpoint]\n+------------\n+git branch <branchname> [startingpoint]\n+------------\n \n which will simply _create_ the branch, but will not do anything further. \n You can then later -- once you decide that you want to actually develop\n@@ -843,7 +863,6 @@ $ git show-branch master mybranch\n  ! [mybranch] Some work.\n --\n +  [master] Merged \"mybranch\" changes.\n-+  [master~1] Some fun.\n ++ [mybranch] Some work.\n ------------------------------------------------\n \n@@ -870,8 +889,10 @@ Now, let's pretend you are the one who d\n to the `master` branch. Let's go back to `mybranch`, and run\n resolve to get the \"upstream changes\" back to your branch.\n \n-\tgit checkout mybranch\n-\tgit resolve HEAD master \"Merge upstream changes.\"\n+------------\n+git checkout mybranch\n+git resolve HEAD master \"Merge upstream changes.\"\n+------------\n \n This outputs something like this (the actual commit object names\n would be different)\n@@ -1087,13 +1108,17 @@ i.e. `<project>.git`. Let's create such \n project `my-git`. After logging into the remote machine, create\n an empty directory:\n \n-\tmkdir my-git.git\n+------------\n+mkdir my-git.git\n+------------\n \n Then, make that directory into a git repository by running\n `git init-db`, but this time, since its name is not the usual\n `.git`, we do things slightly differently:\n \n-\tGIT_DIR=my-git.git git-init-db\n+------------\n+GIT_DIR=my-git.git git-init-db\n+------------\n \n Make sure this directory is available for others you want your\n changes to be pulled by via the transport of your choice. Also\n@@ -1117,7 +1142,9 @@ Your \"public repository\" is now ready to\n Come back to the machine you have your private repository. From\n there, run this command:\n \n-\tgit push <public-host>:/path/to/my-git.git master\n+------------\n+git push <public-host>:/path/to/my-git.git master\n+------------\n \n This synchronizes your public repository to match the named\n branch head (i.e. `master` in this case) and objects reachable\n@@ -1127,7 +1154,9 @@ As a real example, this is how I update \n repository. Kernel.org mirror network takes care of the\n propagation to other publicly visible machines:\n \n-\tgit push master.kernel.org:/pub/scm/git/git.git/ \n+------------\n+git push master.kernel.org:/pub/scm/git/git.git/ \n+------------\n \n \n Packing your repository\n@@ -1140,7 +1169,9 @@ not so convenient to transport over the \n immutable once they are created, there is a way to optimize the\n storage by \"packing them together\". The command\n \n-\tgit repack\n+------------\n+git repack\n+------------\n \n will do it for you. If you followed the tutorial examples, you\n would have accumulated about 17 objects in `.git/objects/??/`\n@@ -1164,7 +1195,9 @@ Our programs are always perfect ;-).\n Once you have packed objects, you do not need to leave the\n unpacked objects that are contained in the pack file anymore.\n \n-\tgit prune-packed\n+------------\n+git prune-packed\n+------------\n \n would remove them for you.\n \ndiff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\nnew file mode 100644\nindex 0000000..35db799\n--- /dev/null\n+++ b/t/t1200-tutorial.sh\n@@ -0,0 +1,160 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Johannes Schindelin\n+#\n+\n+test_description='Test git-rev-parse with different parent options'\n+\n+. ./test-lib.sh\n+\n+echo \"Hello World\" > hello\n+echo \"Silly example\" > example\n+\n+git-update-index --add hello example\n+\n+test_expect_success 'blob' \"test blob = \\\"$(git-cat-file -t 557db03)\\\"\"\n+\n+test_expect_success 'blob 557db03' \"test \\\"Hello World\\\" = \\\"$(git-cat-file blob 557db03)\\\"\"\n+\n+echo \"It's a new day for git\" >>hello\n+cat > diff.expect << EOF\n+diff --git a/hello b/hello\n+index 557db03..263414f 100644\n+--- a/hello\n++++ b/hello\n+@@ -1 +1,2 @@\n+ Hello World\n++It's a new day for git\n+EOF\n+git-diff-files -p > diff.output\n+test_expect_success 'git-diff-files -p' 'cmp diff.expect diff.output'\n+git diff > diff.output\n+test_expect_success 'git diff' 'cmp diff.expect diff.output'\n+\n+tree=$(git-write-tree 2>/dev/null)\n+\n+test_expect_success 'tree' \"test 8988da15d077d4829fc51d8544c097def6644dbb = $tree\"\n+\n+output=\"$(echo \"Initial commit\" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)\"\n+\n+test_expect_success 'commit' \"test 'Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb' = \\\"$output\\\"\"\n+\n+git-diff-index -p HEAD > diff.output\n+test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output'\n+\n+git diff HEAD > diff.output\n+test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'\n+\n+#rm hello\n+#test_expect_success 'git-read-tree --reset HEAD' \"git-read-tree --reset HEAD ; test \\\"hello: needs update\\\" = \\\"$(git-update-index --refresh)\\\"\"\n+\n+cat > whatchanged.expect << EOF\n+diff-tree VARIABLE (from root)\n+Author: VARIABLE\n+Date:   VARIABLE\n+\n+    Initial commit\n+\n+diff --git a/example b/example\n+new file mode 100644\n+index 0000000..f24c74a\n+--- /dev/null\n++++ b/example\n+@@ -0,0 +1 @@\n++Silly example\n+diff --git a/hello b/hello\n+new file mode 100644\n+index 0000000..557db03\n+--- /dev/null\n++++ b/hello\n+@@ -0,0 +1 @@\n++Hello World\n+EOF\n+\n+git-whatchanged -p --root | \\\n+\tsed -e \"1s/^\\(.\\{10\\}\\).\\{40\\}/\\1VARIABLE/\" \\\n+\t\t-e \"2,3s/^\\(.\\{8\\}\\).*$/\\1VARIABLE/\" \\\n+> whatchanged.output\n+test_expect_success 'git-whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'\n+\n+git tag my-first-tag\n+test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'\n+\n+# TODO: test git-clone\n+\n+git checkout -b mybranch\n+test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'\n+\n+cat > branch.expect <<EOF\n+  master\n+* mybranch\n+EOF\n+\n+git branch > branch.output\n+test_expect_success 'git branch' 'cmp branch.expect branch.output'\n+\n+git checkout mybranch\n+echo \"Work, work, work\" >>hello\n+git commit -m 'Some work.' hello\n+\n+git checkout master\n+\n+echo \"Play, play, play\" >>hello\n+echo \"Lots of fun\" >>example\n+git commit -m 'Some fun.' hello example\n+\n+test_expect_failure 'git resolve now fails' 'git resolve HEAD mybranch \"Merge work in mybranch\"'\n+\n+cat > hello << EOF\n+Hello World\n+It's a new day for git\n+Play, play, play\n+Work, work, work\n+EOF\n+\n+git commit -m 'Merged \"mybranch\" changes.' hello\n+\n+cat > show-branch.expect << EOF\n+* [master] Merged \"mybranch\" changes.\n+ ! [mybranch] Some work.\n+--\n++  [master] Merged \"mybranch\" changes.\n+++ [mybranch] Some work.\n+EOF\n+\n+git show-branch master mybranch > show-branch.output\n+test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'\n+\n+git checkout mybranch\n+\n+cat > resolve.expect << EOF\n+Updating from VARIABLE to VARIABLE.\n+ example |    1 +\n+ hello   |    1 +\n+ 2 files changed, 2 insertions(+), 0 deletions(-)\n+EOF\n+\n+git resolve HEAD master \"Merge upstream changes.\" | \\\n+\tsed -e \"1s/[0-9a-f]\\{40\\}/VARIABLE/g\" > resolve.output\n+test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'\n+\n+cat > show-branch2.expect << EOF\n+! [master] Merged \"mybranch\" changes.\n+ * [mybranch] Merged \"mybranch\" changes.\n+--\n+++ [master] Merged \"mybranch\" changes.\n+EOF\n+\n+git show-branch master mybranch > show-branch2.output\n+test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'\n+\n+# TODO: test git fetch\n+\n+# TODO: test git push\n+\n+test_expect_success 'git repack' 'git repack'\n+test_expect_success 'git prune-packed' 'git prune-packed'\n+test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]'\n+\n+test_done\n+\n"},{"id":"9976","messageId":"7vu0fnsu6f.fsf@assigned-by-dhcp.cox.net","threadId":"2070","inReplyTo":"Pine.LNX.4.63.0510111333160.27109@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Adapt tutorial to cygwin and add test case","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-11T19:57:44Z","receivedAt":"2005-10-11T19:57:44Z","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> -And this is where we start using the `.git/HEAD` file. The `HEAD` file is\n> +And this is where we create the `.git/refs/heads/master` file. This file is\n>  supposed to contain the reference to the top-of-tree, and since that's\n>  exactly what `git-commit-tree` spits out, we can do this all with a simple\n>  shell pipeline:\n>  \n>  ------------------------------------------------\n> -echo \"Initial commit\" | git-commit-tree $(git-write-tree) > .git/HEAD\n> +echo \"Initial commit\" | \\\n> +\tgit-commit-tree $(git-write-tree) > .git/refs/heads/master\n>  ------------------------------------------------\n\nHmm.  This is not wrong, but does not feel right.  The point we\nare explaining here is that there is a HEAD pointer that knows\nabout the current branch, and after making a commit, we update\nit to record the new tip of the branch.\n\nThe Kosher way would be\n\n    tree=$(git-write-tree)\n    commit=$(echo 'Initial commit' | git-commit-tree $tree)\n    git-update-ref HEAD $(commit)\n\nbut looks quite intimidating as a tutorial material.  \n\n> @@ -691,7 +695,9 @@ other point in the history than the curr\n>  just telling `git checkout` what the base of the checkout would be.\n>  In other words, if you have an earlier tag or branch, you'd just do\n>  \n> -\tgit checkout -b mybranch earlier-commit\n> +------------\n> +git checkout -b mybranch earlier-commit\n> +------------\n\nThe original was both ugly and did not use boxquote.  There is\nno excuse for ugliness, but not using boxquote was for a\nreason.  The boxquoted \"type this\" examples were not to be\nmissed, lest the later steps we explain would either not work or\nwould produce results that is different from what we show.  This\nparticular step is \"if you were doing something different, you\nwould do this\", implying \"but do not do that here if you are\nfollowing the tutorial steps because that is not what we are\ndoing here\".  Maybe we should use boxquote but make an explicit\ncomment that this is a tangent here?\n\n> @@ -699,17 +705,29 @@ and check out the state at that time.\n>  \n>  You can always just jump back to your original `master` branch by doing\n>  \n> -\tgit checkout master\n> +------------\n> +git checkout master\n> +------------\n\nSame here.\n\n> @@ -870,8 +889,10 @@ Now, let's pretend you are the one who d\n>  to the `master` branch. Let's go back to `mybranch`, and run\n>  resolve to get the \"upstream changes\" back to your branch.\n>  \n> -\tgit checkout mybranch\n> -\tgit resolve HEAD master \"Merge upstream changes.\"\n> +------------\n> +git checkout mybranch\n> +git resolve HEAD master \"Merge upstream changes.\"\n> +------------\n\nBut not here.\n\n> diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\n> new file mode 100644\n> index 0000000..35db799\n\nThis is an extremely good addition, thanks.\n"},{"id":"9991","messageId":"pan.2005.10.12.01.27.25.688169@smurf.noris.de","threadId":"2070","inReplyTo":"7vu0fnsu6f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Adapt tutorial to cygwin and add test case","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-10-12T01:27:26Z","receivedAt":"2005-10-12T01:27:26Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi, Junio C Hamano wrote:\n\n> The Kosher way would be\n> \n>     tree=$(git-write-tree)\n>     commit=$(echo 'Initial commit' | git-commit-tree $tree)\n>     git-update-ref HEAD $(commit)\n> \n> but looks quite intimidating as a tutorial material.\n\n... which is probably why there's a \"git commit\" command these days.\n\nThose three commands may be The Works, but they also expose exactly what\ngit does behind the scenes, and thus explains reasonably well what you'd\nneed to think about if you want to do something that's not just a simple\ncommit.\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\nDisclaimer: The quote was selected randomly. Really. | http://smurf.noris.de\n - -\nThe Killer Ducks are coming!!!\n"},{"id":"10010","messageId":"Pine.LNX.4.63.0510121302460.30679@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2070","inReplyTo":"pan.2005.10.12.01.27.25.688169@smurf.noris.de","subject":"Re: [PATCH] Adapt tutorial to cygwin and add test case","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-12T11:04:11Z","receivedAt":"2005-10-12T11:04:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 12 Oct 2005, Matthias Urlichs wrote:\n\n> Hi, Junio C Hamano wrote:\n> \n> > The Kosher way would be\n> > \n> >     tree=$(git-write-tree)\n> >     commit=$(echo 'Initial commit' | git-commit-tree $tree)\n> >     git-update-ref HEAD $(commit)\n> > \n> > but looks quite intimidating as a tutorial material.\n> \n> ... which is probably why there's a \"git commit\" command these days.\n\nConcur. The tutorial may contain technical details for the interested (and \nfor those who broke their setup...), so at that stage, I'd prefer to see \nthe convenient version.\n\nCiao,\nDscho\n"},{"id":"10011","messageId":"Pine.LNX.4.63.0510121306030.30679@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2070","inReplyTo":"7vu0fnsu6f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Adapt tutorial to cygwin and add test case","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-12T11:08:54Z","receivedAt":"2005-10-12T11:08:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 11 Oct 2005, Junio C Hamano wrote:\n\n> The original was both ugly and did not use boxquote.  There is\n> no excuse for ugliness, but not using boxquote was for a\n> reason.\n\nI am no expert in non-ugliness, and neither in asciidoc. My first version \nof the patch removed the single \"+\" on a line, because I thought they were \nremnants of a corrupted patch... By using git-whatchanged I found out that \nthis is not so, and finally I found that it means \"continuation\" in \nasciidoc syntax.\n\nSo: Sorry, can't help here.\n\nCiao,\nDscho\n"}]}