From 0c7bf665f228edd3fba8c2b54b8ede0898697dea Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Sat, 29 Aug 2015 13:09:42 +0200 Subject: [PATCH 01/57] Fix typo in variable name --- bin/git-effort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 6ee45bb77..f7ebe990b 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -180,7 +180,7 @@ else save_ifs=$IFS IFS=`echo -en "\n\b"` paths=(`git ls-files`) - IFS=$safe_ifs + IFS=$save_ifs unset save_ifs fi From a7f830b1e7bbc25d6d5a9f29e67b3da73a9d2567 Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 8 Sep 2015 16:08:50 +0800 Subject: [PATCH 02/57] remove duplicate checkout --- bin/git-bug | 3 +-- bin/git-chore | 3 +-- bin/git-feature | 3 +-- bin/git-refactor | 4 +--- 4 files changed, 4 insertions(+), 9 deletions(-) mode change 100644 => 100755 bin/git-chore diff --git a/bin/git-bug b/bin/git-bug index 37174e2c7..b748600ab 100755 --- a/bin/git-bug +++ b/bin/git-bug @@ -10,6 +10,5 @@ else echo "too many arguments; if not finishing a bug, only of new bug is expected" && exit 1 fi branch=bug/$1 - git checkout -b $branch &> /dev/null - test -n $? && git checkout $branch &> /dev/null + git checkout -b $branch fi diff --git a/bin/git-chore b/bin/git-chore old mode 100644 new mode 100755 index d4030f8fc..47ac0a579 --- a/bin/git-chore +++ b/bin/git-chore @@ -10,6 +10,5 @@ else echo "too many arguments; if not finishing a chore, only of new chore is expected" && exit 1 fi branch=chore/$1 - git checkout -b $branch &> /dev/null - test -n $? && git checkout $branch &> /dev/null + git checkout -b $branch fi diff --git a/bin/git-feature b/bin/git-feature index 9d105a1ec..5fd4cd8ba 100755 --- a/bin/git-feature +++ b/bin/git-feature @@ -20,6 +20,5 @@ else else branch=feature/$1 fi - git checkout -b $branch &> /dev/null - test -n $? && git checkout $branch &> /dev/null + git checkout -b $branch fi diff --git a/bin/git-refactor b/bin/git-refactor index 166f18049..445c0d253 100755 --- a/bin/git-refactor +++ b/bin/git-refactor @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# Removed unnecessary git checkout for bug, feature and refactor if test "$1" = "finish"; then test -z $2 && echo "refactor required." 1>&2 && exit 1 @@ -11,6 +10,5 @@ else echo "too many arguments; if not finishing a refactor, only of new refactoring is expected" && exit 1 fi branch=refactor/$1 - git checkout -b $branch &> /dev/null - test -n $? && git checkout $branch &> /dev/null + git checkout -b $branch fi From 38c7b0337226f60f0182929b89890ff0d79fe705 Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 8 Sep 2015 13:25:44 +0800 Subject: [PATCH 03/57] add alias to git-feature --- bin/git-feature | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/bin/git-feature b/bin/git-feature index 5fd4cd8ba..46292d36e 100755 --- a/bin/git-feature +++ b/bin/git-feature @@ -1,24 +1,41 @@ #!/usr/bin/env bash +branch_prefix=feature +declare -a argv +while test $# != 0 +do + case $1 in + -a|--alias ) + if [[ -n $2 ]] + then + shift # shift -a|-alias + branch_prefix=$1 + else + argv+=($1) # treat tail '-a' as + fi + ;; + * ) + argv+=($1) + ;; + esac + shift +done + concatargs(){ - delim='-' - str= - for i in "$@"; do - str="$str$delim$i" - done - branch=feature/${str:1} + str=$(IFS='-'; echo "$*") + branch="$branch_prefix"/$str } -if test "$1" = "finish"; then - test -z $2 && echo "feature required." 1>&2 && exit 1 - branch=feature/$2 - git merge --no-ff $branch && git delete-branch $branch +if test "${argv[0]}" = "finish"; then + test -z "${argv[1]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 + branch="$branch_prefix"/"${argv[1]}" + git merge --no-ff "$branch" && git delete-branch "$branch" else - test -z $1 && echo "feature required." 1>&2 && exit 1 - if test -n "$2"; then - concatargs ${@:2} + test -z "${argv[0]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 + if test -n "${argv[1]}"; then + concatargs "${argv[@]}" else - branch=feature/$1 + branch="$branch_prefix"/"${argv[0]}" fi git checkout -b $branch fi From f6f45990ab6718da256fc0d5644bdecb70a0b4ba Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 8 Sep 2015 13:37:30 +0800 Subject: [PATCH 04/57] update git-feature docs --- Commands.md | 2 +- man/git-feature.1 | 24 ++++++-- man/git-feature.1.html | 136 +++++++++++++++++++++++++++++++++++++++++ man/git-feature.md | 20 ++++-- 4 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 man/git-feature.1.html diff --git a/Commands.md b/Commands.md index bda485a67..13bd7faab 100644 --- a/Commands.md +++ b/Commands.md @@ -72,7 +72,7 @@ Sets up the `gh-pages` branch. (See [GitHub Pages](http://pages.github.com/) do ## git feature|refactor|bug|chore -Create the given feature, refactor, bug or chore branch `name`: +Create/Merge the given feature, refactor, bug or chore branch `name`: ```bash $ git feature dependencies diff --git a/man/git-feature.1 b/man/git-feature.1 index 2afa90c8c..5a21b9d2f 100644 --- a/man/git-feature.1 +++ b/man/git-feature.1 @@ -1,18 +1,24 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-FEATURE" "1" "April 2015" "" "" +.TH "GIT\-FEATURE" "1" "September 2015" "" "" . .SH "NAME" -\fBgit\-feature\fR \- Create feature branch +\fBgit\-feature\fR \- Create/Merge feature branch . .SH "SYNOPSIS" -\fBgit\-feature\fR [finish] +\fBgit\-feature\fR [\-a|\-\-alias branch_prefix] [finish] . .SH "DESCRIPTION" -Create the given feature branch +Create/Merge the given feature branch . .SH "OPTIONS" +<\-a|\-\-alias branch_prefix> +. +.P +use \fBbranch_prefix\fR instead of \fBfeature\fR +. +.P . .P @@ -30,10 +36,16 @@ The name of the feature branch\. $ git feature dependencies \.\.\. -$ git commit \-m "Some changes" +$ (feature/dependencies) git commit \-m "Some changes" \.\.\. -$ git checkout master +$ (feature/dependencies) git checkout master $ git feature finish dependencies + +$ git alias features "feature \-a features" +$ git features dependencies +$ (features/dependencies) \.\.\. +$ (features/dependencies) git checkout master +$ git features finish dependencies . .fi . diff --git a/man/git-feature.1.html b/man/git-feature.1.html new file mode 100644 index 000000000..253d12c56 --- /dev/null +++ b/man/git-feature.1.html @@ -0,0 +1,136 @@ + + + + + + git-feature(1) - Create/Merge feature branch + + + + +
+ + + +
    +
  1. git-feature(1)
  2. +
  3. +
  4. git-feature(1)
  5. +
+ +

NAME

+

+ git-feature - Create/Merge feature branch +

+ +

SYNOPSIS

+ +

git-feature [-a|--alias branch_prefix] [finish] <name>

+ +

DESCRIPTION

+ +

Create/Merge the given feature branch

+ +

OPTIONS

+ +

<-a|--alias branch_prefix>

+ +

use branch_prefix instead of feature

+ +

<finish>

+ +

Merge and delete the feature branch.

+ +

<name>

+ +

The name of the feature branch.

+ +

EXAMPLES

+ +
$ git feature dependencies
+...
+$ (feature/dependencies) git commit -m "Some changes"
+...
+$ (feature/dependencies) git checkout master
+$ git feature finish dependencies
+
+$ git alias features "feature -a features"
+$ git features dependencies
+$ (features/dependencies) ...
+$ (features/dependencies) git checkout master
+$ git features finish dependencies
+
+ +

AUTHOR

+ +

Written by Jesús Espino <jespinog@gmail.com>

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. September 2015
  3. +
  4. git-feature(1)
  5. +
+ +
+ + diff --git a/man/git-feature.md b/man/git-feature.md index d9e7a6eaa..0c78c9c60 100644 --- a/man/git-feature.md +++ b/man/git-feature.md @@ -1,16 +1,20 @@ -git-feature(1) -- Create feature branch +git-feature(1) -- Create/Merge feature branch ======================================= ## SYNOPSIS -`git-feature` [finish] <name> +`git-feature` [-a|--alias branch_prefix] [finish] <name> ## DESCRIPTION - Create the given feature branch + Create/Merge the given feature branch ## OPTIONS + <-a|--alias branch_prefix> + + use `branch_prefix` instead of `feature` + <finish> Merge and delete the feature branch. @@ -23,11 +27,17 @@ git-feature(1) -- Create feature branch $ git feature dependencies ... - $ git commit -m "Some changes" + $ (feature/dependencies) git commit -m "Some changes" ... - $ git checkout master + $ (feature/dependencies) git checkout master $ git feature finish dependencies + $ git alias features "feature -a features" + $ git features dependencies + $ (features/dependencies) ... + $ (features/dependencies) git checkout master + $ git features finish dependencies + ## AUTHOR Written by Jesús Espino <> From 639210660edf8abf9d1baa59bb29808faf35e0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 11 Sep 2015 20:14:36 +0200 Subject: [PATCH 05/57] Make sure git-authors doesn't return twice the same one. --- bin/git-authors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-authors b/bin/git-authors index 0996e3b27..2e51aff5b 100755 --- a/bin/git-authors +++ b/bin/git-authors @@ -21,7 +21,7 @@ fi # authors() { - git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' + git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' } # From 9916356b142dc2d34992b03784afe818afe668da Mon Sep 17 00:00:00 2001 From: spacewander Date: Sat, 12 Sep 2015 18:44:48 +0800 Subject: [PATCH 06/57] add alias conflict prompt --- Makefile | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ae4c71d43..6c2d2870e 100644 --- a/Makefile +++ b/Makefile @@ -23,17 +23,33 @@ install: $(eval TEMPFILE := $(shell mktemp -q ${TMPDIR:-/tmp}/git-extras.XXXXXX 2>/dev/null || mktemp -q)) @# chmod from rw-------(default) to rwxrwxr-x, so that users can exec the scripts @chmod 775 $(TEMPFILE) + $(eval EXISTED_ALIASES := $(shell \ + git config --get-regexp 'alias.*' | awk '{print "git-" substr($$1, 7)}')) @$(foreach COMMAND, $(COMMANDS_USED_WITH_GIT_REPO), \ - echo "... installing $(COMMAND)"; \ - head -1 bin/$(COMMAND) | cat - $(LIB) ./helper/is-git-repo > $(TEMPFILE); \ - tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ - cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ + disable=''; \ + if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \ + read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \ + test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \ + fi; \ + if test -z "$$disable"; then \ + echo "... installing $(COMMAND)"; \ + head -1 bin/$(COMMAND) | cat - $(LIB) ./helper/is-git-repo > $(TEMPFILE); \ + tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ + cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ + fi; \ ) @$(foreach COMMAND, $(COMMANDS_USED_WITHOUT_GIT_REPO), \ - echo "... installing $(COMMAND)"; \ - head -1 bin/$(COMMAND) | cat - $(LIB) > $(TEMPFILE); \ - tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ - cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ + disable=''; \ + if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \ + read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \ + test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \ + fi; \ + if test -z "$$disable"; then \ + echo "... installing $(COMMAND)"; \ + head -1 bin/$(COMMAND) | cat - $(LIB) > $(TEMPFILE); \ + tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ + cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ + fi; \ ) @if [ -z "$(wildcard man/git-*.1)" ]; then \ echo "WARNING: man pages not created, use 'make docs' (which requires 'ronn' ruby lib)"; \ From 86e1a7014cd2effe1b8260b760b3b6c5a738ac8f Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Sat, 29 Aug 2015 15:14:26 +0200 Subject: [PATCH 07/57] effort: More robust argument parsing Why: * The old way of handling arguments could make it difficult to make non-breaking changes because to be able to handle more arguments than the '--above' argument, the logic would need to be heavily refactored and demand restrictions on argument order. This change addresses the need by: * Parse arguments in a cleaner way * Make the command more future proof with respect to arguments Notable change is the synopsis. Please the see man page. --- bin/git-effort | 80 ++++++++++++++++----------------------------- man/git-effort.1 | 48 ++++++++++++++++++--------- man/git-effort.html | 41 +++++++++++++++-------- man/git-effort.md | 36 +++++++++++++------- 4 files changed, 112 insertions(+), 93 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index f7ebe990b..7d0be16cc 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -115,41 +115,32 @@ sort_effort() { < $tmp sort -rn -k 2 } -above_index=0 -has_above=false -next_is_above=false -num_paths=0 - -# Some implementations of `seq` gives "1\n0" for seq 0 -if [ $# -gt 0 ] ; then - for i in `seq ${#@}` - do - cur="${!i}" - - if "$next_is_above" ; then - above="$cur" - next_is_above=false - continue - fi - - case "$cur" in - --above) - if "$has_above" ; then - echo "error: --above can only be specified one time" 1>&2 - exit 1 - fi - next_is_above=true - has_above=true - above_index=$(( i - 1 )) - ;; - --*) - ;; - *) - num_paths=$(( num_paths + 1 )) - ;; - esac - done -fi +declare -a paths=() +while [ "${#}" -ge 1 ] ; do + + case "$1" in + --above) + shift + above=$1 + ;; + --) + shift + args_to_git_log=$(printf " %q" "${@:1}") + break + ;; + --*) + echo 1>&2 "error: unknown argument $1" + echo 1>&2 "error: if that argument was meant for git-log," + echo 1>&2 "error: please put it after two dashes ( -- )." + exit 1 + ;; + *) + paths+=( "$1" ) + ;; + esac + + shift +done # Exit if above-value is not an int if [ -z "${above##*[!0-9]*}" ] ; then @@ -157,26 +148,13 @@ if [ -z "${above##*[!0-9]*}" ] ; then exit 1 fi -args_before_above=`printf " %q" "${@:1:$above_index}"` - -num_args=$(( i - num_paths )) -if $has_above ; then offset=2 ; else offset=0 ; fi -from=$(( 1 + above_index + offset )) -len=$(( num_args - $(( above_index + offset)) )) -args_after_above=`printf " %q" "${@:$from:$len}"` - -args_to_git_log="${args_before_above#\ \'\'}${args_after_above#\ \'\'}" - -shift $num_args - +# remove empty quotes that appear when there are no arguments +args_to_git_log="${args_to_git_log#\ \'\'}" export args_to_git_log # [path ...] -declare -a paths=() -if test $# -ge 1; then - paths=("$@") -else +if test "${#paths}" -eq 0; then save_ifs=$IFS IFS=`echo -en "\n\b"` paths=(`git ls-files`) diff --git a/man/git-effort.1 b/man/git-effort.1 index ce9afef97..a30097477 100644 --- a/man/git-effort.1 +++ b/man/git-effort.1 @@ -1,13 +1,13 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-EFFORT" "1" "August 2015" "" "Git Extras" +.TH "GIT\-EFFORT" "1" "September 2015" "" "Git Extras" . .SH "NAME" \fBgit\-effort\fR \- Show effort statistics on file(s) . .SH "SYNOPSIS" -\fBgit\-effort\fR [\-\-above ] [] [[\-\-] \.\.\.] +\fBgit\-effort\fR [\-\-above ] [\.\.\.] [\-\- [\.\.\.]] . .SH "DESCRIPTION" Shows effort statistics about files in the repository\. @@ -28,22 +28,19 @@ Display includes: Ignore files with commits <= a value\. . .P -Run +\.\.\. . -.br -man \-P \'less +/Commit\e Limiting\' git\-log -. -.br -to read about options to limit which commits are counted\. +.P +Only count commits that touches the given paths\. . .P -Note: \fBgit\-effort\fR does not accept commit ranges\. +Note: \fBgit\-effort\fR does not accept revision ranges, but the underlying \fBgit log\fR does (See the examples)\. . .P -[\-\-] \.\.\. +\.\.\. . .P -Only count commits that touches the given paths\. +Options for \fBgit log\fR\. Note that you must use \fB\-\-\fR to separate options to \fBgit log\fR from options to \fBgit effort\fR\. This makes it possible to only count commits you are interested in\. Not all options are relevant in the context of \fBgit\-effort\fR, but those that are is listed under the "Commit Limiting" section on the \fBgit\-log\fR manpages\. . .SH "EXAMPLES" Note: Output will first appear unsorted, then the screen is cleared and the sorted list is output\. The initial unsorted list is not shown in the examples for brevity\. @@ -70,7 +67,7 @@ $ git effort \-\-above 5 git\-repl 7 5 -$ git effort \-\-after="one year ago" \-\-above 5 \-\-author="Leila Muhtasib" +$ git effort \-\-above 5 bin/* \-\- \-\-after="one year ago" \-\-author="Leila Muhtasib" file commits active days @@ -86,18 +83,37 @@ $ git effort \-\-after="one year ago" \-\-above 5 \-\-author="Leila Muhtasib" .IP "" 0 . .P -Showing statistics on directories is also possible +Showing statistics on directories is also possible: . .IP "" 4 . .nf -$ git effort bin man +$ git effort bin man \-\- \-\-after="one year ago" + + file commits active days + + bin\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 406 232 + man\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 118 80 +. +.fi +. +.IP "" 0 +. +.P +Only count commits in the specified revision range: +. +.P +$ git effort \-\- master\.\.feature +. +.IP "" 4 +. +.nf file commits active days - bin\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 406 232 - man\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 118 80 + bin/git\-effort\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 3 2 + man/git\-effort\.md\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. 1 1 . .fi . diff --git a/man/git-effort.html b/man/git-effort.html index f9d2a8f50..5a9408f1b 100644 --- a/man/git-effort.html +++ b/man/git-effort.html @@ -76,7 +76,7 @@

NAME

SYNOPSIS

-

git-effort [--above <value>] [<options>] [[--] <path>...]

+

git-effort [--above <value>] [<path>...] [-- [<log options>...]]

DESCRIPTION

@@ -92,15 +92,18 @@

OPTIONS

Ignore files with commits <= a value.

-

Run
- man -P 'less +/Commit\ Limiting' git-log
- to read about options to limit which commits are counted.

+

<path>...

-

Note: git-effort does not accept commit ranges.

+

Only count commits that touches the given paths.

-

[--] <path>...

+

Note: git-effort does not accept revision ranges, but the underlying git log does (See the examples).

-

Only count commits that touches the given paths.

+

<log options>...

+ +

Options for git log. Note that you must use -- to separate options to git log + from options to git effort. + This makes it possible to only count commits you are interested in. + Not all options are relevant in the context of git-effort, but those that are is listed under the "Commit Limiting" section on the git-log manpages.

EXAMPLES

@@ -124,7 +127,7 @@

EXAMPLES

git-repl 7 5 -$ git effort --after="one year ago" --above 5 --author="Leila Muhtasib" +$ git effort --above 5 bin/* -- --after="one year ago" --author="Leila Muhtasib" file commits active days @@ -136,19 +139,29 @@

EXAMPLES

git-graft 2 2 -

Showing statistics on directories is also possible

+

Showing statistics on directories is also possible:

-
$ git effort bin man
+
$ git effort bin man -- --after="one year ago"
 
   file                                          commits    active days
 
-  bin.......................................... 406         232
-  man.......................................... 118         80
+  bin.......................................... 406        232
+  man.......................................... 118        80
+
+ +

Only count commits in the specified revision range:

+ +

$ git effort -- master..feature

+ +
  file                                          commits    active days
+
+  bin/git-effort............................... 3          2
+  man/git-effort.md............................ 1          1
 

AUTHOR

-

Written by Leila Muhtasib <muhtasib@gmail.com>

+

Written by Leila Muhtasib <muhtasib@gmail.com>

REPORTING BUGS

@@ -161,7 +174,7 @@

SEE ALSO

  1. -
  2. August 2015
  3. +
  4. September 2015
  5. git-effort(1)
diff --git a/man/git-effort.md b/man/git-effort.md index da031be3a..90fb9c37c 100644 --- a/man/git-effort.md +++ b/man/git-effort.md @@ -3,7 +3,7 @@ git-effort(1) -- Show effort statistics on file(s) ## SYNOPSIS -`git-effort` [--above <value>] [<options>] [[--] <path>...] +`git-effort` [--above <value>] [<path>...] [-- [<log options>...]] ## DESCRIPTION @@ -19,15 +19,18 @@ git-effort(1) -- Show effort statistics on file(s) Ignore files with commits <= a value. - Run - man -P 'less +/Commit\ Limiting' git-log - to read about options to limit which commits are counted. + <path>... - Note: `git-effort` does not accept commit ranges. + Only count commits that touches the given paths. - [--] <path>... + Note: `git-effort` does not accept revision ranges, but the underlying `git log` does (See the examples). - Only count commits that touches the given paths. + <log options>... + + Options for `git log`. Note that you must use `--` to separate options to `git log` + from options to `git effort`. + This makes it possible to only count commits you are interested in. + Not all options are relevant in the context of `git-effort`, but those that are is listed under the "Commit Limiting" section on the `git-log` manpages. ## EXAMPLES @@ -51,7 +54,7 @@ git-effort(1) -- Show effort statistics on file(s) git-repl 7 5 - $ git effort --after="one year ago" --above 5 --author="Leila Muhtasib" + $ git effort --above 5 bin/* -- --after="one year ago" --author="Leila Muhtasib" file commits active days @@ -62,14 +65,23 @@ git-effort(1) -- Show effort statistics on file(s) git-changelog 3 2 git-graft 2 2 - Showing statistics on directories is also possible + Showing statistics on directories is also possible: + + $ git effort bin man -- --after="one year ago" + + file commits active days + + bin.......................................... 406 232 + man.......................................... 118 80 + + Only count commits in the specified revision range: - $ git effort bin man + $ git effort -- master..feature file commits active days - bin.......................................... 406 232 - man.......................................... 118 80 + bin/git-effort............................... 3 2 + man/git-effort.md............................ 1 1 ## AUTHOR From e91fd9623f4570ec235b312403717c4e423e5a8a Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Sun, 13 Sep 2015 23:56:56 +0200 Subject: [PATCH 08/57] effort: add usage message --- bin/git-effort | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/git-effort b/bin/git-effort index 7d0be16cc..46e354742 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -4,6 +4,13 @@ tmp=$(git_extra_mktemp) above=0 color= +# +# print usage message +# +usage() { + echo 1>&2 "usage: git effort [--above ] [...] [-- [...]]" +} + # # get dates for the given # @@ -129,6 +136,7 @@ while [ "${#}" -ge 1 ] ; do break ;; --*) + usage echo 1>&2 "error: unknown argument $1" echo 1>&2 "error: if that argument was meant for git-log," echo 1>&2 "error: please put it after two dashes ( -- )." From 80f060b213cc27e7b0fd35816bf5d180864f29ac Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Mon, 14 Sep 2015 00:00:39 +0200 Subject: [PATCH 09/57] effort: change order of arguments to function This makes git effort less prone to failing if someone passes formatting options --- bin/git-effort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 46e354742..3281b552a 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -15,7 +15,7 @@ usage() { # get dates for the given # dates() { - eval "git log --pretty='format: %ad' --date=short $args_to_git_log \"$1\"" + eval "git log $args_to_git_log --pretty='format: %ad' --date=short \"$1\"" } # From 6a000ec99bd3e32c84e6bff07dad400cfba73631 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Mon, 14 Sep 2015 13:18:47 +0100 Subject: [PATCH 10/57] effort, summary: Correctly estimate the number of active days The output of `git log` is not exactly in chronological order. The default sort option (--date-order) is described in the man page as follows: Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order. The `uniq` program will only remove duplicate lines if they follow each other. In order for this to work correctly, we need to ensure that the list of dates is exactly in chronological order. There doesn't seem to be a `git log` option to achieve this, but we can use the `sort` program. I used reverse sort (`sort -r`) since the output will be roughly reverse-sorted already. It's also worth noting that the default --date-order option sorts by commit date, but git-summary uses *author* date (%ai). Passing --author-date-order doesn't fix this issue, though, so I didn't change that. At the time of writing, this change reduces the number of 'active days' for git-extras.git from 367 to 331. --- bin/git-effort | 2 +- bin/git-summary | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 3281b552a..6dc859046 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -42,7 +42,7 @@ show_cursor_and_cleanup() { # active_days() { - echo "$1" | uniq | wc -l + echo "$1" | sort -r | uniq | wc -l } # diff --git a/bin/git-summary b/bin/git-summary index c1bcdce9f..8b69000fc 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -21,7 +21,7 @@ date() { # active_days() { - date $1 | uniq | awk ' + date $1 | sort -r | uniq | awk ' { sum += 1 } END { print sum } ' From c0ad975f227a6da9ae8bec6ab3bc6c6a292a162d Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Mon, 14 Sep 2015 11:01:35 -0400 Subject: [PATCH 11/57] Alphabetized list --- Commands.md | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Commands.md b/Commands.md index 13bd7faab..a9ac4c060 100644 --- a/Commands.md +++ b/Commands.md @@ -1,49 +1,49 @@ - - [`git extras`](#git-extras) - - [`git squash`](#git-squash) - - [`git summary`](#git-summary) - - [`git line-summary`](#git-line-summary) - - [`git effort`](#git-effort) + - [`git alias`](#git-alias) + - [`git archive-file`](#git-archive-file) - [`git authors`](#git-authors) - [`git changelog`](#git-changelog) - [`git clear`](#git-clear) - [`git commits-since`](#git-commits-since) + - [`git contrib`](#git-contrib) - [`git count`](#git-count) - [`git create-branch`](#git-create-branch) - [`git delete-branch`](#git-delete-branch) + - [`git delete-merged-branches`](#git-delete-merged-branches) - [`git delete-submodule`](#git-delete-submodule) - [`git delete-tag`](#git-delete-tag) - - [`git delete-merged-branches`](#git-delete-merged-branches) + - [`git delta`](#git-delta) + - [`git effort`](#git-effort) + - [`git extras`](#git-extras) + - [`git feature|refactor|bug|chore`](#git-featurerefactorbugchore) + - [`git fork`](#git-fork) - [`git fresh-branch`](#git-fresh-branch) - - [`git guilt`](#git-guilt) - - [`git merge-into`](#git-merge-into) + - [`git gh-pages`](#git-gh-pages) - [`git graft`](#git-graft) - - [`git alias`](#git-alias) + - [`git guilt`](#git-guilt) - [`git ignore`](#git-ignore) - [`git info`](#git-info) - - [`git fork`](#git-fork) + - [`git line-summary`](#git-line-summary) + - [`git local-commits`](#git-local-commits) + - [`git lock`](#git-lock) + - [`git locked`](#git-locked) + - [`git merge-into`](#git-merge-into) + - [`git merge-repo`](#git-merge-repo) + - [`git missing`](#git-missing) + - [`git obliterate`](#git-obliterate) + - [`git pr`](#git-pr) + - [`git psykorebase`](#git-psykorebase) - [`git release`](#git-release) - - [`git contrib`](#git-contrib) - [`git repl`](#git-repl) - - [`git undo`](#git-undo) - - [`git gh-pages`](#git-gh-pages) + - [`git reset-file`](#git-reset-file) + - [`git root`](#git-root) - [`git scp`](#git-scp) - [`git setup`](#git-setup) + - [`git squash`](#git-squash) + - [`git summary`](#git-summary) - [`git touch`](#git-touch) - - [`git obliterate`](#git-obliterate) - - [`git feature|refactor|bug|chore`](#git-featurerefactorbugchore) - - [`git local-commits`](#git-local-commits) - - [`git archive-file`](#git-archive-file) - - [`git missing`](#git-missing) - - [`git lock`](#git-lock) - - [`git locked`](#git-locked) + - [`git undo`](#git-undo) - [`git unlock`](#git-unlock) - - [`git reset-file`](#git-reset-file) - - [`git pr`](#git-pr) - - [`git root`](#git-root) - - [`git delta`](#git-delta) - - [`git merge-repo`](#git-merge-repo) - - [`git psykorebase`](#git-psykorebase) ## git extras From 5f61bfad6ecd86a45a0900d8aeef0ef0b5006cce Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 23 Sep 2015 19:27:19 +0200 Subject: [PATCH 12/57] summary: beware of locale issues, and pass options to line-summary * bin/git-summary: here. --- bin/git-summary | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/git-summary b/bin/git-summary index 8b69000fc..33f21be7c 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -48,7 +48,7 @@ file_count() { # authors() { - git shortlog -n -s $commit | awk ' + git shortlog -n -s $commit | LC_ALL=C awk ' { args[NR] = $0; sum += $0 } END { for (i = 1; i <= NR; ++i) { @@ -69,7 +69,8 @@ repository_age() { # summary if test "$1" = "--line"; then - git line-summary + shift + git line-summary "$@" echo else From 7b74567550e7d1fe3b9b08996acceff60f387814 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Thu, 24 Sep 2015 16:11:06 +0200 Subject: [PATCH 13/57] Add possibility to also checkout pull requests based on GitHub urls --- Commands.md | 9 +++++++++ bin/git-pr | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Commands.md b/Commands.md index a9ac4c060..7da4fc758 100644 --- a/Commands.md +++ b/Commands.md @@ -846,6 +846,15 @@ From https://github.com/tj/git-extras Switched to branch 'pr/226' ``` +You can also checkout a pull request based on a GitHub url + +```bash +$ git pr https://github.com/tj/git-extras/pull/453 +From https://github.com/tj/git-extras + * [new ref] refs/pull/453/head -> pr/453 +Switched to branch 'pr/453' +``` + To remove all local pull request branches, provide the magic `clean` parameter: ```bash diff --git a/bin/git-pr b/bin/git-pr index 35a65f3de..a7e1fdf86 100755 --- a/bin/git-pr +++ b/bin/git-pr @@ -1,11 +1,19 @@ #!/usr/bin/env bash -# Based on https://gist.github.com/gnarf/5406589 +# Based on https://gist.github.com/gnarf/5406589 and https://gist.github.com/jhnns/d654d9d6da6d3b749986 if test "$1" = "clean"; then git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref; do git branch -D ${ref#refs/heads/} done + exit 0 +elif [[ $1 =~ ^(https?://[^/]+/(.+))/pull/([0-9]+).*$ ]]; then + remote=${BASH_REMATCH[1]}.git + id=${BASH_REMATCH[3]} + branch=pr/$id else test -z $1 && echo "pr number required." 1>&2 && exit 1 - git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1 + remote=${2:-origin} + id=$1 + branch=pr/$id fi +git fetch -fu $remote refs/pull/$id/head:$branch && git checkout $branch From 5b285380e794ca059aa028eceffb5a773d222d15 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 2 Oct 2015 03:48:53 -0400 Subject: [PATCH 14/57] Makefile: escape $ used inside eval as shell variable --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6c2d2870e..a2f5caa57 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ install: @mkdir -p $(DESTDIR)$(BINPREFIX) @echo "... installing bins to $(DESTDIR)$(BINPREFIX)" @echo "... installing man pages to $(DESTDIR)$(MANPREFIX)" - $(eval TEMPFILE := $(shell mktemp -q ${TMPDIR:-/tmp}/git-extras.XXXXXX 2>/dev/null || mktemp -q)) + $(eval TEMPFILE := $(shell mktemp -q $${TMPDIR:-/tmp}/git-extras.XXXXXX 2>/dev/null || mktemp -q)) @# chmod from rw-------(default) to rwxrwxr-x, so that users can exec the scripts @chmod 775 $(TEMPFILE) $(eval EXISTED_ALIASES := $(shell \ From ed7dcb7682c7bfded308a98d48fd8f9f72df30ca Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 2 Oct 2015 05:47:08 -0400 Subject: [PATCH 15/57] Makefile: refactor is-git-repo inclusion logic This avoids the need for a big repeated block of code. --- Makefile | 26 ++++++++------------------ need_git_repo | 6 ++++++ 2 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 need_git_repo diff --git a/Makefile b/Makefile index a2f5caa57..a68ab189a 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,10 @@ BINS = $(wildcard bin/git-*) MANS = $(wildcard man/git-*.md) MAN_HTML = $(MANS:.md=.html) MAN_PAGES = $(MANS:.md=.1) +# Libraries used by all commands LIB = "helper/reset-env" "helper/git-extra-utility" -COMMANDS_USED_WITHOUT_GIT_REPO = git-alias git-extras git-fork git-setup -COMMANDS_USED_WITH_GIT_REPO = $(filter-out $(COMMANDS_USED_WITHOUT_GIT_REPO), \ - $(subst bin/, , $(BINS))) +COMMANDS = $(subst bin/, , $(BINS)) default: install @@ -25,7 +24,7 @@ install: @chmod 775 $(TEMPFILE) $(eval EXISTED_ALIASES := $(shell \ git config --get-regexp 'alias.*' | awk '{print "git-" substr($$1, 7)}')) - @$(foreach COMMAND, $(COMMANDS_USED_WITH_GIT_REPO), \ + @$(foreach COMMAND, $(COMMANDS), \ disable=''; \ if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \ read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \ @@ -33,20 +32,11 @@ install: fi; \ if test -z "$$disable"; then \ echo "... installing $(COMMAND)"; \ - head -1 bin/$(COMMAND) | cat - $(LIB) ./helper/is-git-repo > $(TEMPFILE); \ - tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ - cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ - fi; \ - ) - @$(foreach COMMAND, $(COMMANDS_USED_WITHOUT_GIT_REPO), \ - disable=''; \ - if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \ - read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \ - test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \ - fi; \ - if test -z "$$disable"; then \ - echo "... installing $(COMMAND)"; \ - head -1 bin/$(COMMAND) | cat - $(LIB) > $(TEMPFILE); \ + head -1 bin/$(COMMAND) > $(TEMPFILE); \ + cat $(LIB) >> $(TEMPFILE); \ + if grep "$(COMMAND)" need_git_repo >/dev/null; then \ + cat ./helper/is-git-repo >> $(TEMPFILE); \ + fi; \ tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \ cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \ fi; \ diff --git a/need_git_repo b/need_git_repo new file mode 100644 index 000000000..5f5e38880 --- /dev/null +++ b/need_git_repo @@ -0,0 +1,6 @@ +# A list of the commands that use is_git_repo, and should have +# it included in the "built" version of the command +git-alias +git-extras +git-fork +git-setup From b2817c7299765c425c3e11c7b175f49c36ddd76a Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 2 Oct 2015 06:35:38 -0400 Subject: [PATCH 16/57] git-effort: use portable terminal escape sequences Also uses "default color" instead of "black" for the low-activity things, so it still shows up on colorschemes that have dark backgrounds. --- bin/git-effort | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 6dc859046..e594f7187 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -18,12 +18,18 @@ dates() { eval "git log $args_to_git_log --pretty='format: %ad' --date=short \"$1\"" } +# tput, being quiet about unknown capabilities +tputq() { + tput "$@" 2>/dev/null + return 0 +} + # # hide cursor # hide_cursor() { - printf '\033[?25l' + tputq civis } # @@ -31,8 +37,8 @@ hide_cursor() { # show_cursor_and_cleanup() { - printf '\033[?25h' - printf '\033[m\n' + tputq cvvis + tputq sgr0 rm "$tmp" > /dev/null 2>&1 exit 0 } @@ -50,14 +56,16 @@ active_days() { # color_for() { - test $1 -gt 10 && color='33' - test $1 -gt 25 && color='33;1' - test $1 -gt 50 && color='93' - test $1 -gt 75 && color='93;1' - test $1 -gt 100 && color='31' - test $1 -gt 125 && color='31;1' - test $1 -gt 150 && color='91' - test $1 -gt 200 && color='91;1' + if [ $1 -gt 200 ]; then color="$(tputq setaf 1)$(tputq bold)" + elif [ $1 -gt 150 ]; then color="$(tputq setaf 1)" # red + elif [ $1 -gt 125 ]; then color="$(tputq setaf 2)$(tputq bold)" + elif [ $1 -gt 100 ]; then color="$(tputq setaf 2)" # green + elif [ $1 -gt 75 ]; then color="$(tputq setaf 93)$(tputq bold)" + elif [ $1 -gt 50 ]; then color="$(tputq setaf 93)" # purplish + elif [ $1 -gt 25 ]; then color="$(tputq setaf 3)$(tputq bold)" + elif [ $1 -gt 10 ]; then color="$(tputq setaf 3)" # yellow + else color="$(tputq sgr0)" # default color + fi } # @@ -67,6 +75,8 @@ color_for() { effort() { path=$1 local commit_dates + local color reset_color commits len dot f_dot i msg active + reset_color="$(tputq sgr0)" commit_dates=`dates "$path"` [ $? -gt 0 ] && exit 255 @@ -92,12 +102,12 @@ effort() { i=$(($i+1)) done - msg=$(printf " \033[${color}m%s %-10d" "$f_dot" $commits) + msg=$(printf " ${color}%s %-10d" "$f_dot" $commits) # active days active=`active_days "$commit_dates"` color_for $(( $active - $above )) - msg="$msg $(printf "\033[${color}m %d\033[0m\n" $active)" + msg="$msg $(printf "${color} %d${reset_color}\n" $active)" echo "$msg" } @@ -117,7 +127,7 @@ heading() { sort_effort() { clear - echo + echo " " heading < $tmp sort -rn -k 2 } @@ -180,6 +190,7 @@ export -f effort export -f color_for export -f active_days export -f dates +export -f tputq export above export log_args From 19f66943cbe857760305e20ae4b2b85f36a39fff Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 2 Oct 2015 08:35:04 -0400 Subject: [PATCH 17/57] git-summary: protect against character encoding issues with LC_ALL=C --- bin/git-line-summary | 2 +- bin/git-summary | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/git-line-summary b/bin/git-line-summary index 74c0166f1..940bd7326 100755 --- a/bin/git-line-summary +++ b/bin/git-line-summary @@ -9,7 +9,7 @@ single_file() { while read data do if [[ $(file "$data") = *text* ]]; then - git blame --line-porcelain "$data" 2>/dev/null | grep "^author\ " | sed -n 's/^author //p'; + git blame --line-porcelain "$data" 2>/dev/null | grep "^author\ " | LC_ALL=C sed -n 's/^author //p'; fi done } diff --git a/bin/git-summary b/bin/git-summary index 33f21be7c..7643f10c4 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -1,5 +1,6 @@ #!/usr/bin/env bash + SUBDIRECTORY_OK=Yes source "$(git --exec-path)/git-sh-setup" cd_to_toplevel @@ -63,7 +64,7 @@ authors() { # repository_age() { - git log --reverse --pretty=oneline --format="%ar" | head -n 1 | sed 's/ago//' + git log --reverse --pretty=oneline --format="%ar" | head -n 1 | LC_ALL=C sed 's/ago//' } # summary From 7ae2e0b9efb40ba6d2430d9076f215869d2df4c0 Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 8 Oct 2015 10:24:31 +0800 Subject: [PATCH 18/57] git-scp: use portable terminal escape sequences --- bin/git-scp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/git-scp b/bin/git-scp index 7481b6087..e12c3c9a3 100755 --- a/bin/git-scp +++ b/bin/git-scp @@ -1,10 +1,10 @@ #!/usr/bin/env bash -COLOR_RED() { echo -en "\033[31m"; } -COLOR_GREEN() { echo -en "\033[32m"; } -COLOR_YELLOW(){ echo -en "\033[33m"; } -COLOR_BLUE() { echo -en "\033[34m"; } -COLOR_RESET() { echo -en "\033[0m"; } +COLOR_RED() { test -t 1 && echo -n "$(tput setaf 1)"; } +COLOR_GREEN() { test -t 1 && echo -n "$(tput setaf 2)"; } +COLOR_YELLOW(){ test -t 1 && echo -n "$(tput setaf 3)"; } +COLOR_BLUE() { test -t 1 && echo -n "$(tput setaf 4)"; } +COLOR_RESET() { test -t 1 && echo -n "$(tput sgr 0)"; } function _test_git_scp() { From 02a440953b8565d5d2039ec2e4eee2d918f479c0 Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 8 Oct 2015 14:06:46 +0800 Subject: [PATCH 19/57] replace wildcard '?' to literal '?' Previously the `?` in the case statement will match any single letter. As a result, `git scp a` will act as the same as `git scp -h`. What we actually need is a literal '?'. --- bin/git-scp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-scp b/bin/git-scp index e12c3c9a3..c9c2f2142 100755 --- a/bin/git-scp +++ b/bin/git-scp @@ -170,7 +170,7 @@ function _error() case $(basename $0) in git-scp) case $1 in - ''|-h|?|help|--help) shift; _test_git_scp; _usage $@;; + ''|-h|'?'|help|--help) shift; _test_git_scp; _usage $@;; *) scp_and_stage $@;; esac ;; From 77f1c86b0d122a7b3f6fc0e1374cee47c069242d Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 8 Oct 2015 16:45:53 +0800 Subject: [PATCH 20/57] disable color if the output is not printed to tty --- bin/git-effort | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index e594f7187..0e79ed3f0 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -2,6 +2,8 @@ tmp=$(git_extra_mktemp) above=0 +# if the output won't be printed to tty, disable the color +test -t 1 && to_tty=true color= # @@ -56,15 +58,19 @@ active_days() { # color_for() { - if [ $1 -gt 200 ]; then color="$(tputq setaf 1)$(tputq bold)" - elif [ $1 -gt 150 ]; then color="$(tputq setaf 1)" # red - elif [ $1 -gt 125 ]; then color="$(tputq setaf 2)$(tputq bold)" - elif [ $1 -gt 100 ]; then color="$(tputq setaf 2)" # green - elif [ $1 -gt 75 ]; then color="$(tputq setaf 93)$(tputq bold)" - elif [ $1 -gt 50 ]; then color="$(tputq setaf 93)" # purplish - elif [ $1 -gt 25 ]; then color="$(tputq setaf 3)$(tputq bold)" - elif [ $1 -gt 10 ]; then color="$(tputq setaf 3)" # yellow - else color="$(tputq sgr0)" # default color + if [ "$to_tty" = true ]; then + if [ $1 -gt 200 ]; then color="$(tputq setaf 1)$(tputq bold)" + elif [ $1 -gt 150 ]; then color="$(tputq setaf 1)" # red + elif [ $1 -gt 125 ]; then color="$(tputq setaf 2)$(tputq bold)" + elif [ $1 -gt 100 ]; then color="$(tputq setaf 2)" # green + elif [ $1 -gt 75 ]; then color="$(tputq setaf 93)$(tputq bold)" + elif [ $1 -gt 50 ]; then color="$(tputq setaf 93)" # purplish + elif [ $1 -gt 25 ]; then color="$(tputq setaf 3)$(tputq bold)" + elif [ $1 -gt 10 ]; then color="$(tputq setaf 3)" # yellow + else color="$(tputq sgr0)" # default color + fi + else + color="" fi } @@ -76,7 +82,8 @@ effort() { path=$1 local commit_dates local color reset_color commits len dot f_dot i msg active - reset_color="$(tputq sgr0)" + reset_color="" + test "$to_tty" = true && reset_color="$(tputq sgr0)" commit_dates=`dates "$path"` [ $? -gt 0 ] && exit 255 @@ -191,6 +198,7 @@ export -f color_for export -f active_days export -f dates export -f tputq +export to_tty export above export log_args From 4b795fc42fe621ca87dd6447a9d43a18ab43b90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 8 Oct 2015 16:13:27 -0400 Subject: [PATCH 21/57] add simple sed command --- Commands.md | 5 ++ bin/git-sed | 69 +++++++++++++++++++++++ man/git-sed.1 | 64 +++++++++++++++++++++ man/git-sed.html | 144 +++++++++++++++++++++++++++++++++++++++++++++++ man/git-sed.md | 59 +++++++++++++++++++ 5 files changed, 341 insertions(+) create mode 100755 bin/git-sed create mode 100644 man/git-sed.1 create mode 100644 man/git-sed.html create mode 100644 man/git-sed.md diff --git a/Commands.md b/Commands.md index 7da4fc758..9d4c79151 100644 --- a/Commands.md +++ b/Commands.md @@ -38,6 +38,7 @@ - [`git reset-file`](#git-reset-file) - [`git root`](#git-root) - [`git scp`](#git-scp) + - [`git sed`](#git-sed) - [`git setup`](#git-setup) - [`git squash`](#git-squash) - [`git summary`](#git-summary) @@ -700,6 +701,10 @@ Remove the latest 3 commits: git undo 3 ``` +## git sed + +Run grep as directed but replace the given files with the pattern. + ## git setup Set up a git repository (if one doesn't exist), add all files, and make an initial commit. `dir` defaults to the current working directory. diff --git a/bin/git-sed b/bin/git-sed new file mode 100755 index 000000000..966e6438a --- /dev/null +++ b/bin/git-sed @@ -0,0 +1,69 @@ +#!/bin/sh + +usage() { + cat < ] + +Run git grep and then send results to sed for replacement with the +given flags, if -f is provided. + +Also runs git commit if -c is provided. +EOF +} + +# don't commit by default +do_commit() { + true +} + +while [ "X$1" != "X" ]; do + case "$1" in + -c|--commit) + if git status --porcelain | grep .; then + echo "you need to commit your changes before running with --commit" + exit 1 + fi + do_commit() { + git commit -m"replace $search with $replacement + +actual command: + + $command" -a + } + ;; + -f|--flags) + if [ "X$2" = "X" ]; then + usage + echo "missing argument for $1" + exit 1 + fi + shift + flags=$1 + ;; + -h|--help) + usage + exit + ;; + -*) + usage + echo "unkonwn flag: $1" + exit 1 + ;; + *) + if [ "X$search" = "X" ]; then + search="$1" + elif [ "X$replacement" = "X" ]; then + replacement="$1" + else + usage + echo "too many arguments: $1" + exit 1 + fi + ;; + esac + shift +done + +command="git grep -l '$search' | xargs sed -i 's/$search/$replacement/$flags'" +git grep -l "$search" | xargs sed -i "s/$search/$replacement/$flags" +do_commit diff --git a/man/git-sed.1 b/man/git-sed.1 new file mode 100644 index 000000000..f637cd25d --- /dev/null +++ b/man/git-sed.1 @@ -0,0 +1,64 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-SED" "1" "October 2015" "" "" +. +.SH "NAME" +\fBgit\-sed\fR \- replace patterns in git\-controlled files +. +.SH "SYNOPSIS" +\fBgit\-sed\fR [ \-c ] [ \-f \fIflags\fR ] \fIsearch\fR \fIreplacement\fR +. +.SH "DESCRIPTION" +Run git grep and then send results to sed for replacement with the given flags, if \-f is provided\. +. +.P +Also runs git commit if \-c is provided\. +. +.SH "OPTIONS" +\-c +. +.P +commit the resulting changes with a standard commit message detailing the exact command ran\. will fail if there are unstaged changes\. +. +.P +\-f +. +.P +will use the given regex flags in the sed command (for example "g" replaces multiple times on the same line)\. +. +.P + +. +.P +the pattern passed to grep and to the first part of the sed expression\. +. +.P + +. +.P +the replacement passed to sed, the second part of the sed expression\. +. +.SH "EXAMPLES" +. +.nf + +$ git sed \'my_function\' \'do_stuff\' +# \.\.\. only does the changes, without committing +$ git commit \-m"use proper function name" +$ git sed \-c \'do_stuff\' \'stuff\' +# \.\. does the changes and a commit +$ git sed \-f g do_stuff stuff +# \.\. g is actually pretty important, otherwise you will miss some +# stuff! +. +.fi +. +.SH "AUTHOR" +Written by Antoine Beaupré <\fIanarcat@debian\.org\fR> from inspiration by https://github\.com/da\-x/git\-search\-replace and http://stackoverflow\.com/questions/9651898/is\-there\-a\-git\-sed\-or\-equivalent +. +.SH "REPORTING BUGS" +<\fIhttps://github\.com/tj/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-sed.html b/man/git-sed.html new file mode 100644 index 000000000..a89796d30 --- /dev/null +++ b/man/git-sed.html @@ -0,0 +1,144 @@ + + + + + + git-sed(1) - replace patterns in git-controlled files + + + + +
+ + + +
    +
  1. git-sed(1)
  2. +
  3. +
  4. git-sed(1)
  5. +
+ +

NAME

+

+ git-sed - replace patterns in git-controlled files +

+ +

SYNOPSIS

+ +

git-sed [ -c ] [ -f flags ] search replacement

+ +

DESCRIPTION

+ +

Run git grep and then send results to sed for replacement with the +given flags, if -f is provided.

+ +

Also runs git commit if -c is provided.

+ +

OPTIONS

+ +

-c

+ +

commit the resulting changes with a standard commit message + detailing the exact command ran. will fail if there are unstaged + changes.

+ +

-f <flags>

+ +

will use the given regex flags in the sed command (for example "g" + replaces multiple times on the same line).

+ +

<search>

+ +

the pattern passed to grep and to the first part of the sed expression.

+ +

<replacement>

+ +

the replacement passed to sed, the second part of the sed expression.

+ +

EXAMPLES

+ +
$ git sed 'my_function' 'do_stuff'
+# ... only does the changes, without committing
+$ git commit -m"use proper function name"
+$ git sed -c 'do_stuff' 'stuff'
+# .. does the changes and a commit
+$ git sed -f g do_stuff stuff
+# .. g is actually pretty important, otherwise you will miss some
+# stuff!
+
+ +

AUTHOR

+ +

Written by Antoine Beaupré <anarcat@debian.org> from +inspiration by https://github.com/da-x/git-search-replace and +http://stackoverflow.com/questions/9651898/is-there-a-git-sed-or-equivalent

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. October 2015
  3. +
  4. git-sed(1)
  5. +
+ +
+ + diff --git a/man/git-sed.md b/man/git-sed.md new file mode 100644 index 000000000..19d1f48fd --- /dev/null +++ b/man/git-sed.md @@ -0,0 +1,59 @@ +git-sed(1) -- replace patterns in git-controlled files +====================================================== + +## SYNOPSIS + +`git-sed` [ -c ] [ -f ] + +## DESCRIPTION + +Run git grep and then send results to sed for replacement with the +given flags, if -f is provided. + +Also runs git commit if -c is provided. + +## OPTIONS + + -c + + commit the resulting changes with a standard commit message + detailing the exact command ran. will fail if there are unstaged + changes. + + -f <flags> + + will use the given regex flags in the sed command (for example "g" + replaces multiple times on the same line). + + <search> + + the pattern passed to grep and to the first part of the sed expression. + + <replacement> + + the replacement passed to sed, the second part of the sed expression. + +## EXAMPLES + + $ git sed 'my_function' 'do_stuff' + # ... only does the changes, without committing + $ git commit -m"use proper function name" + $ git sed -c 'do_stuff' 'stuff' + # .. does the changes and a commit + $ git sed -f g do_stuff stuff + # .. g is actually pretty important, otherwise you will miss some + # stuff! + +## AUTHOR + +Written by Antoine Beaupré <> from +inspiration by https://github.com/da-x/git-search-replace and +http://stackoverflow.com/questions/9651898/is-there-a-git-sed-or-equivalent + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> From 7f662708fa98af45ed081e4c642434454e70aceb Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 13 Oct 2015 23:54:52 +0800 Subject: [PATCH 22/57] use real purplish --- bin/git-effort | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 0e79ed3f0..c0ee24d81 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -63,8 +63,8 @@ color_for() { elif [ $1 -gt 150 ]; then color="$(tputq setaf 1)" # red elif [ $1 -gt 125 ]; then color="$(tputq setaf 2)$(tputq bold)" elif [ $1 -gt 100 ]; then color="$(tputq setaf 2)" # green - elif [ $1 -gt 75 ]; then color="$(tputq setaf 93)$(tputq bold)" - elif [ $1 -gt 50 ]; then color="$(tputq setaf 93)" # purplish + elif [ $1 -gt 75 ]; then color="$(tputq setaf 5)$(tputq bold)" + elif [ $1 -gt 50 ]; then color="$(tputq setaf 5)" # purplish elif [ $1 -gt 25 ]; then color="$(tputq setaf 3)$(tputq bold)" elif [ $1 -gt 10 ]; then color="$(tputq setaf 3)" # yellow else color="$(tputq sgr0)" # default color From 546ddf78af75ba9d8f378a0c88a00842d0775340 Mon Sep 17 00:00:00 2001 From: Jan Schulz Date: Sat, 17 Oct 2015 12:25:14 +0200 Subject: [PATCH 23/57] Use the default installation path in install.cmd --- install.cmd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.cmd b/install.cmd index 1e1866539..727b937d6 100644 --- a/install.cmd +++ b/install.cmd @@ -1,5 +1,9 @@ @ECHO OFF SET PREFIX=C:\SCM\PortableGit\mingw64 +:: default for Git for Windows 2.x +@if exist "%ProgramFiles%\Git" ( + set PREFIX="%ProgramFiles%\Git\mingw64" +) IF NOT "%~1"=="" SET PREFIX="%~1" SET HTMLDIR=%PREFIX%\share\doc\git-doc SET GITEXTRAS=%~dp0 From 5a80928b89106699d6c214d435f4582e4039e3d0 Mon Sep 17 00:00:00 2001 From: Jan Schulz Date: Sat, 17 Oct 2015 12:30:40 +0200 Subject: [PATCH 24/57] git-changelog: option to only use merges using `-m` or `--merges-only` will only show the merge commit messages. It will also use the body of the merge commit message in addition to the subject, as github merges usually have a useless subject line for commit messages. If used with `-n/--no-merges`, the last one specified will win. --- bin/git-changelog | 21 ++++++++++++++++----- man/git-changelog.md | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bin/git-changelog b/bin/git-changelog index f6df152d6..dc27a8b1d 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -4,6 +4,8 @@ DEF_TAG_RECENT="n.n.n" GIT_LOG_OPTS="$(git config changelog.opts)" GIT_LOG_FORMAT="$(git config changelog.format)" [[ -z "$GIT_LOG_FORMAT" ]] && GIT_LOG_FORMAT=' * %s' +GIT_MERGELOG_FORMAT="$(git config changelog.mergeformat)" +[[ -z "$GIT_MERGELOG_FORMAT" ]] && GIT_MERGELOG_FORMAT=' * %s%n%w(64,4,4)%b' GIT_EDITOR="$(git var GIT_EDITOR)" PROGNAME="git-changelog" @@ -26,6 +28,7 @@ OPTIONS: -f, --final-tag Newest tag to retrieve commits from in a range -s, --start-tag Oldest tag to retrieve commits from in a range -n, --no-merges Suppress commits from merged branches + -m, --merges-only Only uses merge commits (uses both subject and body of commit) -p, --prune-old Replace existing Changelog entirely with new content -x, --stdout Write output to stdout instead of to a Changelog file -h, --help, ? Show this message @@ -143,13 +146,13 @@ _fetchCommitRange() { local final_tag="$3" if [[ "$list_all" == true ]]; then - git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" + git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" elif [[ -n "$final_tag" && "$start_tag" == "null" ]]; then - git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${final_tag}" + git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${final_tag}" elif [[ -n "$final_tag" ]]; then - git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${start_tag}"'..'"${final_tag}" + git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${start_tag}"'..'"${final_tag}" elif [[ -n "$start_tag" ]]; then - git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" "${start_tag}"'..' + git log $GIT_LOG_OPTS --pretty=format:"${CUR_GIT_LOG_FORMAT}" "${start_tag}"'..' fi | sed 's/^ \* \*/ */g' } @@ -375,6 +378,11 @@ main() { ;; -n | --no-merges ) GIT_LOG_OPTS='--no-merges' + CUR_GIT_LOG_FORMAT="$GIT_LOG_FORMAT" + ;; + -m | --merges-only ) + GIT_LOG_OPTS='--merges' + CUR_GIT_LOG_FORMAT="$GIT_MERGELOG_FORMAT" ;; -p | --prune-old ) option=( $(_setValueForKeyFakeAssocArray "prune_old" true "${option[*]}") ) @@ -393,7 +401,10 @@ main() { esac shift done - + + # The default log format unless already set + [[ -z "$CUR_GIT_LOG_FORMAT" ]] && CUR_GIT_LOG_FORMAT="$GIT_LOG_FORMAT" + local _tag="$(_valueForKeyFakeAssocArray "start_tag" "${option[*]}")" if [[ -n "${_tag}" ]]; then start_tag="$(git describe --tags --abbrev=0 "${_tag}" 2>/dev/null)" diff --git a/man/git-changelog.md b/man/git-changelog.md index 12f3f6588..3dd650763 100644 --- a/man/git-changelog.md +++ b/man/git-changelog.md @@ -42,6 +42,10 @@ git-changelog(1) -- Generate a changelog report Filters out merge commits (commits with more than 1 parent) from generated changelog. + -m, --merges-only + + Uses only merge commits (commits with more than 1 parent) for generated changelog. It also changes the default format to include the merge commit messages body, as on github the commits subject line only contains the branch name but no information about the content of the merge. + -p, --prune-old Replace existing changelog entirely with newly generated content, thereby disabling the default behavior of appending the content of any detected changelog to the end of newly generated content. From 106acae94377a05ca754985a819063ffff1158f9 Mon Sep 17 00:00:00 2001 From: Nimit Kalra Date: Sun, 18 Oct 2015 13:44:13 -0500 Subject: [PATCH 25/57] Regenerate git-changelog man pages (.html and .1) for #471. --- man/git-changelog.1 | 8 +++++++- man/git-changelog.html | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/man/git-changelog.1 b/man/git-changelog.1 index 46a409384..023ad322c 100644 --- a/man/git-changelog.1 +++ b/man/git-changelog.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-CHANGELOG" "1" "April 2015" "" "" +.TH "GIT\-CHANGELOG" "1" "October 2015" "" "Git Extras" . .SH "NAME" \fBgit\-changelog\fR \- Generate a changelog report @@ -61,6 +61,12 @@ When specifying a range, the oldest tag to retrieve commits from\. Commits will Filters out merge commits (commits with more than 1 parent) from generated changelog\. . .P +\-m, \-\-merges\-only +. +.P +Uses only merge commits (commits with more than 1 parent) for generated changelog\. It also changes the default format to include the merge commit messages body, as on github the commits subject line only contains the branch name but no information about the content of the merge\. +. +.P \-p, \-\-prune\-old . .P diff --git a/man/git-changelog.html b/man/git-changelog.html index 14b39a55c..ef6bc11e2 100644 --- a/man/git-changelog.html +++ b/man/git-changelog.html @@ -65,7 +65,7 @@
  1. git-changelog(1)
  2. -
  3. +
  4. Git Extras
  5. git-changelog(1)
@@ -115,6 +115,10 @@

OPTIONS

Filters out merge commits (commits with more than 1 parent) from generated changelog.

+

-m, --merges-only

+ +

Uses only merge commits (commits with more than 1 parent) for generated changelog. It also changes the default format to include the merge commit messages body, as on github the commits subject line only contains the branch name but no information about the content of the merge.

+

-p, --prune-old

Replace existing changelog entirely with newly generated content, thereby disabling the default behavior of appending the content of any detected changelog to the end of newly generated content.

@@ -159,7 +163,7 @@

EXAMPLES

AUTHOR

-

Written by Mark Eissler <mark@mixtur.com>

+

Written by Mark Eissler <mark@mixtur.com>

REPORTING BUGS

@@ -172,7 +176,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. October 2015
  5. git-changelog(1)
From b4f4dd1197c69385cebf5bb1e9943a05cd7fe7ee Mon Sep 17 00:00:00 2001 From: Jan Schulz Date: Thu, 22 Oct 2015 10:35:24 +0200 Subject: [PATCH 26/57] Add more info how to set global gitignore --- bin/git-ignore | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/git-ignore b/bin/git-ignore index f710bedd7..85bd5e417 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -14,7 +14,15 @@ function show_global { } function add_global { - add_patterns `git config --global core.excludesfile` "$@" + local global_gitignore=$(git config --global core.excludesfile) + if [ -z "$global_gitignore" ]; then + echo "Can't find global .gitignore." + echo "" + echo "Use 'git config --global --add core.excludesfile ~/.gitignore-global' to set the path to your global gitignore file to '~/.gitignore-global'." + echo "" + else + add_patterns `git config --global core.excludesfile` "$@" + fi } function show_local { From 91ca995edc4d360e5b3b71987d9bf10d65c4e4d4 Mon Sep 17 00:00:00 2001 From: Nimit Kalra Date: Sun, 27 Dec 2015 11:26:38 -0600 Subject: [PATCH 27/57] Update all man pages. --- man/git-alias.1 | 2 +- man/git-alias.1.html | 145 ------------------ man/git-alias.html | 10 +- man/git-archive-file.1 | 2 +- man/git-archive-file.html | 4 +- man/git-authors.1 | 19 ++- man/git-authors.html | 9 +- man/git-back.1 | 2 +- man/git-back.html | 4 +- man/git-bug.1 | 2 +- man/git-bug.html | 4 +- man/git-changelog.1 | 2 +- man/git-changelog.html | 6 +- man/git-chore.1 | 2 +- man/git-chore.html | 4 +- man/git-clear.1 | 23 +-- man/git-clear.html | 17 +- man/git-commits-since.1 | 2 +- man/git-commits-since.html | 4 +- man/git-contrib.1 | 2 +- man/git-contrib.html | 6 +- man/git-count.1 | 2 +- man/git-count.html | 4 +- man/git-create-branch.1 | 2 +- man/git-create-branch.html | 4 +- man/git-delete-branch.1 | 2 +- man/git-delete-branch.html | 4 +- man/git-delete-merged-branches.1 | 2 +- man/git-delete-merged-branches.html | 4 +- man/git-delete-submodule.1 | 2 +- man/git-delete-submodule.html | 4 +- man/git-delete-tag.1 | 2 +- man/git-delete-tag.html | 4 +- man/git-delta.1 | 2 +- man/git-delta.html | 4 +- man/git-effort.1 | 2 +- man/git-effort.html | 6 +- man/git-extras.1 | 16 +- man/git-extras.html | 10 +- man/git-extras.md | 6 +- man/git-feature.1 | 2 +- man/git-feature.1.html | 136 ---------------- man/git-feature.html | 26 +++- man/git-fork.1 | 2 +- man/git-fork.html | 12 +- man/git-fresh-branch.1 | 2 +- man/git-fresh-branch.html | 4 +- man/git-gh-pages.1 | 2 +- man/git-gh-pages.html | 4 +- man/git-graft.1 | 2 +- man/git-graft.html | 6 +- man/git-guilt.1 | 2 +- man/git-guilt.html | 6 +- man/git-ignore-io.1 | 2 +- ...it-ignore-io.1.html => git-ignore-io.html} | 4 +- man/git-ignore.1 | 2 +- man/git-ignore.html | 6 +- man/git-info.1 | 2 +- man/git-info.html | 4 +- man/git-line-summary.1 | 2 +- man/git-line-summary.html | 4 +- man/git-local-commits.1 | 2 +- man/git-local-commits.html | 4 +- man/git-lock.1 | 2 +- man/git-lock.html | 4 +- man/git-locked.1 | 2 +- man/git-locked.html | 4 +- man/git-merge-into.1 | 2 +- man/git-merge-into.html | 6 +- man/git-merge-repo.1 | 2 +- man/git-merge-repo.html | 4 +- man/git-missing.1 | 2 +- man/git-missing.html | 4 +- man/git-pr.1 | 2 +- man/git-pr.html | 2 +- man/git-psykorebase.1 | 2 +- man/git-psykorebase.html | 6 +- man/git-rebase-patch.1 | 2 +- man/git-rebase-patch.html | 4 +- man/git-refactor.1 | 2 +- man/git-refactor.html | 4 +- man/git-release.1 | 2 +- man/git-release.html | 6 +- man/git-rename-tag.1 | 2 +- man/git-rename-tag.html | 4 +- man/git-repl.1 | 2 +- man/git-repl.html | 4 +- man/git-reset-file.1 | 2 +- man/git-reset-file.html | 4 +- man/git-root.1 | 2 +- man/git-root.html | 4 +- man/git-scp.1 | 2 +- man/git-scp.html | 4 +- man/git-sed.1 | 2 +- man/git-sed.html | 4 +- man/git-setup.1 | 2 +- man/git-setup.html | 4 +- man/git-show-merged-branches.1 | 2 +- man/git-show-merged-branches.html | 4 +- man/git-show-tree.1 | 2 +- man/git-show-tree.html | 4 +- man/git-show-unmerged-branches.1 | 2 +- man/git-show-unmerged-branches.html | 4 +- man/git-squash.1 | 2 +- man/git-squash.html | 4 +- man/git-summary.1 | 2 +- man/git-summary.html | 6 +- man/git-touch.1 | 2 +- man/git-touch.html | 4 +- man/git-undo.1 | 2 +- man/git-undo.html | 4 +- man/git-unlock.1 | 2 +- man/git-unlock.html | 4 +- man/index.txt | 4 + 114 files changed, 249 insertions(+), 502 deletions(-) delete mode 100644 man/git-alias.1.html delete mode 100644 man/git-feature.1.html rename man/{git-ignore-io.1.html => git-ignore-io.html} (93%) diff --git a/man/git-alias.1 b/man/git-alias.1 index d009922b7..06806b285 100644 --- a/man/git-alias.1 +++ b/man/git-alias.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-ALIAS" "1" "August 2015" "" "" +.TH "GIT\-ALIAS" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-alias\fR \- Define, search and show aliases diff --git a/man/git-alias.1.html b/man/git-alias.1.html deleted file mode 100644 index 384b4e927..000000000 --- a/man/git-alias.1.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - git-alias(1) - Define, search and show aliases - - - - -
- - - -
    -
  1. git-alias(1)
  2. -
  3. -
  4. git-alias(1)
  5. -
- -

NAME

-

- git-alias - Define, search and show aliases -

- -

SYNOPSIS

- -

git-alias
-git-alias <search-pattern>
-git-alias <alias-name> <command>

- -

DESCRIPTION

- -

List all aliases, show one alias, or set one (global) alias.

- -

OPTIONS

- -

<search-pattern>

- -

The pattern used to search aliases.

- -

<alias-name>

- -

The name of the alias to create.

- -

<command>

- -

The command for which you are creating an alias.

- -

EXAMPLES

- -

Defining a new alias:

- -
$ git alias last "cat-file commit HEAD"
-
- -

Providing only one argument, git-alias searchs for aliases matching the given value:

- -
$ git alias ^la
-last = cat-file commit HEAD
-
- -

git-alias will show all aliases if no argument is given:

- -
$ git alias
-s = status
-amend = commit --amend
-rank = shortlog -sn --no-merges
-whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
-whois = !sh -c 'git log -i -1 --pretty="format:%an <%ae>
-
- -

AUTHOR

- -

Written by Jonhnny Weslley <jw@jonhnnyweslley.net>

- -

REPORTING BUGS

- -

<https://github.com/tj/git-extras/issues>

- -

SEE ALSO

- -

<https://github.com/tj/git-extras>

- - -
    -
  1. -
  2. August 2015
  3. -
  4. git-alias(1)
  5. -
- -
- - diff --git a/man/git-alias.html b/man/git-alias.html index e65783707..e00864a24 100644 --- a/man/git-alias.html +++ b/man/git-alias.html @@ -65,7 +65,7 @@
  1. git-alias(1)
  2. -
  3. Git Extras
  4. +
  5. git-alias(1)
@@ -77,7 +77,7 @@

NAME

SYNOPSIS

git-alias
-git-alias <search-term>
+git-alias <search-pattern>
git-alias <alias-name> <command>

DESCRIPTION

@@ -86,7 +86,7 @@

DESCRIPTION

OPTIONS

-

<search-term>

+

<search-pattern>

The pattern used to search aliases.

@@ -123,7 +123,7 @@

EXAMPLES

AUTHOR

-

Written by Jonhnny Weslley <jw@jonhnnyweslley.net>

+

Written by Jonhnny Weslley <jw@jonhnnyweslley.net>

REPORTING BUGS

@@ -136,7 +136,7 @@

SEE ALSO

  1. -
  2. August 2015
  3. +
  4. December 2015
  5. git-alias(1)
diff --git a/man/git-archive-file.1 b/man/git-archive-file.1 index bf84acba0..484657713 100644 --- a/man/git-archive-file.1 +++ b/man/git-archive-file.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-ARCHIVE\-FILE" "1" "April 2015" "" "" +.TH "GIT\-ARCHIVE\-FILE" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-archive\-file\fR \- Export the current HEAD of the git repository to a archive diff --git a/man/git-archive-file.html b/man/git-archive-file.html index b55728b8a..bcd98a468 100644 --- a/man/git-archive-file.html +++ b/man/git-archive-file.html @@ -98,7 +98,7 @@

EXAMPLES

AUTHOR

-

Written by Philipp Klose <me@thehippo.de>

+

Written by Philipp Klose <me@thehippo.de>

REPORTING BUGS

@@ -111,7 +111,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. December 2015
  5. git-archive-file(1)
diff --git a/man/git-authors.1 b/man/git-authors.1 index 15f1d1e58..391b77218 100644 --- a/man/git-authors.1 +++ b/man/git-authors.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-AUTHORS" "1" "April 2015" "" "" +.TH "GIT\-AUTHORS" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-authors\fR \- Generate authors report @@ -35,8 +35,21 @@ Listing authors: .IP $ git authors \-\-list . -.IP -\fBTJ Holowaychuk Tj Holowaychuk hemanth\.hm Jonhnny Weslley nickl\- Leila Muhtasib \fR +.IP "" 4 +. +.nf + +TJ Holowaychuk +Tj Holowaychuk +hemanth\.hm +Jonhnny Weslley +nickl\- +Leila Muhtasib +. +.fi +. +.IP "" 0 + . .SH "AUTHOR" Written by Titus Wormer <\fItituswormer@gmail\.com\fR> diff --git a/man/git-authors.html b/man/git-authors.html index de18ecf44..d67bf7f4a 100644 --- a/man/git-authors.html +++ b/man/git-authors.html @@ -101,20 +101,19 @@

EXAMPLES

$ git authors --list

-

-TJ Holowaychuk <tj@vision-media.ca> +

TJ Holowaychuk <tj@vision-media.ca>
 Tj Holowaychuk <tj@vision-media.ca>
 hemanth.hm <hemanth.hm@gmail.com>
 Jonhnny Weslley <jw@jonhnnyweslley.net>
 nickl- <github@jigsoft.co.za>
 Leila Muhtasib <muhtasib@gmail.com>
-

+

AUTHOR

-

Written by Titus Wormer <tituswormer@gmail.com>

+

Written by Titus Wormer <tituswormer@gmail.com>

REPORTING BUGS

@@ -127,7 +126,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. December 2015
  5. git-authors(1)
diff --git a/man/git-back.1 b/man/git-back.1 index b06cc94ac..b88a83d30 100644 --- a/man/git-back.1 +++ b/man/git-back.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-BACK" "1" "April 2015" "" "" +.TH "GIT\-BACK" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-back\fR \- Undo and Stage latest commits diff --git a/man/git-back.html b/man/git-back.html index abe392c09..8ff46e64f 100644 --- a/man/git-back.html +++ b/man/git-back.html @@ -102,7 +102,7 @@

EXAMPLES

AUTHOR

-

Written by Kenneth Reitz <me@kennethreitz.com>

+

Written by Kenneth Reitz <me@kennethreitz.com>

REPORTING BUGS

@@ -115,7 +115,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. December 2015
  5. git-back(1)
diff --git a/man/git-bug.1 b/man/git-bug.1 index 51606f8bf..bf3670a4c 100644 --- a/man/git-bug.1 +++ b/man/git-bug.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-BUG" "1" "April 2015" "" "" +.TH "GIT\-BUG" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-bug\fR \- Create bug branch diff --git a/man/git-bug.html b/man/git-bug.html index 2c5fb6fb6..b7c091790 100644 --- a/man/git-bug.html +++ b/man/git-bug.html @@ -104,7 +104,7 @@

EXAMPLES

AUTHOR

-

Written by Jesús Espino <jespinog@gmail.com>

+

Written by Jesús Espino <jespinog@gmail.com>

REPORTING BUGS

@@ -117,7 +117,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. December 2015
  5. git-bug(1)
diff --git a/man/git-changelog.1 b/man/git-changelog.1 index 023ad322c..e14c53790 100644 --- a/man/git-changelog.1 +++ b/man/git-changelog.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-CHANGELOG" "1" "October 2015" "" "Git Extras" +.TH "GIT\-CHANGELOG" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-changelog\fR \- Generate a changelog report diff --git a/man/git-changelog.html b/man/git-changelog.html index ef6bc11e2..dca780d6a 100644 --- a/man/git-changelog.html +++ b/man/git-changelog.html @@ -65,7 +65,7 @@
  1. git-changelog(1)
  2. -
  3. Git Extras
  4. +
  5. git-changelog(1)
@@ -163,7 +163,7 @@

EXAMPLES

AUTHOR

-

Written by Mark Eissler <mark@mixtur.com>

+

Written by Mark Eissler <mark@mixtur.com>

REPORTING BUGS

@@ -176,7 +176,7 @@

SEE ALSO

  1. -
  2. October 2015
  3. +
  4. December 2015
  5. git-changelog(1)
diff --git a/man/git-chore.1 b/man/git-chore.1 index 783a78cc5..d557f465b 100644 --- a/man/git-chore.1 +++ b/man/git-chore.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-CHORE" "1" "April 2015" "" "" +.TH "GIT\-CHORE" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-chore\fR \- Create chore branch diff --git a/man/git-chore.html b/man/git-chore.html index bce74474f..cbe6b0777 100644 --- a/man/git-chore.html +++ b/man/git-chore.html @@ -104,7 +104,7 @@

EXAMPLES

AUTHOR

-

Written by Chris Hall <christopher.k.hall@gmail.com> from bug/feature/refactor comamnds originally written by Jesús Espino <jespinog@gmail.com>

+

Written by Chris Hall <christopher.k.hall@gmail.com> from bug/feature/refactor comamnds originally written by Jesús Espino <jespinog@gmail.com>

REPORTING BUGS

@@ -117,7 +117,7 @@

SEE ALSO

  1. -
  2. April 2015
  3. +
  4. December 2015
  5. git-chore(1)
diff --git a/man/git-clear.1 b/man/git-clear.1 index 44f961ace..15a5bb1c6 100644 --- a/man/git-clear.1 +++ b/man/git-clear.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-CLEAR" "1" "August 2015" "" "" +.TH "GIT\-CLEAR" "1" "December 2015" "" "" . .SH "NAME" \fBgit\-clear\fR \- Rigorously clean up a repository @@ -10,9 +10,7 @@ \fBgit\-clear\fR . .SH "DESCRIPTION" -Clears the repository to a state that it looks as if it was freshly cloned -with the current HEAD. Basically it is a git-reset --hard together with -deletion of all untracked files that reside inside the working directory. +Clears the repository to a state that it looks as if it was freshly cloned with the current HEAD\. Basically it is a git\-reset \-\-hard together with deletion of all untracked files that reside inside the working directory\. . .SH "EXAMPLES" Clears the repo\. @@ -21,27 +19,14 @@ Clears the repo\. . .nf -$ git clear -. -.fi -. -.IP "" 0 -. -.P -Remove the latest 3 commits: -. -.IP "" 4 -. -.nf - -$ git back 3 +$ git clear . .fi . .IP "" 0 . .SH "AUTHOR" -Written by Daniel Brendle <\fIgrindhold@gmx\.net\fR> +Written by Daniel \'grindhold\' Brendle <\fIgrindhold@gmx\.net\fR> . .SH "REPORTING BUGS" <\fIhttps://github\.com/tj/git\-extras/issues\fR> diff --git a/man/git-clear.html b/man/git-clear.html index fd7c6b831..4002b5492 100644 --- a/man/git-clear.html +++ b/man/git-clear.html @@ -3,7 +3,7 @@ - git-clear(1) - Undo and Stage latest commits + git-clear(1) - Rigorously clean up a repository - - - -
- - - -
    -
  1. git-feature(1)
  2. -
  3. -
  4. git-feature(1)
  5. -
- -

NAME

-

- git-feature - Create/Merge feature branch -

- -

SYNOPSIS

- -

git-feature [-a|--alias branch_prefix] [finish] <name>

- -

DESCRIPTION

- -

Create/Merge the given feature branch

- -

OPTIONS

- -

<-a|--alias branch_prefix>

- -

use branch_prefix instead of feature

- -

<finish>

- -

Merge and delete the feature branch.

- -

<name>

- -

The name of the feature branch.

- -

EXAMPLES

- -
$ git feature dependencies
-...
-$ (feature/dependencies) git commit -m "Some changes"
-...
-$ (feature/dependencies) git checkout master
-$ git feature finish dependencies
-
-$ git alias features "feature -a features"
-$ git features dependencies
-$ (features/dependencies) ...
-$ (features/dependencies) git checkout master
-$ git features finish dependencies
-
- -

AUTHOR

- -

Written by Jesús Espino <jespinog@gmail.com>

- -

REPORTING BUGS

- -

<https://github.com/tj/git-extras/issues>

- -

SEE ALSO

- -

<https://github.com/tj/git-extras>

- - -
    -
  1. -
  2. September 2015
  3. -
  4. git-feature(1)
  5. -
- -
- - diff --git a/man/git-feature.html b/man/git-feature.html index 58a748a9c..0374e9e6e 100644 --- a/man/git-feature.html +++ b/man/git-feature.html @@ -3,7 +3,7 @@ - git-feature(1) - Create feature branch + git-feature(1) - Create/Merge feature branch + + + +
+ + + +
    +
  1. git-sync(1)
  2. +
  3. +
  4. git-sync(1)
  5. +
+ +

NAME

+

+ git-sync - Sync local branch with remote branch +

+ +

SYNOPSIS

+ +

git sync <remote> <branch>

+ +

DESCRIPTION

+ +

Sync local branch with <branch> of <remote>. + All changes and untracked files and directories will be removed.

+ +

EXAMPLES

+ +

Sync local branch with origin/master

+ +
$ git sync origin master
+
+ +

AUTHOR

+ +

Written by Takuma Yamaguchi <kumon0587@gmail.com>

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. January 2016
  3. +
  4. git-sync(1)
  5. +
+ +
+ + diff --git a/man/git-sync.md b/man/git-sync.md new file mode 100644 index 000000000..885463498 --- /dev/null +++ b/man/git-sync.md @@ -0,0 +1,30 @@ +git-sync(1) -- Sync local branch with remote branch +================================================================= + +## SYNOPSIS + + `git sync` <remote> <branch> + +## DESCRIPTION + + Sync local branch with <branch> of <remote>. + All changes and untracked files and directories will be removed. + +## EXAMPLES + + Sync local branch with origin/master + + $ git sync origin master + +## AUTHOR + +Written by Takuma Yamaguchi <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> + From 3481ff245ecf99dd283b75d70b68e05684ceeee3 Mon Sep 17 00:00:00 2001 From: Takuma Yamaguchi Date: Sat, 16 Jan 2016 01:40:10 +0900 Subject: [PATCH 47/57] upstream is used by default --- bin/git-sync | 38 +++++++++++++++++++++++++------------- man/git-sync.1 | 23 +++++++++++++++++++++-- man/git-sync.html | 16 ++++++++++++---- man/git-sync.md | 12 +++++++++--- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/bin/git-sync b/bin/git-sync index 765f19a78..cbb684599 100755 --- a/bin/git-sync +++ b/bin/git-sync @@ -5,14 +5,19 @@ function _usage() local command="git sync" cat << EOS Usage: - ${command} - ${command} -h | --help | help | ? + ${command} [ ] + ${command} -h | --help -Sync local branch with of . +Sync local branch with /. +When and are not specified on the command line, upstream of local branch will be used by default. All changes and untracked files and directories will be removed. -Example: - ${command} origin master +Examples: + Sync with upstream of local branch: + ${command} + + Sync with origin/master: + ${command} origin master EOS } @@ -20,8 +25,9 @@ function main() { while [ "$1" != "" ]; do case $1 in - -h | --help | help | "?" ) + -h | --help) _usage + exit ;; * ) if [ "${remote}" = "" ]; then @@ -38,18 +44,24 @@ function main() shift done - if [ "${remote}" = "" -o "${branch}" = "" ]; then - echo -e "Error: too few arguments.\n" - _usage - exit 1 + if [ "${remote}" = "" ]; then + local remote_branch="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})" + branch="$(git rev-parse --abbrev-ref --symbolic-full-name @)" + remote="${remote_branch%%/${branch}}" + elif [ "${branch}" = "" ]; then + echo -e "Error: too few arguments.\n" + _usage + exit 1 + else + local remote_branch="${remote}/${branch}" fi - echo "Are you sure you want to clean all changes & sync with '${remote}/${branch}'? [y/N]" + echo "Are you sure you want to clean all changes & sync with '${remote_branch}'? [y/N]" local res read res - case ${res} in + case "${res}" in "Y" | "y" | "yes" | "Yes" | "YES" ) - git fetch '${remote}' && git reset --hard '${remote}'/'${branch}' && git clean -d -f -x + echo "git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}" && git clean -d -f -x" ;; * ) echo "Canceled." diff --git a/man/git-sync.1 b/man/git-sync.1 index 90a4954ee..498b2f217 100644 --- a/man/git-sync.1 +++ b/man/git-sync.1 @@ -7,12 +7,31 @@ \fBgit\-sync\fR \- Sync local branch with remote branch . .SH "SYNOPSIS" -\fBgit sync\fR +\fBgit sync\fR [ ] . .SH "DESCRIPTION" -Sync local branch with of \. All changes and untracked files and directories will be removed\. +Sync local branch with /\. +. +.P +When and are not specified on the command line, upstream of local branch will be used by default\. +. +.P +All changes and untracked files and directories will be removed\. . .SH "EXAMPLES" +Sync local branch with its upstream +. +.IP "" 4 +. +.nf + +$ git sync +. +.fi +. +.IP "" 0 +. +.P Sync local branch with origin/master . .IP "" 4 diff --git a/man/git-sync.html b/man/git-sync.html index 05a5c1f6f..234cdb0ac 100644 --- a/man/git-sync.html +++ b/man/git-sync.html @@ -75,15 +75,23 @@

NAME

SYNOPSIS

-

git sync <remote> <branch>

+

git sync [ <remote> <branch> ]

DESCRIPTION

-

Sync local branch with <branch> of <remote>. - All changes and untracked files and directories will be removed.

+

Sync local branch with <remote>/<branch>.

+ +

When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default.

+ +

All changes and untracked files and directories will be removed.

EXAMPLES

+

Sync local branch with its upstream

+ +
$ git sync
+
+

Sync local branch with origin/master

$ git sync origin master
@@ -91,7 +99,7 @@ 

EXAMPLES

AUTHOR

-

Written by Takuma Yamaguchi <kumon0587@gmail.com>

+

Written by Takuma Yamaguchi <kumon0587@gmail.com>

REPORTING BUGS

diff --git a/man/git-sync.md b/man/git-sync.md index 885463498..f2f6e431e 100644 --- a/man/git-sync.md +++ b/man/git-sync.md @@ -3,15 +3,22 @@ git-sync(1) -- Sync local branch with remote branch ## SYNOPSIS - `git sync` <remote> <branch> + `git sync` [ <remote> <branch> ] ## DESCRIPTION - Sync local branch with <branch> of <remote>. + Sync local branch with <remote>/<branch>. + + When <remote> and <branch> are not specified on the command line, upstream of local branch will be used by default. + All changes and untracked files and directories will be removed. ## EXAMPLES + Sync local branch with its upstream + + $ git sync + Sync local branch with origin/master $ git sync origin master @@ -27,4 +34,3 @@ Written by Takuma Yamaguchi <> ## SEE ALSO <> - From 19ece6192e21612642e7fbdbf6c4c7beb946bd0a Mon Sep 17 00:00:00 2001 From: Takuma Yamaguchi Date: Sat, 16 Jan 2016 01:47:30 +0900 Subject: [PATCH 48/57] add example of git-sync --- Commands.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Commands.md b/Commands.md index ab899f0d0..6fd1cbc5d 100644 --- a/Commands.md +++ b/Commands.md @@ -991,7 +991,13 @@ The above rebase `feature` branch on top of `master` branch ## git sync -Sync local branch with remote branch +Sync local branch with its remote branch + +```bash +$ git sync +``` + +Sync local branch with origin/master ```bash $ git sync origin master From f0ecd8212922b83975aff78e61bf0f21273061c1 Mon Sep 17 00:00:00 2001 From: Takuma Yamaguchi Date: Sun, 17 Jan 2016 00:56:45 +0900 Subject: [PATCH 49/57] add upstream check & bugfix --- bin/git-sync | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/git-sync b/bin/git-sync index cbb684599..8de036aec 100755 --- a/bin/git-sync +++ b/bin/git-sync @@ -44,16 +44,20 @@ function main() shift done + local remote_branch if [ "${remote}" = "" ]; then - local remote_branch="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})" - branch="$(git rev-parse --abbrev-ref --symbolic-full-name @)" - remote="${remote_branch%%/${branch}}" + if ! remote_branch="$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)"; then + echo "There is no upstream information of local branch." + exit 1 + fi + local branch="$(git rev-parse --abbrev-ref --symbolic-full-name @)" + local remote=$(git config "branch.${branch}.remote") elif [ "${branch}" = "" ]; then echo -e "Error: too few arguments.\n" _usage exit 1 else - local remote_branch="${remote}/${branch}" + remote_branch="${remote}/${branch}" fi echo "Are you sure you want to clean all changes & sync with '${remote_branch}'? [y/N]" @@ -61,7 +65,7 @@ function main() read res case "${res}" in "Y" | "y" | "yes" | "Yes" | "YES" ) - echo "git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}" && git clean -d -f -x" + git fetch "${remote}" "${branch}" && git reset --hard "${remote_branch}" && git clean -d -f -x ;; * ) echo "Canceled." From afce25cd650dfccdf70057691e2db6378242102b Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 20 Jan 2016 11:39:25 +0800 Subject: [PATCH 50/57] use ps -f and awk to emulate pgrep There is no pgrep in git for windows --- bin/git-changelog | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/git-changelog b/bin/git-changelog index dc27a8b1d..bb01b7a9d 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -317,7 +317,20 @@ _exit() { stty sane; echo; echo "caught signal, shutting down" IFS=$'\n' - pid_list=( $(pgrep -P $$) ) + # The format of `ps` is different between Windows and other platforms, + # so we need to calculate the total column number(COL_NUM) of header first. + # Why don't we just use the last column? + # Because the body of CMD column may contain space and be treated as multiple fileds. + pid_list=( $(ps -f | + awk -v ppid=$$ 'NR == 1 { + COL_NUM = NF + } + $3 == ppid { + # filter out temp processes created in this subshell + if ($COL_NUM != "ps" && $COL_NUM != "awk" && $COL_NUM !~ "bash$") + print $2 + }') + ) IFS="$defaultIFS" local _pid From a192fe688ac65450602cba72850050889236476d Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 20 Jan 2016 11:39:39 +0800 Subject: [PATCH 51/57] handle GIT_EDITOR which contains space --- bin/git-changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/git-changelog b/bin/git-changelog index bb01b7a9d..80cecf96b 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -478,7 +478,10 @@ main() { rm -f "$tmpfile" else cp -f "$tmpfile" "$changelog" - [[ -n "$GIT_EDITOR" ]] && $GIT_EDITOR "$changelog" + # Use `eval` to handle GIT_EDITOR which contains space and options, + # like ""C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst ". + # Thanks @JanSchulz to inspire me this solution + [[ -n "$GIT_EDITOR" ]] && eval $GIT_EDITOR "$changelog" if [[ $? -ne 0 ]]; then _exit fi From 0fde295f5ee1c8edb709e504da47dc8b329c5a08 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 22 Jan 2016 18:01:28 +0800 Subject: [PATCH 52/57] Update git PR manual to mention URLs --- man/git-pr.1 | 30 +++++++++- man/git-pr.html | 143 ------------------------------------------------ man/git-pr.md | 19 ++++++- 3 files changed, 44 insertions(+), 148 deletions(-) diff --git a/man/git-pr.1 b/man/git-pr.1 index 0c62df08b..a7df50972 100644 --- a/man/git-pr.1 +++ b/man/git-pr.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-PR" "1" "December 2015" "" "" +.TH "GIT\-PR" "1" "January 2016" "" "Git Extras" . .SH "NAME" \fBgit\-pr\fR \- Checks out a pull request locally @@ -10,10 +10,13 @@ \fBgit\-pr\fR [] . .br +\fBgit\-pr\fR +. +.br \fBgit\-pr clean\fR . .SH "DESCRIPTION" -Creates a local branch based on a GitHub pull request number, and switch to that branch afterwards\. +Creates a local branch based on a GitHub pull request number or URL, and switch to that branch afterwards\. . .SH "OPTIONS" @@ -21,6 +24,12 @@ Creates a local branch based on a GitHub pull request number, and switch to that .P The name of the remote to fetch from\. Defaults to \fBorigin\fR\. . +.P + +. +.P +GitHub pull request URL in the format \fBhttps://github\.com/tj/git\-extras/pull/453\fR\. +. .SH "EXAMPLES" This checks out the pull request \fB226\fR from \fBorigin\fR: . @@ -57,6 +66,23 @@ $ git pr 226 upstream .IP "" 0 . .P +You can also checkout a pull request based on a GitHub URL: +. +.IP "" 4 +. +.nf + +$ git pr https://github\.com/tj/git\-extras/pull/453 + +From https://github\.com/tj/git\-extras + * [new ref] refs/pull/453/head \-> pr/453 +Switched to branch \'pr/453\' +. +.fi +. +.IP "" 0 +. +.P To clean up old branches: . .IP "" 4 diff --git a/man/git-pr.html b/man/git-pr.html index 40406135c..e69de29bb 100644 --- a/man/git-pr.html +++ b/man/git-pr.html @@ -1,143 +0,0 @@ - - - - - - git-pr(1) - Checks out a pull request locally - - - - -
- - - -
    -
  1. git-pr(1)
  2. -
  3. -
  4. git-pr(1)
  5. -
- -

NAME

-

- git-pr - Checks out a pull request locally -

- -

SYNOPSIS

- -

git-pr <number> [<remote>]
-git-pr clean

- -

DESCRIPTION

- -

Creates a local branch based on a GitHub pull request number, and switch to - that branch afterwards.

- -

OPTIONS

- -

<remote>

- -

The name of the remote to fetch from. Defaults to origin.

- -

EXAMPLES

- -

This checks out the pull request 226 from origin:

- -
$ git pr 226
-
-remote: Counting objects: 12, done.
-remote: Compressing objects: 100% (9/9), done.
-remote: Total 12 (delta 3), reused 9 (delta 3)
-Unpacking objects: 100% (12/12), done.
-From https://github.com/tj/git-extras
- * [new ref]         refs/pull/226/head -> pr/226
-
-Switched to branch 'pr/226'
-
- -

This pulls from a different remote:

- -
$ git pr 226 upstream
-
- -

To clean up old branches:

- -
$ git pr clean
-
-Deleted branch pr/226 (was b96a8c2).
-Deleted branch pr/220 (was d34dc0f).
-
- -

AUTHOR

- -

Originally from https://gist.github.com/gnarf/5406589

- -

REPORTING BUGS

- -

<https://github.com/tj/git-extras/issues>

- -

SEE ALSO

- -

<https://github.com/tj/git-extras>

- - -
    -
  1. -
  2. December 2015
  3. -
  4. git-pr(1)
  5. -
- -
- - diff --git a/man/git-pr.md b/man/git-pr.md index 9d774eea6..93c6fd0c9 100644 --- a/man/git-pr.md +++ b/man/git-pr.md @@ -4,19 +4,24 @@ git-pr(1) -- Checks out a pull request locally ## SYNOPSIS `git-pr` <number> [<remote>]
+`git-pr` <url>
`git-pr clean` ## DESCRIPTION - Creates a local branch based on a GitHub pull request number, and switch to - that branch afterwards. + Creates a local branch based on a GitHub pull request number or URL, and + switch to that branch afterwards. ## OPTIONS - + <remote> The name of the remote to fetch from. Defaults to `origin`. + <url> + + GitHub pull request URL in the format `https://github.com/tj/git-extras/pull/453`. + ## EXAMPLES This checks out the pull request `226` from `origin`: @@ -36,6 +41,14 @@ This pulls from a different remote: $ git pr 226 upstream +You can also checkout a pull request based on a GitHub URL: + + $ git pr https://github.com/tj/git-extras/pull/453 + + From https://github.com/tj/git-extras + * [new ref] refs/pull/453/head -> pr/453 + Switched to branch 'pr/453' + To clean up old branches: $ git pr clean From 9d2df44d18d6b8989fb3feb5d4de02716d40c56d Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 22 Jan 2016 20:51:36 +0800 Subject: [PATCH 53/57] Regerenate git-pr.html --- man/git-pr.html | 157 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/man/git-pr.html b/man/git-pr.html index e69de29bb..a6a436542 100644 --- a/man/git-pr.html +++ b/man/git-pr.html @@ -0,0 +1,157 @@ + + + + + + git-pr(1) - Checks out a pull request locally + + + + +
+ + + +
    +
  1. git-pr(1)
  2. +
  3. Git Extras
  4. +
  5. git-pr(1)
  6. +
+ +

NAME

+

+ git-pr - Checks out a pull request locally +

+ +

SYNOPSIS

+ +

git-pr <number> [<remote>]
+git-pr <url>
+git-pr clean

+ +

DESCRIPTION

+ +

Creates a local branch based on a GitHub pull request number or URL, and + switch to that branch afterwards.

+ +

OPTIONS

+ +

<remote>

+ +

The name of the remote to fetch from. Defaults to origin.

+ +

<url>

+ +

GitHub pull request URL in the format https://github.com/tj/git-extras/pull/453.

+ +

EXAMPLES

+ +

This checks out the pull request 226 from origin:

+ +
$ git pr 226
+
+remote: Counting objects: 12, done.
+remote: Compressing objects: 100% (9/9), done.
+remote: Total 12 (delta 3), reused 9 (delta 3)
+Unpacking objects: 100% (12/12), done.
+From https://github.com/tj/git-extras
+ * [new ref]         refs/pull/226/head -> pr/226
+
+Switched to branch 'pr/226'
+
+ +

This pulls from a different remote:

+ +
$ git pr 226 upstream
+
+ +

You can also checkout a pull request based on a GitHub URL:

+ +
$ git pr https://github.com/tj/git-extras/pull/453
+
+From https://github.com/tj/git-extras
+ * [new ref]         refs/pull/453/head -> pr/453
+Switched to branch 'pr/453'
+
+ +

To clean up old branches:

+ +
$ git pr clean
+
+Deleted branch pr/226 (was b96a8c2).
+Deleted branch pr/220 (was d34dc0f).
+
+ +

AUTHOR

+ +

Originally from https://gist.github.com/gnarf/5406589

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. January 2016
  3. +
  4. git-pr(1)
  5. +
+ +
+ + From 0ca4c6f2215ea021c7508dd67bf5c2cb45b77e10 Mon Sep 17 00:00:00 2001 From: Nimit Kalra Date: Sun, 24 Jan 2016 15:03:50 -0600 Subject: [PATCH 54/57] Version 4.1.0 --- AUTHORS | 138 ++++++++++++++++++++++++------------------------- History.md | 30 +++++++++++ bin/git-extras | 2 +- 3 files changed, 100 insertions(+), 70 deletions(-) diff --git a/AUTHORS b/AUTHORS index e261b6078..e11ca6505 100644 --- a/AUTHORS +++ b/AUTHORS @@ -22,127 +22,127 @@ Patches and Suggestions - Mark Eissler - Leila Muhtasib - Jesús Espino -- Kenneth Reitz +- Jan Schulz - David Baumgold -- Sasha Khamkov - Andrew Janke -- Chris Hall +- Kenneth Reitz +- Sasha Khamkov +- Damian Krzeminski +- Aggelos Orfanakos - grindhold - Camille Reynders -- Damian Krzeminski - NANRI -- Aggelos Orfanakos +- Chris Hall - Phally - Rémy HUBSCHER +- Rico Sta. Cruz - Alexander Krasnukhin +- Takuma Yamaguchi - gisphm -- Jan Schulz -- Jonathan "Duke" Leto - wooorm -- Brian J Brennan -- Ivan Malopinsky -- Nimit Kalra - Philipp Klose +- Jonathan "Duke" Leto - Nils Winkler +- Ivan Malopinsky - Julio Napurí - Hogan Long -- Domenico Rotiroti -- Alexis GRIMALDI -- Andre Cerqueira -- Curtis McEnroe -- Devin Withers -- Evan Grim -- Florian H +- Brian J Brennan - Gert Van Gool -- Guillaume Seren -- Jean Jordaan -- Justin Guenther -- Kylie McClain -- Marc Harter +- Curtis McEnroe - Nate Jones - Newell Zhu - Patryk Małek - Paul Schreiber +- Andre Cerqueira - Richard Littauer -- Rico Sta. Cruz +- Jean Jordaan +- Alexis GRIMALDI +- David Rogers +- Devin Withers - Tom Vincent +- Domenico Rotiroti - Wil Moore III +- Justin Guenther - go2null <1t1is2@gmail.com> +- Evan Grim +- Kylie McClain - luozexuan +- Florian H +- Guillaume Seren - phigoro - soffolk -- Joshua Appelman +- Marc Harter +- Xiaopei Li +- creynders +- dead-horse +- eszabpt - jykntr +- meza +- neydroid +- nulltask +- zeroDivisible - Adam Parkin +- ☃ pitr +- Akim Demaille +- Alex McHale +- Allan Odgaard +- Amir Tocker +- Andrei Petcu +- Andrew Starr-Bochicchio +- Andy +- Antoine Beaupré +- Aurélien Scoubeau +- Balazs Nadasdi +- Ben Parnell +- Brandon Zylstra +- Bruno Sutic +- Carl Casbolt +- Ciro Nunes +- Craig MacGregor +- Dan Jackson +- Daniel Schildt +- Dave James Miller +- David Hartmann +- Dung Quang +- Emil Kjelsrud +- Greg Allen +- Guillermo Rauch +- Gunnlaugur Thor Briem +- James Manning +- Jan Krueger +- Jarod Stewart +- Jason Young +- Jens K. Mueller +- Jesse Sipprell +- Jianjin Fan +- Johannes Ewald +- John Hoffmann +- Jon Ander Peñalba +- Joshua Appelman - Kevin Woo - Konstantin Schukraft -- Akim Demaille - Leandro López -- David Hartmann -- Dave James Miller - Maarten Winter -- meza -- Daniel Schildt - Mathieu D. (MatToufoutu) - Matt Colyer - Matthew Avant - Michael Komitee - Michael Matuzak - Moritz Grauel -- Dan Jackson -- neydroid - Nathan Rajlich -- Amir Tocker - Nick Campbell - Nick Payne -- Craig MacGregor - Niklas Fiekas -- Ciro Nunes -- Carl Casbolt -- nulltask -- Bruno Sutic -- Brandon Zylstra - Raphael Fleischlin - Rasmus Wriedt Larsen - Riceball LEE -- zeroDivisible -- ☃ pitr - Rob Kennedy - Ryan Bohn -- Ben Parnell - Sam Thursfield -- Balazs Nadasdi - Stephen Mathieson - Steve Mao -- Aurélien Scoubeau -- Antoine Beaupré - Todd Wolfson - Tony - TweeKane - Valérian Galliat -- Allan Odgaard -- Xiaopei Li -- creynders -- dead-horse -- eszabpt -- Andy -- Alex McHale -- Andrew Starr-Bochicchio -- Jan Krueger -- James Manning -- Jarod Stewart -- Jason Young -- Andrei Petcu -- Jens K. Mueller -- Jesse Sipprell -- Gunnlaugur Thor Briem -- Jianjin Fan -- Johannes Ewald -- John Hoffmann -- Jon Ander Peñalba -- Guillermo Rauch -- Greg Allen -- Emil Kjelsrud -- Dung Quang -- David Rogers - Duane Johnson diff --git a/History.md b/History.md index f8fc90b84..2beae7b85 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,34 @@ +4.1.0 / 2016-01-25 +================== + + * Merge pull request #503 from spacewander/fix_502 + * Merge pull request #507 from rstacruz/git-pr-manual + * Regerenate git-pr.html + * Merge pull request #506 from rstacruz/git-pr-manual + * Update git PR manual to mention URLs + * handle GIT_EDITOR which contains space + * use ps -f and awk to emulate pgrep + * Merge pull request #500 from kumon/master + * add upstream check & bugfix + * add example of git-sync + * upstream is used by default + * Merge pull request #497 from JanSchulz/win_inst2 + * add git-sync + * Merge pull request #499 from tj/add-bsd-installation + * Add BSD installation instructions. + * installation.md: Update information about column.exe + * install.cmd: add a check for write rights to the install folder + * install.cmd: properly escape the ! in the shebang line + * Merge pull request #496 from JanSchulz/win_inst + * Make the win installer more robust + * Merge pull request #494 from apjanke/fix-git-repo-inclusion + * Merge pull request #495 from JanSchulz/patch-1 + * Update Installation.md + * Makefile: fix inverted list of commands that use is_git_repo + * Add Gitter badge. + * Bump version to 4.1.0-dev. + 4.0.0 / 2015-12-28 ================== diff --git a/bin/git-extras b/bin/git-extras index be1c25ede..45103dfcc 100755 --- a/bin/git-extras +++ b/bin/git-extras @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="4.1.0-dev" +VERSION="4.1.0" INSTALL_SCRIPT="https://raw.githubusercontent.com/tj/git-extras/master/install.sh" update() { From 8a8a483f41133165e0afe8f4f79ad9fbdadf10f2 Mon Sep 17 00:00:00 2001 From: Nimit Kalra Date: Sun, 24 Jan 2016 15:07:09 -0600 Subject: [PATCH 55/57] Bump version to 4.2.0-dev. --- bin/git-extras | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-extras b/bin/git-extras index 45103dfcc..c2b44a5cb 100755 --- a/bin/git-extras +++ b/bin/git-extras @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="4.1.0" +VERSION="4.2.0-dev" INSTALL_SCRIPT="https://raw.githubusercontent.com/tj/git-extras/master/install.sh" update() { From 511c135e2f8c37a3c2f5ad24445b472f0cef8765 Mon Sep 17 00:00:00 2001 From: George Crabtree Date: Thu, 28 Jan 2016 22:17:36 +1100 Subject: [PATCH 56/57] Fix typo in git-clear documentation --- Commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands.md b/Commands.md index 6fd1cbc5d..f7c0071ad 100644 --- a/Commands.md +++ b/Commands.md @@ -946,7 +946,7 @@ Makefile README.md ``` -## git-clear +## git clear Does a hard reset and deletes all untracked files from the working directory From d286839da1054c04675e2a3dc90baf8caf253b63 Mon Sep 17 00:00:00 2001 From: Prayag Verma Date: Sat, 30 Jan 2016 17:30:04 +0530 Subject: [PATCH 57/57] Mention initial copyright year and add contributors to copyright I am not a lawyer but according to http://www.copyright.gov/circs/circ01.pdf (See screenshot of relevant section below), mentioning the first year of publication in the copyright is a good thing ![selection_008](https://cloud.githubusercontent.com/assets/829526/12409934/7021c3a6-be95-11e5-8d1a-18f6948571e0.png) Mentioning 2010 as the first release happened at that time - https://github.com/tj/git-extras/releases/tag/0.0.1 Also adding `Contributors` to copyright because TJ Holowaychuk is not the only person owning copyright for the whole project. The copyright is collectively owned by all contributors, or more precisely: every contributor owns a copyright on the code he or she has contributed. The only way to retain full copyright over code is to ask for signing contributor's agreement before merging in changes. This is, in fact, what some companies who license commercially their free software do. --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index f1c86e1a6..86c4a2974 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ (The MIT License) -Copyright (c) 2015 TJ Holowaychuk +Copyright (c) 2010 TJ Holowaychuk and Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the