Permalink
Browse files

Setup a default format for the Verbatim environments.

  • Loading branch information...
1 parent ac06e6d commit 81e37936525ec657d2f57d323524d120e71a8abc @godbyk godbyk committed May 16, 2011
Showing with 137 additions and 137 deletions.
  1. +10 −10 afterhours2.tex
  2. +12 −12 afterhours3.tex
  3. +1 −1 afterhours4.tex
  4. +14 −14 afterhours5.tex
  5. +13 −13 chap2.tex
  6. +22 −22 chap3.tex
  7. +34 −34 chap4.tex
  8. +28 −28 chap6.tex
  9. +1 −1 chap7.tex
  10. +2 −2 gitt.cls
View
@@ -7,7 +7,7 @@ \subsection{A Look At Plumbing}
To start with, we are going to use the Git repository that we have been playing with in Week 2 and take a deeper look at what is actually inside a Git repository. Let us view the directory structure, to see what has been created in the \texttt{.git} folder.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo/.git$ ls -la
total 52
drwxr-xr-x 8 john john 4096 2011-03-31 20:35 .
@@ -68,7 +68,7 @@ \subsection{A Look At Plumbing}
So now we know what a basic repository should look like, let us go through each stage of our committing in \textbf{Week 2} and see how it is built up at each stage. Below is a consolidated list of all the objects in the repository.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
./09/5b9cda52807c9c11781ec0a4aee927787b61f1
./16/3f06147a449e724d0cfd484c3334709e8e1fce
./34/a5dff148e70c12310cda0800d6bcaf82530bdc
@@ -82,19 +82,19 @@ \subsection{A Look At Plumbing}
In order to start rebuilding a picture of our repository, let us first find out what the first commit to our repository was. Looking back in \emph{Week 2} we can see the following trimmed output.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
[master (root-commit) cfe23cb] My First Ever Commit
\end{Verbatim}
So we need to start with the object that begins \texttt{cfe23cb}. Remember in the description above about the SHA-1 hashes, the first two bytes are the directory name. We are looking for a file that starts with the characters \texttt{e23cb} and it will be in the directory called \texttt{cf}. By George! Looking at the list above, we can see that there is one file which fits the bill. In fact it would be a little ambiguous if there were two. It \emph{could} happen that we would have two SHA-1 hashes that started with the same seven characters, but it's not likely. The line we are interested in is listed below.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
./cf/e23cbe0150fda69a004e301828097935ec4397}
\end{Verbatim}
It would be nice if we could find out a little more about this object, and confirm that it is what we expect it to be. to start with, let us run the linux \texttt{file} command on it, to see what it makes of it.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo/.git/objects/cf$ file
e23cbe0150fda69a004e301828097935ec4397
e23cbe0150fda69a004e301828097935ec4397: VAX COFF executable -
@@ -117,7 +117,7 @@ \subsection{Out comes the wrench}
If we run this plumbing command against our object, and supply the \texttt{-t} parameter, \texttt{git cat-file} will tell us the type of the object. If we run it with the \texttt{-s} parameter, it will tell us the size. Finally, running it with the \texttt{-p} parameter we can see what the object actually contains. Each of these has been demonstrated below.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -t cfe23c
commit
john@satsuki:~/coderepo$ git cat-file -s cfe23c
@@ -134,7 +134,7 @@ \subsection{Out comes the wrench}
Fantastic! We now have a way of confirming the objects are what we think they are. If we were to run the command against every file in the repository, we would end up with a list that would look something like the one below. Notice our commit object sat in the middle.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
./09/5b9cda52807c9c11781ec0a4aee927787b61f1 blob
./16/3f06147a449e724d0cfd484c3334709e8e1fce commit
./34/a5dff148e70c12310cda0800d6bcaf82530bdc tree
@@ -148,7 +148,7 @@ \subsection{Out comes the wrench}
Now things start to get interesting. Did you also notice the tree SHA-1 hash mentioned when we ran \texttt{git cat-file -p}? This is the tree object that stores the file structure. Why don't we run the command against that file too?
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -p 34a5dff
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
my_first_committed_file
@@ -157,7 +157,7 @@ \subsection{Out comes the wrench}
We can now see a list of all files that were present in that snapshot of the working tree. In our case this just happens to be one file. Using our command one last time against the object name of the file, we can see the actual contents of the file.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -p e69de29
john@satsuki:~/coderepo$
\end{Verbatim}
@@ -172,7 +172,7 @@ \subsection{Out comes the wrench}
If we pick another commit object from the list and run our command on it we can see something new has appeared in the output.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -p 163f061
tree 3ffa7ab6dafef2bc38a70a39c53604c333ed4d7a
parent cfe23cbe0150fda69a004e301828097935ec4397
View
@@ -10,27 +10,27 @@ \subsection{The Diff Utility}
Though we are not going to go into the problem in great detail, it is useful to know what actually happens at this level. Essentially you have two sequences, for now we are going to simplify the problem and work on a string of letters.
Old string:
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
a b c d e j k l m p r s
\end{Verbatim}
New string:
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
a c d f g h i j n o p t u
\end{Verbatim}
The challenge is to find the longest sequence of items that is present in both of the strings above. This new sequence is found by deleting items from the first and second set until all that remains is a sequence of common items.
In our example case, this is as follows
LCS string:
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
a c d j p
\end{Verbatim}
Comparing this to each of our strings above, it is easy to generate a diff. If the items are present in the \emph{Old string}, but not in the LCS string then they must have been deleted. Conversely if they are present in the \emph{New string}, but not the LCS, then they must have been additions. Putting this into practice in our example and marking deletions with \texttt{-} and additions with \texttt{+}, we get the following:
Diff string:
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
b e fghi klm o rs tu
- - ++++ --- + -- ++
\end{Verbatim}
@@ -42,7 +42,7 @@ \subsection{More about tags}
Firstly we can use the \texttt{git tag} command to show all tags that are currently in the repository.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git tag
v0.9
v1.0a
@@ -51,14 +51,14 @@ \subsection{More about tags}
Now let us create a new tag and give it some extra information.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git tag v1.0b -m 'This is an annotated tag'
john@satsuki:~/coderepo$
\end{Verbatim}
Unfortunately Git was not particularly forthcoming with information on the creation of the tag. On saying that, it is not difficult for us to use the \texttt{git show} command to see what we have done.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git show v1.0b
tag v1.0b
Tagger: John Haskins <john.haskins@tamagoyakiinc.koala>
@@ -98,7 +98,7 @@ \subsection{More about tags}
The implementation of tags in Git is very simple indeed. We are going to jump into the \texttt{.git} directory and take a look at a simple output from some commands.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ cd .git/
john@satsuki:~/coderepo/.git$ ls
branches config HEAD index logs refs
@@ -113,7 +113,7 @@ \subsection{More about tags}
Inside the \texttt{.git/refs/tags} folder, there is a file for every single tag in the system. This file contains a single string of characters. That string looks oddly like an SHA-1 commit to me. Using the tricks that we learnt in the last After Hours section, we can interrogate the Git repository, by throwing a few wrenches at it.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -p a022d4
tree 96551f45496232c0ec6b389731d55fa3d7e1c8fd
parent 9938a0c30940dccaeddce4bb2eb151fba3a21ae5
@@ -129,7 +129,7 @@ \subsection{More about tags}
Excellent! Just as we expected. So Git stores the SHA-1 hash for the commit we are referring to, in a file which has the same name as the tag. Just for clarity, let us run the same set of commands against our newly created annotated tag.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ cd .git/refs/tags/
john@satsuki:~/coderepo/.git/refs/tags$ cat v1.0b
6cbcf47957589bf4b84cc934a26731636d021574
@@ -138,7 +138,7 @@ \subsection{More about tags}
Hang on a minute! Shouldn't the output of the \texttt{v1.0a} and \texttt{v1.0b} files be the same. There were both created at the same point in the repositories history. They were both supposed to be pointing to the same commit. Let us use a little plumbing and see what is going on.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -t 6cbcf4
tag
john@satsuki:~/coderepo$
@@ -148,7 +148,7 @@ \subsection{More about tags}
When the tag was merely a pointer to a commit object, the repository required nothing more that the object that it was referring to, to be stored in the file. Now we have more information, Git treats the information just as it would any other, by creating an object. We can investigate this further and use the \texttt{-p} parameter to the \texttt{git cat-file} command to see exactly what is stored within this file.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git cat-file -p 6cbcf4
object a022d4d1edc69970b4e8b3fe1da3dccd943a55e4
type commit
View
@@ -37,7 +37,7 @@ \subsection{How does merging work?}
Let us go back to our example above. We are attempting to merge in \textbf{zaney} to the \textbf{wonderful} branch. We need to find the \textbf{C} in our equation. To do this we could pour over Figure 1. This should yield the result to be commit \textbf{9710177}. Is there are way we can ask Git to do the same thing? The following output introduces a new command that is used to find the \emph{Best Common Ancestor} for a given merge proposal.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo-af4$ git merge-base wonderful zaney
9710177657ae00665ca8f8027b17314346a5b1c4
john@satsuki:~/coderepo-af4$ git cat-file -p 9710177
View
@@ -11,7 +11,7 @@ \subsection{Taking commits that little bit further}
So let us start by creating our branch and making some changes as shown below.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git checkout -b fantasy
Switched to a new branch 'fantasy'
john@satsuki:~/coderepo$ echo "This is line 1" > newfile1
@@ -24,7 +24,7 @@ \subsection{Taking commits that little bit further}
Let us now just run a \texttt{git diff} to see exactly what the changes are.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git diff
diff --git a/newfile1 b/newfile1
index 44640b2..0eccf1a 100644
@@ -51,7 +51,7 @@ \subsection{Taking commits that little bit further}
Now, we could just do \texttt{git commit -a} and be done with it, but what if we really wanted to split this information up into four commits? We will introduce a new parameter to our \texttt{git add} tool from before. We are going to use the \texttt{git add -p} or \texttt{git add --patch}. This will allow us to interactively edit the hunks before they are committed. To begin with, let us run \texttt{git add -p} and see what it is we need to do.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git add -p
diff --git a/newfile1 b/newfile1
index 44640b2..0eccf1a 100644
@@ -69,7 +69,7 @@ \subsection{Taking commits that little bit further}
We are given the options of \texttt{y,n,q,a,d,/,e,?}. At first glance, this may seem rather daunting. Let us choose the \texttt{?} and see what help is presented to us.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
Stage this hunk [y,n,q,a,d,/,e,?]? ?
y - stage this hunk
n - do not stage this hunk
@@ -110,7 +110,7 @@ \subsection{Taking commits that little bit further}
Here we are left in our chosen text editor, to either add, modify or remove lines from the hunk. In our case, we are going to delete a few lines. We only want to leave the first line of additions. Just because we delete the others does not mean they are deleted from the working copy. Remember, we are not editing the actual files here. Just the hunks that are going to be staged.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
# Manual hunk edit mode -- see bottom for a quick guide
@@ -1,2 +1,4 @@
-A new file
@@ -132,7 +132,7 @@ \subsection{Taking commits that little bit further}
After the deletes, the editors file should look like this.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
# Manual hunk edit mode -- see bottom for a quick guide
@@ -1,2 +1,4 @@
-A new file
@@ -151,7 +151,7 @@ \subsection{Taking commits that little bit further}
Once we quit our editor, we are then asked about the next hunk. In our case, we are going to apply all of the changes to our second file during this commit. To do this we are going to use the \texttt{a} option.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
diff --git a/newfile2 b/newfile2
index 3545c1d..40efcce 100644
--- a/newfile2
@@ -168,7 +168,7 @@ \subsection{Taking commits that little bit further}
At first glance, we do not appear to have been left with any indication that anything has taken place. In order to perform a check we shall run out obligatory \texttt{git diff}, both between the working copy and the index, and between the index and the last commit.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git diff
diff --git a/newfile1 b/newfile1
index f702b65..0eccf1a 100644
@@ -184,7 +184,7 @@ \subsection{Taking commits that little bit further}
So above, we can see that the difference between the working copy and the index, or staging area, is the last three lines that we are not ready to commit yet. Below we can see the difference between the staging area and the last commit to the repository. This includes the three lines that we included during our interactive commit preparation.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git diff --cached
diff --git a/newfile1 b/newfile1
index 44640b2..f702b65 100644
@@ -208,7 +208,7 @@ \subsection{Taking commits that little bit further}
We can now commit in the normal way, and continue to edit the working copy to stage the sections we require. The following output is shortened for brevity.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git commit -m 'Added first line'
[fantasy 03bd20c] Added first line
2 files changed, 3 insertions(+), 2 deletions(-)
@@ -235,7 +235,7 @@ \subsection{Taking commits that little bit further}
We have gone through the process of editing each hunk for each commit and have performed the commits.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git log
commit a59e73b1dc571318a1154aa4c2fc591ab6f1f395
Author: John Haskins <john.haskins@tamagoyakiinc.koala>
@@ -264,7 +264,7 @@ \subsection{Taking commits that little bit further}
Next we are going to see how to perform exactly the same procedure using \texttt{git gui}. For a start, we are going to reset our branch HEAD and our index back to their state before we made the last four commits, however we are going to leave the working copy files in the state they were after these last four commits. This is called a \textbf{mixed} reset, as it modifies the staging area and the HEAD, but does not touch the working files.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git log --oneline
a59e73b Added fourth line
3ca3d62 Added third line
@@ -283,7 +283,7 @@ \subsection{Taking commits that little bit further}
Now we will run a diff, just to be sure.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git diff
diff --git a/newfile1 b/newfile1
index 44640b2..0eccf1a 100644
@@ -338,7 +338,7 @@ \subsection{Taking commits that little bit further}
Let us now move back to our \textbf{master} branch and remove the \textbf{fantasy} branch.
-\begin{Verbatim}[frame=leftline,framerule=1mm,fontsize=\relsize{-3}]
+\begin{Verbatim}
john@satsuki:~/coderepo$ git checkout master
Switched to branch 'master'
john@satsuki:~/coderepo$ git branch -D fantasy
Oops, something went wrong.

0 comments on commit 81e3793

Please sign in to comment.