summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2009-03-30 19:05:42 -0400
committerBrian Cully <bjc@kublai.com>2009-03-30 19:05:42 -0400
commit337f7be7057f98bee6509706d95d163c1a1212a7 (patch)
tree94c2e4743772f6ccdc867a8d58a07ac820108b55
parent413010caec9a5a1c5eee37a80f69b1fd5d195d31 (diff)
downloaddvcs-git-slides-337f7be7057f98bee6509706d95d163c1a1212a7.tar.gz
dvcs-git-slides-337f7be7057f98bee6509706d95d163c1a1212a7.zip
Fix a bug when reading the last object in a tree.
-rwxr-xr-xread_object.pl4
1 files changed, 4 insertions, 0 deletions
diff --git a/read_object.pl b/read_object.pl
index 10a4e56..40013d4 100755
--- a/read_object.pl
+++ b/read_object.pl
@@ -107,6 +107,10 @@ sub format_tree {
my @rc = ();
while (@tree) {
my ($info, $id) = (shift @tree, shift @tree);
+ unless ($id || @tree) {
+ $id = substr($info, -20);
+ $info = substr($info, 0, -21);
+ }
$info =~ /^([^ ]*) (.*)/;
my ($mode, $name) = ($1, $2);
my @bytes = unpack('C*', $id);