diff --git a/git_map.py b/git_map.py index f93e6b896..700132516 100755 --- a/git_map.py +++ b/git_map.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + """ Provides an augmented `git log --graph` view. In particular, it also annotates commits with branches + tags that point to them. Items are colorized as follows: diff --git a/git_map_branches.py b/git_map_branches.py index 5fde84b28..fc6c8cec4 100755 --- a/git_map_branches.py +++ b/git_map_branches.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + """ Provides a short mapping of all the branches in your local repo, organized by their upstream ('tracking branch') layout. Example: @@ -45,7 +49,14 @@ def print_branch(cur, cur_hash, branch, branch_hashes, par_map, branch_map, else: color += Style.NORMAL - print color + " "*depth + branch + (" *" if branch == cur else "") + suffix = '' + if cur == 'HEAD': + if branch_hash == cur_hash: + suffix = ' *' + elif branch == cur: + suffix = ' *' + + print color + " "*depth + branch + suffix for child in par_map.pop(branch, ()): print_branch(cur, cur_hash, child, branch_hashes, par_map, branch_map, depth=depth+1) diff --git a/git_nav_downstream.py b/git_nav_downstream.py index 9c2a53780..e394343ba 100755 --- a/git_nav_downstream.py +++ b/git_nav_downstream.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + """ Checks out a downstream branch from the currently checked out branch. If there is more than one downstream branch, then this script will prompt you to select @@ -14,7 +18,11 @@ def main(argv): upfn = upstream cur = current_branch() if cur == 'HEAD': - upfn = lambda b: hash_one(upstream(b)) + def _upfn(b): + parent = upstream(b) + if parent: + return hash_one(parent) + upfn = _upfn cur = hash_one(cur) downstreams = [b for b in branches() if upfn(b) == cur] if not downstreams: