Merge branch 'js/typofixes'
[gitweb.git] / t / lib-pack.sh
index 501078249dc7d5d5b27dd6b75a22086767a0eddf..c4d907a450a7863ff0fe32fe9aed7ef5c100dd3e 100644 (file)
@@ -79,6 +79,18 @@ pack_obj () {
                ;;
        esac
 
+       # If it's not a delta, we can convince pack-objects to generate a pack
+       # with just our entry, and then strip off the header (12 bytes) and
+       # trailer (20 bytes).
+       if test -z "$2"
+       then
+               echo "$1" | git pack-objects --stdout >pack_obj.tmp &&
+               size=$(wc -c <pack_obj.tmp) &&
+               dd if=pack_obj.tmp bs=1 count=$((size - 20 - 12)) skip=12 &&
+               rm -f pack_obj.tmp
+               return
+       fi
+
        echo >&2 "BUG: don't know how to print $1${2:+ (from $2)}"
        return 1
 }