From 902996edd23313e80653a9f725413fc4107e7c70 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 1 Feb 2012 13:07:14 -0800 Subject: [PATCH 01/12] Added git-squash --- Readme.md | 5 +++++ bin/git-squash | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100755 bin/git-squash diff --git a/Readme.md b/Readme.md index f7e4fe6..43b18c6 100644 --- a/Readme.md +++ b/Readme.md @@ -25,6 +25,7 @@ $ brew install git-extras ## Commands - `git extras` + - `git squash` - `git summary` - `git changelog` - `git commits-since` @@ -202,6 +203,10 @@ $ git commits-since yesterday TJ Holowaychuk - Fixed readme ``` +## git-squash [msg] + + Squashes the current branch into a single commit with the given `[msg]`. + ## git-count Output commit count: diff --git a/bin/git-squash b/bin/git-squash new file mode 100755 index 0000000..a780b84 --- /dev/null +++ b/bin/git-squash @@ -0,0 +1,10 @@ +#!/bin/sh + +# TODO: warn on master + +branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` +msg=${1-Squashed $branch} +git checkout -b squash-tmp master \ + && git merge --squash $branch \ + && git commit -m $msg \ + && git branch -M $branch \ No newline at end of file From 86b3edb06da05ac24575939b5c3bdc8316991903 Mon Sep 17 00:00:00 2001 From: Hogan Long Date: Sat, 4 Feb 2012 13:18:42 -0500 Subject: [PATCH 02/12] Update man/git-fresh-branch.md --- man/git-fresh-branch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/git-fresh-branch.md b/man/git-fresh-branch.md index 2c4ab52..a936c02 100644 --- a/man/git-fresh-branch.md +++ b/man/git-fresh-branch.md @@ -13,7 +13,7 @@ git-fresh-branch(1) -- Create fresh branches <branchname> - The name of the branch to delete. + The name of the branch to create. ## EXAMPLES From d6443669192b8fc23b0d8ea0c8fd9a0601c6b5f9 Mon Sep 17 00:00:00 2001 From: Hogan Long Date: Sat, 4 Feb 2012 13:22:00 -0500 Subject: [PATCH 03/12] Update man/git-fresh-branch.1 --- man/git-fresh-branch.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/git-fresh-branch.1 b/man/git-fresh-branch.1 index 73742a7..c2f2851 100644 --- a/man/git-fresh-branch.1 +++ b/man/git-fresh-branch.1 @@ -16,7 +16,7 @@ Creates empty local branch named \. . .P -The name of the branch to delete\. +The name of the branch to create\. . .SH "EXAMPLES" . From e64d209fbf7b3735e500ec1e38b635a84e2a86e9 Mon Sep 17 00:00:00 2001 From: Hogan Long Date: Sat, 4 Feb 2012 13:22:38 -0500 Subject: [PATCH 04/12] Update man/git-fresh-branch.html --- man/git-fresh-branch.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/git-fresh-branch.html b/man/git-fresh-branch.html index 87e8fed..5e48b4d 100644 --- a/man/git-fresh-branch.html +++ b/man/git-fresh-branch.html @@ -86,7 +86,7 @@

<branchname>

-

The name of the branch to delete.

+

The name of the branch to create.

EXAMPLES

From 1c62e436b787bb88054f0c06fc84f14987adb381 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 4 Feb 2012 13:51:43 -0800 Subject: [PATCH 05/12] changed git-squash(1) --- Readme.md | 15 ++++++++++----- bin/git-squash | 16 +++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Readme.md b/Readme.md index 47b1510..53baeb8 100644 --- a/Readme.md +++ b/Readme.md @@ -202,10 +202,6 @@ $ git commits-since yesterday TJ Holowaychuk - Fixed readme ``` -## git-squash [msg] - - Squashes the current branch into a single commit with the given `[msg]`. - ## git-count Output commit count: @@ -353,7 +349,7 @@ Create empty local branch `name`: $ git fresh-branch docs ``` -## git-graft <src-branch> <dest-branch> +## git-graft <src-branch> [dest-branch] Merge commits from `src-branch` into `dest-branch`. (`dest-branch` defaults to `master`.) @@ -362,6 +358,15 @@ $ git graft new_feature dev $ git graft new_feature ``` +## git-squash <src-branch> [msg] + +Merge commits from `src-branch` into the current branch as a _single_ commit. When `[msg]` is given `git-commit(1)` will be invoked with that message. This is useful when small individual commits within a topic branch are irrelevant and you want to consider the topic as a single change. + +```bash +$ git squash fixed-cursor-styling +$ git squash fixed-cursor-styling "Fixed cursor styling" +``` + ## git-changelog Populate a file whose name matches `change|history -i_` with commits diff --git a/bin/git-squash b/bin/git-squash index a780b84..71fc7ed 100755 --- a/bin/git-squash +++ b/bin/git-squash @@ -1,10 +1,12 @@ #!/bin/sh -# TODO: warn on master +src=$1 +msg=$2 -branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` -msg=${1-Squashed $branch} -git checkout -b squash-tmp master \ - && git merge --squash $branch \ - && git commit -m $msg \ - && git branch -M $branch \ No newline at end of file +test -z $src && echo "source branch required." && exit 1 + +git merge --squash $src && git branch -d $src + +if test -n $msg + git commit -a -m "$msg" +fi \ No newline at end of file From 07d5ee82fff84fb75f31ea0f840068d85b70c23e Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 4 Feb 2012 13:59:07 -0800 Subject: [PATCH 06/12] fixed git-squash --- bin/git-squash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/git-squash b/bin/git-squash index 71fc7ed..98ab229 100755 --- a/bin/git-squash +++ b/bin/git-squash @@ -5,8 +5,8 @@ msg=$2 test -z $src && echo "source branch required." && exit 1 -git merge --squash $src && git branch -d $src +git merge --squash $src -if test -n $msg - git commit -a -m "$msg" -fi \ No newline at end of file +if test -n "$msg"; then + git commit -a -m "$msg" && git branch -D $src +fi From 0c2a86f05861a76943c975665c55e693eea75bbe Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 4 Feb 2012 14:01:02 -0800 Subject: [PATCH 07/12] Added _git_squash() to bash_completion.sh --- etc/bash_completion.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index 273c680..adff45f 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -32,6 +32,10 @@ _git_graft(){ __gitcomp "$(__git_heads)" } +_git_squash(){ + __gitcomp "$(__git_heads)" +} + __git_extras_workflow(){ __gitcomp "$(__git_heads | grep ^$1/ | sed s/^$1\\///g) finish" } From 4a56adb294c22c513b9977e64452e9b9a1925353 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 4 Feb 2012 14:01:59 -0800 Subject: [PATCH 08/12] Release 1.0.0 --- History.md | 5 +++++ bin/git-extras | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index e1a03bf..f4fdd87 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,9 @@ +1.0.0 / 2012-02-04 +================== + + * Added `git-squash BRANCH [MSG]` to merge as a single commit + 0.9.0 / 2012-01-15 ================== diff --git a/bin/git-extras b/bin/git-extras index 8424da6..06253a6 100755 --- a/bin/git-extras +++ b/bin/git-extras @@ -1,6 +1,6 @@ #!/bin/sh -VERSION="0.9.0" +VERSION="1.0.0" update() { local orig=$PWD From e7280f03054fa960fa20e8efaacc552183596401 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 7 Feb 2012 22:18:45 -0800 Subject: [PATCH 09/12] refactored git-summary(1) --- bin/git-summary | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/git-summary b/bin/git-summary index 7e9dc0e..19d1ffa 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -1,11 +1,12 @@ #!/bin/sh -COMMITISH="" -test $# -ne 0 && COMMITISH=$@ +commit="" +test $# -ne 0 && commit=$@ project=${PWD##*/} -commit_count=`git log --oneline $COMMITISH | wc -l | tr -d ' '` + +commit_count=`git log --oneline $commit | wc -l | tr -d ' '` file_count=`git ls-files | wc -l | tr -d ' '` -authors=`git shortlog -n -s $COMMITISH | awk ' +authors=`git shortlog -n -s $commit | awk ' { args[NR] = $0; sum += $0 } END { for (i = 1; i <= NR; ++i) { @@ -16,8 +17,8 @@ authors=`git shortlog -n -s $COMMITISH | awk ' echo echo " project: $project" echo " commits: $commit_count" -if test "$COMMITISH" = ""; then - echo " files : $file_count" +if test "$commit" = ""; then + echo " files : $file_count" fi echo " authors: " echo "$authors" From a1ea7e3a32ceb7af04daded32c16b0cad642e3b4 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 7 Feb 2012 22:40:37 -0800 Subject: [PATCH 10/12] Added git-effort(1) (not yet complete) --- bin/git-effort | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 bin/git-effort diff --git a/bin/git-effort b/bin/git-effort new file mode 100755 index 0000000..63a1622 --- /dev/null +++ b/bin/git-effort @@ -0,0 +1,20 @@ +#!/bin/sh + +files=`git ls-files` + +echo +echo " file commits" +echo + +for file in $files; do + commits=`git log --oneline $file | wc -l` + color='90' + + test $commits -gt 10 && color='33' + test $commits -gt 25 && color='93' + test $commits -gt 50 && color='32' + test $commits -gt 100 && color='92' + + printf " \033[${color}m%-45s %d\033[0m\n" $file $commits +done +echo From 453251a2089d4efc06c858de66f056277c3a3361 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 7 Feb 2012 22:42:59 -0800 Subject: [PATCH 11/12] docs for git-effort(1) --- Readme.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Readme.md b/Readme.md index 53baeb8..aec62a3 100644 --- a/Readme.md +++ b/Readme.md @@ -27,6 +27,7 @@ $ brew install git-extras - `git extras` - `git squash` - `git summary` + - `git effort` - `git changelog` - `git commits-since` - `git pull-request` @@ -164,6 +165,12 @@ the commmitish range: $ git summary v42.. ``` +## git-effort + + Displays "effort" statistics, currently just the number of commits per file, showing highlighting where the most activity is. + + ![git effort](http://f.cl.ly/items/2B0D1x3v3w023s1r2t0g/Grab.png) + ## git-repl GIT read-eval-print-loop: From c1d2dfc04c35774777e3a6ddd61439f0b9ee157f Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 7 Feb 2012 22:47:15 -0800 Subject: [PATCH 12/12] Release 1.1.0 --- History.md | 5 +++++ bin/git-extras | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index f4fdd87..cc5fe5c 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,9 @@ +1.1.0 / 2012-02-07 +================== + + * Added `git-effort(1)` (not yet complete) + 1.0.0 / 2012-02-04 ================== diff --git a/bin/git-extras b/bin/git-extras index 06253a6..e390392 100755 --- a/bin/git-extras +++ b/bin/git-extras @@ -1,6 +1,6 @@ #!/bin/sh -VERSION="1.0.0" +VERSION="1.1.0" update() { local orig=$PWD