From b481bb162ff1e0ffed71e4e8f8b20f2912a3a812 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 26 Dec 2014 20:05:20 -0500 Subject: git-checkout-history: Print output from `git-checkout` When `git-checkout` is run internally as part of `git-checkout-history`, print its output to the screen. This allows us to see the "Switched to branch 'example'" text when using `git-checkout-history` so we know for sure which branch we're actually on without having to `git status`. --- git-checkout-history/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git-checkout-history/main.go b/git-checkout-history/main.go index 3b74e9e..cced21e 100644 --- a/git-checkout-history/main.go +++ b/git-checkout-history/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "fmt" "github.com/teddywing/git-checkout-history/utils" "os" @@ -17,10 +18,13 @@ func main() { branchIndex, _ := strconv.Atoi(args[0]) cmd := exec.Command("git", "checkout", branches[branchIndex]) + var out bytes.Buffer + cmd.Stderr = &out err := cmd.Run() if err != nil { fmt.Fprintf(os.Stderr, err.Error()) } + fmt.Print(out.String()) utils.Store(branches[branchIndex]) } else { -- cgit v1.2.3