Commits

Stefan Saasen committed 383c2b7 Merge

Merge branch 'man-pages'

Comments (0)

Files changed (6)

bin/git-filesize-history

-#!/usr/bin/env ruby
-# == Synopsis 
-#
-# Show the filesize history of blobs for a given path in the current git repository
-#
-# == Usage
-#
-# git filesize-history PATH
-#
-# E.g.
-#
-# git filesize-history src/Test.hs
-#
-#   Commit  b5388a5:  976.56 KB
-#   Commit  18898db:   329.00 B
-#   Commit  ac52f2f:     7.00 B
-require 'rubygems'
-require 'rdoc/usage'
+#!/bin/bash
 
-begin
-  require 'grit'
-rescue LoadError
-  puts 'Please install the "grit" gem first.'
-  puts "\t[sudo] gem install grit"
+if [ "$#" -lt 1 ]; then
+  echo "Usage:"
+  echo ""
+  echo "  git filesize-history PATH"
+  echo ""
   exit -1
-end
+fi
 
-RDoc::usage('usage') if ARGV.size < 1
+set -u
+set -e
 
-class Numeric
-  def to_human
-    units = %w{B KB MB GB TB}
-    e = (Math.log(self)/Math.log(1024)).floor
-    s = "%.2f" % (to_f / 1024**e)
-    #s.sub(/\.?0*$/, units[e])
-    "#{s} #{units[e]}"
-  end
-end
 
-def clean_path_relative(path)
-  File.expand_path(path).gsub(File.expand_path("."), '').gsub(/^\//, '')
-end
+FILEPATH=$1
+FILENAME=`basename ${FILEPATH}`
 
+#echo "File size history for \"${FILEPATH}\":"
 
-PATH = clean_path_relative(ARGV.first.to_s)
+for commit in $(git log --pretty="%h" -- ${FILEPATH}); do
+  bytes="`git ls-tree -l -r ${commit} | grep ${FILENAME} | awk '{print $4}'`"
+  human=`echo ${bytes} | awk '{ split( "B KB MB GB TB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] }'`
+  printf "Commit %10b: %10b (%d bytes)\n" $commit $human $bytes
+done
 
-repo = Grit::Repo.new('.')
-commits = repo.log('master', PATH)
-commits.each do |commit|
-  blob = commit.tree/PATH
-  puts "Commit #{commit.id_abbrev.rjust(8)}: #{blob.size.to_human.rjust(10)}" if blob
-end
-
-# vim: set filetype=ruby
+# vim: set filetype=sh

bin/git-find-blob

   exit -1
 fi
 
+set -u
+set -e
+
 blob="$1"
 shift
 git log "$@" --pretty=format:'%T %h %s' | while read tree commit subject ; do

bin/git-sync-local-tags

-#!/usr/bin/env ruby == Synopsis 
-#
-# Delete local tags that have been removed in the remote
-#
-# == Usage
-#
-#   git sync-local-tags
-#
-# Or use "-n" for dry-run and print out what would be deleted without actually
-# deleting any local tags.
-#
-#   git sync-local-tags -n
+#!/usr/bin/env ruby
 
 module Git
   class SyncTags

man/git-filesize-history.1

+.\" Manpage for git-filesize-history
+.TH man 1 "May 2012" "1.0" "git filesize-history man page"
+.SH NAME
+git filesize-history  \- Show how the filesize changed for a given PATH
+.SH SYNOPSIS
+git filesize-history PATH
+.SH DESCRIPTION
+Print out the filesize (human readable and in bytes) for the given path by traversing the history.
+
+This only prints the commits that are reachable from the current tip.
+.SH OPTIONS
+.TP
+.I PATH
+Path to a file in the local git repository. E.g.:
+.nf
+    git filesize-history src/Test.hs
+.fi
+.SH SEE ALSO
+git(1)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Stefan Saasen <stefan@saasen.me>

man/git-find-blob.1

+.\" Manpage for git-find-blob
+.TH man 1 "May 2012" "1.0" "git find-blob man page"
+.SH NAME
+git find-blob \- Find the commits that contain the given object id
+.SH SYNOPSIS
+git find-blob <object>
+.SH DESCRIPTION
+List all the commits that contain the object id <object>
+.SH OPTIONS
+.TP
+.I <object>
+Blob object id
+.SH SEE ALSO
+git(1)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Stefan Saasen <stefan@saasen.me>

man/git-sync-tags.1

+.\" Manpage for git-sync-tags
+.TH man 1 "May 2012" "1.0" "git sync-tags man page"
+.SH NAME
+git sync-tags  \- Delete local tags that have been removed in the remote
+.SH SYNOPSIS
+git sync-tags 
+.SH DESCRIPTION
+Delete all local tags that are not present anymore in the default remote.
+.SH OPTIONS
+.TP
+.I -n
+Don't remote the tags but print out what would be deleted (dry run)
+.nf
+    git sync-tags -n
+.fi
+.SH SEE ALSO
+git(1)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Stefan Saasen <stefan@saasen.me>