Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/ddollar/git-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
cv committed Oct 22, 2008
2 parents f8dd1f0 + aa4350b commit 2cb06c2
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 50 deletions.
46 changes: 46 additions & 0 deletions git-branch-status
@@ -0,0 +1,46 @@
#!/usr/bin/env ruby -wKU

require 'rubygems'
require 'term/ansicolor'

class String
include Term::ANSIColor

def color_nonzero(color)
(self.to_i == 0) ? self : self.send(color)
end
end

include Term::ANSIColor

current = nil

branches = `git branch`.split("\n").inject([]) do |array, line|
branch = line[2..-1].strip
current = branch if line[0..0] == '*'
array << branch
end

longest = branches.map { |b| b.length }.max

branches.sort.each do |branch|
remote = `git config branch.#{branch}.remote`.chomp

status = if remote.strip != ''
remote_branch = `git config branch.#{branch}.merge`.chomp.split('/').last
outgoing = `git log #{remote}/#{remote_branch}..#{branch} --pretty=oneline | wc -l`.strip
incoming = `git log #{branch}..#{remote}/#{remote_branch} --pretty=oneline | wc -l`.strip

"o:#{outgoing.color_nonzero(:green)} i:#{incoming.color_nonzero(:red)}"
else
"not tracking"
end

next if status == 'not tracking'

branch_display = (current == branch) ? branch.white.bold : branch

padding = longest - branch.length

puts " %s %s %s" % [ (' ' * padding), branch_display, status ]
end
2 changes: 2 additions & 0 deletions git-diff
@@ -0,0 +1,2 @@
#!/bin/sh
git diff --color --color-words $*
29 changes: 6 additions & 23 deletions git-incoming
Expand Up @@ -3,39 +3,22 @@
CURRENT_BRANCH=$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo "$(git branch | grep '^*' |sed s/\*\ //)"; fi)
if [ "${CURRENT_BRANCH}" != "" ]; then
REMOTE_REPOSITORY="$(echo ${1} | cut -d"/" -f1 -s)"
REMOTE_BRANCH="$(echo ${1} | cut -d"/" -f2 -s)"
if [ "${REMOTE_REPOSITORY}" == "" ]; then
REMOTE_REPOSITORY="${1}"
fi
TARGET="${1}"
# if no remote repository was specified, attempt to get it from the
# "tracked" branch of this branch
if [ "${REMOTE_REPOSITORY}" == "" ]; then
if [ "${TARGET}" == "" ]; then
TRACKING_REPOSITORY="$(git config branch.${CURRENT_BRANCH}.remote)"
# there is a tracking repository
if [ "${TRACKING_REPOSITORY}" != "" ]; then
REMOTE_REPOSITORY="${TRACKING_REPOSITORY}"
REMOTE_BRANCH="$(git config branch.${CURRENT_BRANCH}.merge | cut -d"/" -f3)"
TARGET="${REMOTE_REPOSITORY}/${REMOTE_BRANCH}"
fi
fi
# if there is no tracking repository, default to origin
if [ "${REMOTE_REPOSITORY}" == "" ]; then
REMOTE_REPOSITORY="origin"
fi
if [ "${REMOTE_BRANCH}" == "" ]; then
REMOTE_BRANCH="${CURRENT_BRANCH}"
fi
if [ "${SILENCE}" != "yes" ]; then
echo "From: ${REMOTE_REPOSITORY}/${REMOTE_BRANCH}"
echo ""
fi
echo "From: ${TARGET}"
echo ""
#git remote update &>/dev/null
git log ..${REMOTE_REPOSITORY}/${REMOTE_BRANCH} ${GIT_LOG_ARGUMENTS}
git log ..${TARGET}
fi
2 changes: 0 additions & 2 deletions git-incoming-short

This file was deleted.

2 changes: 2 additions & 0 deletions git-index
@@ -0,0 +1,2 @@
#!/bin/sh
git-diff --cached $*
29 changes: 6 additions & 23 deletions git-outgoing
Expand Up @@ -3,39 +3,22 @@
CURRENT_BRANCH=$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo "$(git branch | grep '^*' |sed s/\*\ //)"; fi)
if [ "${CURRENT_BRANCH}" != "" ]; then
REMOTE_REPOSITORY="$(echo ${1} | cut -d"/" -f1 -s)"
REMOTE_BRANCH="$(echo ${1} | cut -d"/" -f2 -s)"
if [ "${REMOTE_REPOSITORY}" == "" ]; then
REMOTE_REPOSITORY="${1}"
fi
TARGET="${1}"
# if no remote repository was specified, attempt to get it from the
# "tracked" branch of this branch
if [ "${REMOTE_REPOSITORY}" == "" ]; then
if [ "${TARGET}" == "" ]; then
TRACKING_REPOSITORY="$(git config branch.${CURRENT_BRANCH}.remote)"
# there is a tracking repository
if [ "${TRACKING_REPOSITORY}" != "" ]; then
REMOTE_REPOSITORY="${TRACKING_REPOSITORY}"
REMOTE_BRANCH="$(git config branch.${CURRENT_BRANCH}.merge | cut -d"/" -f3)"
TARGET="${REMOTE_REPOSITORY}/${REMOTE_BRANCH}"
fi
fi
# if there is no tracking repository, default to origin
if [ "${REMOTE_REPOSITORY}" == "" ]; then
REMOTE_REPOSITORY="origin"
fi
if [ "${REMOTE_BRANCH}" == "" ]; then
REMOTE_BRANCH="${CURRENT_BRANCH}"
fi
if [ "${SILENCE}" != "yes" ]; then
echo "To: ${REMOTE_REPOSITORY}/${REMOTE_BRANCH}"
echo ""
fi
echo "To: ${TARGET}"
echo ""
#git remote update &>/dev/null
git log ${REMOTE_REPOSITORY}/${REMOTE_BRANCH}.. ${GIT_LOG_ARGUMENTS}
git log ${TARGET}..
fi
2 changes: 0 additions & 2 deletions git-outgoing-short

This file was deleted.

0 comments on commit 2cb06c2

Please sign in to comment.