Integrated repo and further tests from rafl's catalysed gitweb.
Zachary Stevens [Tue, 29 Sep 2009 21:51:29 +0000 (22:51 +0100)]
23 files changed:
t/lib/repositories/repo1/HEAD [new file with mode: 0644]
t/lib/repositories/repo1/config [new file with mode: 0644]
t/lib/repositories/repo1/description [new file with mode: 0644]
t/lib/repositories/repo1/hooks/applypatch-msg [new file with mode: 0644]
t/lib/repositories/repo1/hooks/commit-msg [new file with mode: 0644]
t/lib/repositories/repo1/hooks/post-commit [new file with mode: 0644]
t/lib/repositories/repo1/hooks/post-update [new file with mode: 0644]
t/lib/repositories/repo1/hooks/pre-applypatch [new file with mode: 0644]
t/lib/repositories/repo1/hooks/pre-commit [new file with mode: 0644]
t/lib/repositories/repo1/hooks/pre-rebase [new file with mode: 0644]
t/lib/repositories/repo1/hooks/update [new file with mode: 0644]
t/lib/repositories/repo1/info/exclude [new file with mode: 0644]
t/lib/repositories/repo1/objects/14/5dc3ef5d307be84cb9b325d70bd08aeed0eceb [new file with mode: 0644]
t/lib/repositories/repo1/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 [new file with mode: 0644]
t/lib/repositories/repo1/objects/36/c6c6708b8360d7023e8a1649c45bcf9b3bd818 [new file with mode: 0644]
t/lib/repositories/repo1/objects/3b/c0634310b9c62222bb0e724c11ffdfb297b4ac [new file with mode: 0644]
t/lib/repositories/repo1/objects/3f/7567c7bdf7e7ebf410926493b92d398333116e [new file with mode: 0644]
t/lib/repositories/repo1/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 [new file with mode: 0644]
t/lib/repositories/repo1/objects/72/9a7c3f6ba5453b42d16a43692205f67fb23bc1 [new file with mode: 0644]
t/lib/repositories/repo1/objects/82/b5fee28277349b6d46beff5fdf6a7152347ba0 [new file with mode: 0644]
t/lib/repositories/repo1/objects/90/62594aebb5df0de7fb92413f17a9eced196c22 [new file with mode: 0644]
t/lib/repositories/repo1/refs/heads/master [new file with mode: 0644]
t/model_Git.t

diff --git a/t/lib/repositories/repo1/HEAD b/t/lib/repositories/repo1/HEAD
new file mode 100644 (file)
index 0000000..cb089cd
--- /dev/null
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/t/lib/repositories/repo1/config b/t/lib/repositories/repo1/config
new file mode 100644 (file)
index 0000000..07d359d
--- /dev/null
@@ -0,0 +1,4 @@
+[core]
+       repositoryformatversion = 0
+       filemode = true
+       bare = true
diff --git a/t/lib/repositories/repo1/description b/t/lib/repositories/repo1/description
new file mode 100644 (file)
index 0000000..407d91e
--- /dev/null
@@ -0,0 +1 @@
+some test repository
diff --git a/t/lib/repositories/repo1/hooks/applypatch-msg b/t/lib/repositories/repo1/hooks/applypatch-msg
new file mode 100644 (file)
index 0000000..02de1ef
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message taken by
+# applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.  The hook is
+# allowed to edit the commit message file.
+#
+# To enable this hook, make this file executable.
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/commit-msg" &&
+       exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
+:
diff --git a/t/lib/repositories/repo1/hooks/commit-msg b/t/lib/repositories/repo1/hooks/commit-msg
new file mode 100644 (file)
index 0000000..9b04f2d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message.
+# Called by git-commit with one argument, the name of the file
+# that has the commit message.  The hook should exit with non-zero
+# status after issuing an appropriate message if it wants to stop the
+# commit.  The hook is allowed to edit the commit message file.
+#
+# To enable this hook, make this file executable.
+
+# Uncomment the below to add a Signed-off-by line to the message.
+# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
+
+# This example catches duplicate Signed-off-by lines.
+
+test "" = "$(grep '^Signed-off-by: ' "$1" |
+        sort | uniq -c | sed -e '/^[   ]*1[    ]/d')" || {
+       echo >&2 Duplicate Signed-off-by lines.
+       exit 1
+}
+
diff --git a/t/lib/repositories/repo1/hooks/post-commit b/t/lib/repositories/repo1/hooks/post-commit
new file mode 100644 (file)
index 0000000..8be6f34
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script that is called after a successful
+# commit is made.
+#
+# To enable this hook, make this file executable.
+
+: Nothing
diff --git a/t/lib/repositories/repo1/hooks/post-update b/t/lib/repositories/repo1/hooks/post-update
new file mode 100644 (file)
index 0000000..bcba893
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script to prepare a packed repository for use over
+# dumb transports.
+#
+# To enable this hook, make this file executable by "chmod +x post-update".
+
+exec git-update-server-info
diff --git a/t/lib/repositories/repo1/hooks/pre-applypatch b/t/lib/repositories/repo1/hooks/pre-applypatch
new file mode 100644 (file)
index 0000000..5f56ce8
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed
+# by applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.
+#
+# To enable this hook, make this file executable.
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/pre-commit" &&
+       exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
+:
+
diff --git a/t/lib/repositories/repo1/hooks/pre-commit b/t/lib/repositories/repo1/hooks/pre-commit
new file mode 100644 (file)
index 0000000..723a9ef
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by git-commit with no arguments.  The hook should
+# exit with non-zero status after issuing an appropriate message if
+# it wants to stop the commit.
+#
+# To enable this hook, make this file executable.
+
+# This is slightly modified from Andrew Morton's Perfect Patch.
+# Lines you introduce should not have trailing whitespace.
+# Also check for an indentation that has SP before a TAB.
+
+if git-rev-parse --verify HEAD 2>/dev/null
+then
+       git-diff-index -p -M --cached HEAD
+else
+       # NEEDSWORK: we should produce a diff with an empty tree here
+       # if we want to do the same verification for the initial import.
+       :
+fi |
+perl -e '
+    my $found_bad = 0;
+    my $filename;
+    my $reported_filename = "";
+    my $lineno;
+    sub bad_line {
+       my ($why, $line) = @_;
+       if (!$found_bad) {
+           print STDERR "*\n";
+           print STDERR "* You have some suspicious patch lines:\n";
+           print STDERR "*\n";
+           $found_bad = 1;
+       }
+       if ($reported_filename ne $filename) {
+           print STDERR "* In $filename\n";
+           $reported_filename = $filename;
+       }
+       print STDERR "* $why (line $lineno)\n";
+       print STDERR "$filename:$lineno:$line\n";
+    }
+    while (<>) {
+       if (m|^diff --git a/(.*) b/\1$|) {
+           $filename = $1;
+           next;
+       }
+       if (/^@@ -\S+ \+(\d+)/) {
+           $lineno = $1 - 1;
+           next;
+       }
+       if (/^ /) {
+           $lineno++;
+           next;
+       }
+       if (s/^\+//) {
+           $lineno++;
+           chomp;
+           if (/\s$/) {
+               bad_line("trailing whitespace", $_);
+           }
+           if (/^\s*   /) {
+               bad_line("indent SP followed by a TAB", $_);
+           }
+           if (/^(?:[<>=]){7}/) {
+               bad_line("unresolved merge conflict", $_);
+           }
+       }
+    }
+    exit($found_bad);
+'
+
diff --git a/t/lib/repositories/repo1/hooks/pre-rebase b/t/lib/repositories/repo1/hooks/pre-rebase
new file mode 100644 (file)
index 0000000..981c454
--- /dev/null
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+publish=next
+basebranch="$1"
+if test "$#" = 2
+then
+       topic="refs/heads/$2"
+else
+       topic=`git symbolic-ref HEAD`
+fi
+
+case "$basebranch,$topic" in
+master,refs/heads/??/*)
+       ;;
+*)
+       exit 0 ;# we do not interrupt others.
+       ;;
+esac
+
+# Now we are dealing with a topic branch being rebased
+# on top of master.  Is it OK to rebase it?
+
+# Is topic fully merged to master?
+not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
+if test -z "$not_in_master"
+then
+       echo >&2 "$topic is fully merged to master; better remove it."
+       exit 1 ;# we could allow it, but there is no point.
+fi
+
+# Is topic ever merged to next?  If so you should not be rebasing it.
+only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
+only_next_2=`git-rev-list ^master           ${publish} | sort`
+if test "$only_next_1" = "$only_next_2"
+then
+       not_in_topic=`git-rev-list "^$topic" master`
+       if test -z "$not_in_topic"
+       then
+               echo >&2 "$topic is already up-to-date with master"
+               exit 1 ;# we could allow it, but there is no point.
+       else
+               exit 0
+       fi
+else
+       not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
+       perl -e '
+               my $topic = $ARGV[0];
+               my $msg = "* $topic has commits already merged to public branch:\n";
+               my (%not_in_next) = map {
+                       /^([0-9a-f]+) /;
+                       ($1 => 1);
+               } split(/\n/, $ARGV[1]);
+               for my $elem (map {
+                               /^([0-9a-f]+) (.*)$/;
+                               [$1 => $2];
+                       } split(/\n/, $ARGV[2])) {
+                       if (!exists $not_in_next{$elem->[0]}) {
+                               if ($msg) {
+                                       print STDERR $msg;
+                                       undef $msg;
+                               }
+                               print STDERR " $elem->[1]\n";
+                       }
+               }
+       ' "$topic" "$not_in_next" "$not_in_master"
+       exit 1
+fi
+
+exit 0
+
+################################################################
+
+This sample hook safeguards topic branches that have been
+published from being rewound.
+
+The workflow assumed here is:
+
+ * Once a topic branch forks from "master", "master" is never
+   merged into it again (either directly or indirectly).
+
+ * Once a topic branch is fully cooked and merged into "master",
+   it is deleted.  If you need to build on top of it to correct
+   earlier mistakes, a new topic branch is created by forking at
+   the tip of the "master".  This is not strictly necessary, but
+   it makes it easier to keep your history simple.
+
+ * Whenever you need to test or publish your changes to topic
+   branches, merge them into "next" branch.
+
+The script, being an example, hardcodes the publish branch name
+to be "next", but it is trivial to make it configurable via
+$GIT_DIR/config mechanism.
+
+With this workflow, you would want to know:
+
+(1) ... if a topic branch has ever been merged to "next".  Young
+    topic branches can have stupid mistakes you would rather
+    clean up before publishing, and things that have not been
+    merged into other branches can be easily rebased without
+    affecting other people.  But once it is published, you would
+    not want to rewind it.
+
+(2) ... if a topic branch has been fully merged to "master".
+    Then you can delete it.  More importantly, you should not
+    build on top of it -- other people may already want to
+    change things related to the topic as patches against your
+    "master", so if you need further changes, it is better to
+    fork the topic (perhaps with the same name) afresh from the
+    tip of "master".
+
+Let's look at this example:
+
+                  o---o---o---o---o---o---o---o---o---o "next"
+                 /       /           /           /
+                /   a---a---b A     /           /
+               /   /               /           /
+              /   /   c---c---c---c B         /
+             /   /   /             \         /
+            /   /   /   b---b C     \       /
+           /   /   /   /             \     /
+    ---o---o---o---o---o---o---o---o---o---o---o "master"
+
+
+A, B and C are topic branches.
+
+ * A has one fix since it was merged up to "next".
+
+ * B has finished.  It has been fully merged up to "master" and "next",
+   and is ready to be deleted.
+
+ * C has not merged to "next" at all.
+
+We would want to allow C to be rebased, refuse A, and encourage
+B to be deleted.
+
+To compute (1):
+
+       git-rev-list ^master ^topic next
+       git-rev-list ^master        next
+
+       if these match, topic has not merged in next at all.
+
+To compute (2):
+
+       git-rev-list master..topic
+
+       if this is empty, it is fully merged to "master".
diff --git a/t/lib/repositories/repo1/hooks/update b/t/lib/repositories/repo1/hooks/update
new file mode 100644 (file)
index 0000000..e8c536f
--- /dev/null
@@ -0,0 +1,285 @@
+#!/bin/sh
+#
+# An example hook script to mail out commit update information.
+# It can also blocks tags that aren't annotated.
+# Called by git-receive-pack with arguments: refname sha1-old sha1-new
+#
+# To enable this hook, make this file executable by "chmod +x update".
+#
+# Config
+# ------
+# hooks.mailinglist
+#   This is the list that all pushes will go to; leave it blank to not send
+#   emails frequently.  The log email will list every log entry in full between
+#   the old ref value and the new ref value.
+# hooks.announcelist
+#   This is the list that all pushes of annotated tags will go to.  Leave it
+#   blank to just use the mailinglist field.  The announce emails list the
+#   short log summary of the changes since the last annotated tag
+# hooks.allowunannotated
+#   This boolean sets whether unannotated tags will be allowed into the
+#   repository.  By default they won't be.
+#
+# Notes
+# -----
+# All emails have their subjects prefixed with "[SCM]" to aid filtering.
+# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
+# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and info.
+
+# --- Constants
+EMAILPREFIX="[SCM] "
+LOGBEGIN="- Log -----------------------------------------------------------------"
+LOGEND="-----------------------------------------------------------------------"
+DATEFORMAT="%F %R %z"
+
+# --- Command line
+refname="$1"
+oldrev="$2"
+newrev="$3"
+
+# --- Safety check
+if [ -z "$GIT_DIR" ]; then
+       echo "Don't run this script from the command line." >&2
+       echo " (if you want, you could supply GIT_DIR then run" >&2
+       echo "  $0 <ref> <oldrev> <newrev>)" >&2
+       exit 1
+fi
+
+if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
+       echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
+       exit 1
+fi
+
+# --- Config
+projectdesc=$(cat $GIT_DIR/description)
+recipients=$(git-repo-config hooks.mailinglist)
+announcerecipients=$(git-repo-config hooks.announcelist)
+allowunannotated=$(git-repo-config --bool hooks.allowunannotated)
+
+# --- Check types
+newrev_type=$(git-cat-file -t "$newrev")
+
+case "$refname","$newrev_type" in
+       refs/tags/*,commit)
+               # un-annotated tag
+               refname_type="tag"
+               short_refname=${refname##refs/tags/}
+               if [ $allowunannotated != "true" ]; then
+                       echo "*** The un-annotated tag, $short_refname is not allowed in this repository" >&2
+                       echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
+                       exit 1
+               fi
+               ;;
+       refs/tags/*,tag)
+               # annotated tag
+               refname_type="annotated tag"
+               short_refname=${refname##refs/tags/}
+               # change recipients
+               if [ -n "$announcerecipients" ]; then
+                       recipients="$announcerecipients"
+               fi
+               ;;
+       refs/heads/*,commit)
+               # branch
+               refname_type="branch"
+               short_refname=${refname##refs/heads/}
+               ;;
+       refs/remotes/*,commit)
+               # tracking branch
+               refname_type="tracking branch"
+               short_refname=${refname##refs/remotes/}
+               # Should this even be allowed?
+               echo "*** Push-update of tracking branch, $refname.  No email generated." >&2
+               exit 0
+               ;;
+       *)
+               # Anything else (is there anything else?)
+               echo "*** Update hook: unknown type of update, \"$newrev_type\", to ref $refname" >&2
+               exit 1
+               ;;
+esac
+
+# Check if we've got anyone to send to
+if [ -z "$recipients" ]; then
+       # If the email isn't sent, then at least give the user some idea of what command
+       # would generate the email at a later date
+       echo "*** No recipients found - no email will be sent, but the push will continue" >&2
+       echo "*** for $0 $1 $2 $3" >&2
+       exit 0
+fi
+
+# --- Email parameters
+committer=$(git show --pretty=full -s $newrev | grep "^Commit: " | sed -e "s/^Commit: //")
+describe=$(git describe $newrev 2>/dev/null)
+if [ -z "$describe" ]; then
+       describe=$newrev
+fi
+
+# --- Email (all stdout will be the email)
+(
+# Generate header
+cat <<-EOF
+From: $committer
+To: $recipients
+Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname now at $describe
+X-Git-Refname: $refname
+X-Git-Reftype: $refname_type
+X-Git-Oldrev: $oldrev
+X-Git-Newrev: $newrev
+
+Hello,
+
+This is an automated email from the git hooks/update script, it was
+generated because a ref change was pushed to the repository.
+
+Updating $refname_type, $short_refname,
+EOF
+
+case "$refname_type" in
+       "tracking branch"|branch)
+               if expr "$oldrev" : '0*$' >/dev/null
+               then
+                       # If the old reference is "0000..0000" then this is a new branch
+                       # and so oldrev is not valid
+                       echo "  as a new  $refname_type"
+                   echo "        to  $newrev ($newrev_type)"
+                       echo ""
+                       echo $LOGBEGIN
+                       # This shows all log entries that are not already covered by
+                       # another ref - i.e. commits that are now accessible from this
+                       # ref that were previously not accessible
+                       git-rev-parse --not --all | git-rev-list --stdin --pretty $newref
+                       echo $LOGEND
+               else
+                       # oldrev is valid
+                       oldrev_type=$(git-cat-file -t "$oldrev")
+
+                       # Now the problem is for cases like this:
+                       #   * --- * --- * --- * (oldrev)
+                       #          \
+                       #           * --- * --- * (newrev)
+                       # i.e. there is no guarantee that newrev is a strict subset
+                       # of oldrev - (would have required a force, but that's allowed).
+                       # So, we can't simply say rev-list $oldrev..$newrev.  Instead
+                       # we find the common base of the two revs and list from there
+                       baserev=$(git-merge-base $oldrev $newrev)
+
+                       # Commit with a parent
+                       for rev in $(git-rev-list $newrev ^$baserev)
+                       do
+                               revtype=$(git-cat-file -t "$rev")
+                               echo "       via  $rev ($revtype)"
+                       done
+                       if [ "$baserev" = "$oldrev" ]; then
+                               echo "      from  $oldrev ($oldrev_type)"
+                       else
+                               echo "  based on  $baserev"
+                               echo "      from  $oldrev ($oldrev_type)"
+                               echo ""
+                               echo "This ref update crossed a branch point; i.e. the old rev is not a strict subset"
+                               echo "of the new rev.  This occurs, when you --force push a change in a situation"
+                               echo "like this:"
+                               echo ""
+                               echo " * -- * -- B -- O -- O -- O ($oldrev)"
+                               echo "            \\"
+                               echo "             N -- N -- N ($newrev)"
+                               echo ""
+                               echo "Therefore, we assume that you've already had alert emails for all of the O"
+                               echo "revisions, and now give you all the revisions in the N branch from the common"
+                               echo "base, B ($baserev), up to the new revision."
+                       fi
+                       echo ""
+                       echo $LOGBEGIN
+                       git-rev-list --pretty $newrev ^$baserev
+                       echo $LOGEND
+                       echo ""
+                       echo "Diffstat:"
+                       git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev
+               fi
+               ;;
+       "annotated tag")
+               # Should we allow changes to annotated tags?
+               if expr "$oldrev" : '0*$' >/dev/null
+               then
+                       # If the old reference is "0000..0000" then this is a new atag
+                       # and so oldrev is not valid
+                       echo "        to  $newrev ($newrev_type)"
+               else
+                       echo "        to  $newrev ($newrev_type)"
+                       echo "      from  $oldrev"
+               fi
+
+               # If this tag succeeds another, then show which tag it replaces
+               prevtag=$(git describe $newrev^ 2>/dev/null | sed 's/-g.*//')
+               if [ -n "$prevtag" ]; then
+                       echo "  replaces  $prevtag"
+               fi
+
+               # Read the tag details
+               eval $(git cat-file tag $newrev | \
+                       sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p')
+               tagged=$(date --date="1970-01-01 00:00:00 +0000 $ts seconds" +"$DATEFORMAT")
+
+               echo " tagged by  $tagger"
+               echo "        on  $tagged"
+
+               echo ""
+               echo $LOGBEGIN
+               echo ""
+
+               if [ -n "$prevtag" ]; then
+                       git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+               else
+                       git rev-list --pretty=short $newrev | git shortlog
+               fi
+
+               echo $LOGEND
+               echo ""
+               ;;
+       *)
+               # By default, unannotated tags aren't allowed in; if
+               # they are though, it's debatable whether we would even want an
+               # email to be generated; however, I don't want to add another config
+               # option just for that.
+               #
+               # Unannotated tags are more about marking a point than releasing
+               # a version; therefore we don't do the shortlog summary that we
+               # do for annotated tags above - we simply show that the point has
+               # been marked, and print the log message for the marked point for
+               # reference purposes
+               #
+               # Note this section also catches any other reference type (although
+               # there aren't any) and deals with them in the same way.
+               if expr "$oldrev" : '0*$' >/dev/null
+               then
+                       # If the old reference is "0000..0000" then this is a new tag
+                       # and so oldrev is not valid
+                       echo "  as a new  $refname_type"
+                       echo "        to  $newrev ($newrev_type)"
+               else
+                       echo "        to  $newrev ($newrev_type)"
+                       echo "      from  $oldrev"
+               fi
+               echo ""
+               echo $LOGBEGIN
+               git-show --no-color --root -s $newrev
+               echo $LOGEND
+               echo ""
+               ;;
+esac
+
+# Footer
+cat <<-EOF
+
+hooks/update
+---
+Git Source Code Management System
+$0 $1 \\
+  $2 \\
+  $3
+EOF
+#) | cat >&2
+) | /usr/sbin/sendmail -t
+
+# --- Finished
+exit 0
diff --git a/t/lib/repositories/repo1/info/exclude b/t/lib/repositories/repo1/info/exclude
new file mode 100644 (file)
index 0000000..2c87b72
--- /dev/null
@@ -0,0 +1,6 @@
+# git-ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/t/lib/repositories/repo1/objects/14/5dc3ef5d307be84cb9b325d70bd08aeed0eceb b/t/lib/repositories/repo1/objects/14/5dc3ef5d307be84cb9b325d70bd08aeed0eceb
new file mode 100644 (file)
index 0000000..d26a4fe
Binary files /dev/null and b/t/lib/repositories/repo1/objects/14/5dc3ef5d307be84cb9b325d70bd08aeed0eceb differ
diff --git a/t/lib/repositories/repo1/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 b/t/lib/repositories/repo1/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99
new file mode 100644 (file)
index 0000000..f95e389
Binary files /dev/null and b/t/lib/repositories/repo1/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 differ
diff --git a/t/lib/repositories/repo1/objects/36/c6c6708b8360d7023e8a1649c45bcf9b3bd818 b/t/lib/repositories/repo1/objects/36/c6c6708b8360d7023e8a1649c45bcf9b3bd818
new file mode 100644 (file)
index 0000000..fefba84
--- /dev/null
@@ -0,0 +1,2 @@
+xœÎAj\ 31\f@Ñ®}
\v‰dGc(¥«\1e 7°,95L2Ÿ\14zú–\1e\ f\ f~=n·>!Æü4‡;В¬²·dŒ¢¾-U³rL&¨†[q7ôê\1a>Ëðû\ 4n’V©¢ÖÄŵ-„9®KfÍÑ8oÌL´z(_óã\18ð¾\1f£—;\Êõ»Ï\1fx\19¥íoæú\17OǸ¾\ 2‘p$Œ’à\19      1ÔÿÅé\ fáPÌÀú së»Çð\vk:H…
\ No newline at end of file
diff --git a/t/lib/repositories/repo1/objects/3b/c0634310b9c62222bb0e724c11ffdfb297b4ac b/t/lib/repositories/repo1/objects/3b/c0634310b9c62222bb0e724c11ffdfb297b4ac
new file mode 100644 (file)
index 0000000..fa8f88a
Binary files /dev/null and b/t/lib/repositories/repo1/objects/3b/c0634310b9c62222bb0e724c11ffdfb297b4ac differ
diff --git a/t/lib/repositories/repo1/objects/3f/7567c7bdf7e7ebf410926493b92d398333116e b/t/lib/repositories/repo1/objects/3f/7567c7bdf7e7ebf410926493b92d398333116e
new file mode 100644 (file)
index 0000000..38437d2
Binary files /dev/null and b/t/lib/repositories/repo1/objects/3f/7567c7bdf7e7ebf410926493b92d398333116e differ
diff --git a/t/lib/repositories/repo1/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 b/t/lib/repositories/repo1/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
new file mode 100644 (file)
index 0000000..fc906d8
Binary files /dev/null and b/t/lib/repositories/repo1/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 differ
diff --git a/t/lib/repositories/repo1/objects/72/9a7c3f6ba5453b42d16a43692205f67fb23bc1 b/t/lib/repositories/repo1/objects/72/9a7c3f6ba5453b42d16a43692205f67fb23bc1
new file mode 100644 (file)
index 0000000..e59ece5
Binary files /dev/null and b/t/lib/repositories/repo1/objects/72/9a7c3f6ba5453b42d16a43692205f67fb23bc1 differ
diff --git a/t/lib/repositories/repo1/objects/82/b5fee28277349b6d46beff5fdf6a7152347ba0 b/t/lib/repositories/repo1/objects/82/b5fee28277349b6d46beff5fdf6a7152347ba0
new file mode 100644 (file)
index 0000000..7a1eb5e
Binary files /dev/null and b/t/lib/repositories/repo1/objects/82/b5fee28277349b6d46beff5fdf6a7152347ba0 differ
diff --git a/t/lib/repositories/repo1/objects/90/62594aebb5df0de7fb92413f17a9eced196c22 b/t/lib/repositories/repo1/objects/90/62594aebb5df0de7fb92413f17a9eced196c22
new file mode 100644 (file)
index 0000000..236ca51
Binary files /dev/null and b/t/lib/repositories/repo1/objects/90/62594aebb5df0de7fb92413f17a9eced196c22 differ
diff --git a/t/lib/repositories/repo1/refs/heads/master b/t/lib/repositories/repo1/refs/heads/master
new file mode 100644 (file)
index 0000000..7c4a265
--- /dev/null
@@ -0,0 +1 @@
+36c6c6708b8360d7023e8a1649c45bcf9b3bd818
index c7c3cb4..76eb857 100644 (file)
@@ -6,26 +6,63 @@ use Test::More qw/no_plan/;
 BEGIN { use_ok 'Gitalist::Model::Git' }
 
 my $c = bless {}, 'Gitalist';
-my $Git = Gitalist::Model::Git->new($c, { repo_dir => "$Bin/lib/repositories" });
+my $m = Gitalist::Model::Git->new($c, { repo_dir => "$Bin/lib/repositories" });
+isa_ok($m, 'Gitalist::Model::Git');
 
 # 'bare.git' is a bare git repository in the repository dir
 use Path::Class;
 my $repoBare = Path::Class::Dir->new('t/lib/repositories/bare.git');
-ok( $Git->is_git_repo( $repoBare ), 'is_git_repo true for bare git repo' );
+ok( $m->is_git_repo( $repoBare ), 'is_git_repo true for bare git repo' );
 
 # 'working' is a working copy w/ git repo in the repository dir
 my $repoWorking = Path::Class::Dir->new('t/lib/repositories/working');
-#ok( $Git->is_git_repo( $repoWorking ), 'is_git_repo true for git repo in working copy' );
+#ok( $m->is_git_repo( $repoWorking ), 'is_git_repo true for git repo in working copy' );
 
 # 'empty.git' is an empty directory in the repository dir
 my $repoEmpty = Path::Class::Dir->new('t/lib/repositories/empty.git');
-ok( ! $Git->is_git_repo( $repoEmpty ), 'is_git_repo is false for empty dir' );
+ok( ! $m->is_git_repo( $repoEmpty ), 'is_git_repo is false for empty dir' );
 
-my $projectList = $Git->list_projects;
-ok( scalar @{$projectList} == 1, 'list_projects returns an array with the correct number of members' );
+my $projectList = $m->list_projects;
+ok( scalar @{$projectList} == 2, 'list_projects returns an array with the correct number of members' );
 ok( $projectList->[0]->{name} eq 'bare.git', 'list_projects has correct name for "bare.git" repo' );
 #ok( $projectList->[1]->{name} eq 'working/.git', 'list_projects has correct name for "working" repo' );
 
-use Data::Dumper;
-#warn( Dumper($projectList) );
 
+# Liberally borrowed from rafl's gitweb
+my $repo = 'repo1';
+
+like($m->get_head_hash($repo), qr/^([0-9a-fA-F]{40})$/, 'get_head_hash');
+
+{
+    my @tree = $m->list_tree($repo, '3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
+
+    is(scalar @tree, 1);
+    is_deeply($tree[0], {
+            mode => oct 100644,
+            type => 'blob',
+            object => '257cc5642cb1a054f08cc83f2d943e56fd3ebe99',
+            file => 'file1'
+    });
+
+    is($m->get_object_mode_string($tree[0]), '-rw-r--r--');
+}
+
+is($m->get_object_type($repo, '729a7c3f6ba5453b42d16a43692205f67fb23bc1'), 'tree');
+is($m->get_object_type($repo, '257cc5642cb1a054f08cc83f2d943e56fd3ebe99'), 'blob');
+is($m->get_object_type($repo, '5716ca5987cbf97d6bb54920bea6adde242d87e6'), 'blob');
+
+is($m->cat_file($repo, '257cc5642cb1a054f08cc83f2d943e56fd3ebe99'), "foo\n");
+is($m->cat_file($repo, '5716ca5987cbf97d6bb54920bea6adde242d87e6'), "bar\n");
+
+is($m->diff($repo, '3bc0634310b9c62222bb0e724c11ffdfb297b4ac', '3f7567c7bdf7e7ebf410926493b92d398333116e'), <<EOD);
+diff --git a/file1 b/file1
+index 257cc56..5716ca5 100644
+--- a/file1
++++ b/file1
+@@ -1 +1 @@
+-foo
++bar
+EOD
+
+use Data::Dumper;
+warn( Dumper( $m->list_revs($repo) ));