From 63d707c33caf788eca2a363a7155d8b55fcb7d5b Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Sat, 31 Dec 2011 13:05:43 -0800 Subject: [PATCH 1/2] adding git-missing command --- Readme.md | 11 ++++ bin/git-missing | 13 +++++ man/git-missing.1 | 64 +++++++++++++++++++++ man/git-missing.html | 133 +++++++++++++++++++++++++++++++++++++++++++ man/git-missing.md | 47 +++++++++++++++ 5 files changed, 268 insertions(+) create mode 100755 bin/git-missing create mode 100644 man/git-missing.1 create mode 100644 man/git-missing.html create mode 100644 man/git-missing.md diff --git a/Readme.md b/Readme.md index a82e584..1023fd6 100644 --- a/Readme.md +++ b/Readme.md @@ -66,6 +66,7 @@ $ brew install git-extras - `git promote` - `git local-commits` - `git archive-file` + - `git missing` ## git-extras @@ -529,3 +530,13 @@ List all commits on the local branch that have not yet been sent to origin. Any ## git-archive-file Creates an zip archive of the current git repository. The name of the archive will depend on the current HEAD of your git respository. + +## git-missing [branch1] branch2 + +Print out which commits are on one branch or the other but not both. + +```bash +$ git missing master +< d14b8f0 only on current checked out branch +> 97ef387 only on master +``` diff --git a/bin/git-missing b/bin/git-missing new file mode 100755 index 0000000..d9cc283 --- /dev/null +++ b/bin/git-missing @@ -0,0 +1,13 @@ +#!/bin/sh + +firstbranch=$1 +secondbranch=$2 + +test -z "$firstbranch" && echo "at least one branch required" && exit 1 + +if test -z "$secondbranch"; then + secondbranch=$firstbranch + firstbranch= +fi + +git log $firstbranch...$secondbranch --format="%m %h %s" --left-right diff --git a/man/git-missing.1 b/man/git-missing.1 new file mode 100644 index 0000000..4393f33 --- /dev/null +++ b/man/git-missing.1 @@ -0,0 +1,64 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-MISSING" "1" "December 2011" "" "Git Extras" +. +.SH "NAME" +\fBgit\-missing\fR \- Show commits missing from another branch +. +.SH "SYNOPSIS" +\fBgit\-missing\fR [] +. +.SH "DESCRIPTION" +Shows commits that are in either of two branches but not both\. Useful for seeing what would come across in a merge or push\. +. +.SH "OPTIONS" +[] +. +.P +First branch to compare\. If not specified, defaults to currently checked out branch\. +. +.P + +. +.P +Second branch to compare\. +. +.SH "EXAMPLES" +Show commits on either my current branch or master but not both: +. +.IP "" 4 +. +.nf + +$ git missing master +< d14b8f0 only on current checked out branch +> 97ef387 only on master +. +.fi +. +.IP "" 0 +. +.P +Show commits on either branch foo or branch bar but not both: +. +.IP "" 4 +. +.nf + +$ git missing foo bar +< b8f0d14 only on foo +> f38797e only on bar +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Written by Nate Jones <\fInate@endot\.org\fR> +. +.SH "REPORTING BUGS" +<\fIhttp://github\.com/visionmedia/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttp://github\.com/visionmedia/git\-extras\fR> diff --git a/man/git-missing.html b/man/git-missing.html new file mode 100644 index 0000000..14e97ca --- /dev/null +++ b/man/git-missing.html @@ -0,0 +1,133 @@ + + + + + + git-missing(1) - Show commits missing from another branch + + + + +
+ + + +
    +
  1. git-missing(1)
  2. +
  3. Git Extras
  4. +
  5. git-missing(1)
  6. +
+ +

NAME

+

+ git-missing - Show commits missing from another branch +

+ +

SYNOPSIS

+ +

git-missing [<first branch>] <second branch>

+ +

DESCRIPTION

+ +

Shows commits that are in either of two branches but not both. Useful for + seeing what would come across in a merge or push.

+ +

OPTIONS

+ +

[<first branch>]

+ +

First branch to compare. If not specified, defaults to currently checked out branch.

+ +

<second branch>

+ +

Second branch to compare.

+ +

EXAMPLES

+ +

Show commits on either my current branch or master but not both:

+ +
$ git missing master
+< d14b8f0 only on current checked out branch
+> 97ef387 only on master
+
+ +

Show commits on either branch foo or branch bar but not both:

+ +
$ git missing foo bar
+< b8f0d14 only on foo
+> f38797e only on bar
+
+ +

AUTHOR

+ +

Written by Nate Jones <nate@endot.org>

+ +

REPORTING BUGS

+ +

<http://github.com/visionmedia/git-extras/issues>

+ +

SEE ALSO

+ +

<http://github.com/visionmedia/git-extras>

+ + +
    +
  1. +
  2. December 2011
  3. +
  4. git-missing(1)
  5. +
+ +
+ + diff --git a/man/git-missing.md b/man/git-missing.md new file mode 100644 index 0000000..4128dab --- /dev/null +++ b/man/git-missing.md @@ -0,0 +1,47 @@ +git-missing(1) -- Show commits missing from another branch +========================================================= + +## SYNOPSIS + +`git-missing` [<first branch>] <second branch> + +## DESCRIPTION + + Shows commits that are in either of two branches but not both. Useful for + seeing what would come across in a merge or push. + +## OPTIONS + + [<first branch>] + + First branch to compare. If not specified, defaults to currently checked out branch. + + <second branch> + + Second branch to compare. + +## EXAMPLES + + Show commits on either my current branch or master but not both: + + $ git missing master + < d14b8f0 only on current checked out branch + > 97ef387 only on master + + Show commits on either branch foo or branch bar but not both: + + $ git missing foo bar + < b8f0d14 only on foo + > f38797e only on bar + +## AUTHOR + +Written by Nate Jones <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> From e5c8d79e66c5aebcc342d1cdf8f4a9ac61aa51fd Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Wed, 7 Mar 2012 09:25:37 -0800 Subject: [PATCH 2/2] allow options to be passed through to git log --- bin/git-missing | 14 +++++++++++--- man/git-missing.1 | 10 ++++++++-- man/git-missing.html | 10 +++++++--- man/git-missing.md | 6 +++++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/bin/git-missing b/bin/git-missing index d9cc283..7a7c8b5 100755 --- a/bin/git-missing +++ b/bin/git-missing @@ -1,7 +1,15 @@ #!/bin/sh -firstbranch=$1 -secondbranch=$2 +# grab first two non-option arguments +for arg in $*; do + if [[ $arg != -* ]]; then + test -z "$firstbranch" && firstbranch=$arg && continue + test -z "$secondbranch" && secondbranch=$arg && continue + else + # add anything else to a passthrough + passthrough="$passthrough $arg" + fi +done test -z "$firstbranch" && echo "at least one branch required" && exit 1 @@ -10,4 +18,4 @@ if test -z "$secondbranch"; then firstbranch= fi -git log $firstbranch...$secondbranch --format="%m %h %s" --left-right +git log $passthrough $firstbranch...$secondbranch --format="%m %h %s" --left-right diff --git a/man/git-missing.1 b/man/git-missing.1 index 4393f33..0deada4 100644 --- a/man/git-missing.1 +++ b/man/git-missing.1 @@ -1,13 +1,13 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-MISSING" "1" "December 2011" "" "Git Extras" +.TH "GIT\-MISSING" "1" "March 2012" "" "Git Extras" . .SH "NAME" \fBgit\-missing\fR \- Show commits missing from another branch . .SH "SYNOPSIS" -\fBgit\-missing\fR [] +\fBgit\-missing\fR [] [] . .SH "DESCRIPTION" Shows commits that are in either of two branches but not both\. Useful for seeing what would come across in a merge or push\. @@ -24,6 +24,12 @@ First branch to compare\. If not specified, defaults to currently checked out br .P Second branch to compare\. . +.P +[] +. +.P +Any flags that should be passed to \'git log\', such as \-\-no\-merges\. +. .SH "EXAMPLES" Show commits on either my current branch or master but not both: . diff --git a/man/git-missing.html b/man/git-missing.html index 14e97ca..bc0d2c5 100644 --- a/man/git-missing.html +++ b/man/git-missing.html @@ -76,7 +76,7 @@

SYNOPSIS

-

git-missing [<first branch>] <second branch>

+

git-missing [<first branch>] <second branch> [<git log options>]

DESCRIPTION

@@ -93,6 +93,10 @@

Second branch to compare.

+

[<git log options>]

+ +

Any flags that should be passed to 'git log', such as --no-merges.

+

EXAMPLES

Show commits on either my current branch or master but not both:

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

AUTHOR

-

Written by Nate Jones <nate@endot.org>

+

Written by Nate Jones <nate@endot.org>

REPORTING BUGS

@@ -124,7 +128,7 @@
  1. -
  2. December 2011
  3. +
  4. March 2012
  5. git-missing(1)
diff --git a/man/git-missing.md b/man/git-missing.md index 4128dab..befa030 100644 --- a/man/git-missing.md +++ b/man/git-missing.md @@ -3,7 +3,7 @@ git-missing(1) -- Show commits missing from another branch ## SYNOPSIS -`git-missing` [<first branch>] <second branch> +`git-missing` [<first branch>] <second branch> [<git log options>] ## DESCRIPTION @@ -20,6 +20,10 @@ git-missing(1) -- Show commits missing from another branch Second branch to compare. + [<git log options>] + + Any flags that should be passed to 'git log', such as --no-merges. + ## EXAMPLES Show commits on either my current branch or master but not both: