Guest User

Untitled

a guest
Aug 29th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # NAME
  4. # git-catchup - Rebase onto a "mainline" branch.
  5. #
  6. # SYNOPSIS
  7. # git catchup [<repository> <refspec>]
  8. # git catchup <refspec>
  9. #
  10. # DESCRIPTION
  11. # Incorporate upstream mainline changes into the current branch by
  12. # performing a git-pull(1) --rebase --autostash with the rebase in
  13. # interactive mode configured to output to STDOUT rather than open a
  14. # terminal. Logs changes from the merge-base of <respository>/<refspec>
  15. # and HEAD before and after catching up.
  16. #
  17. # <repository> should be the name of a remote repository as passed to git-
  18. # fetch(1). <refspec> can name an arbitrary remote ref (for example, the
  19. # name of a tag), but usually it is the name of a branch in the remote
  20. # repository.
  21. #
  22. # Default value for <repository> is read from the "remote" configuration
  23. # for the current branch as set by git-branch(1) --track. Default value
  24. # for <refspec> is "master".
  25.  
  26. set -e
  27.  
  28. remote="$1"
  29. parent="$2"
  30.  
  31. if [ -z "$parent" ]; then
  32. parent=${remote:="master"}
  33. remote=$(git config branch.$parent.remote)
  34. remote=${remote:="origin"}
  35. fi
  36.  
  37. previous_head_sha=$(git rev-parse HEAD)
  38.  
  39. __git_update_prettyprint_log () {
  40. format=$(
  41. git config --get pretty.update ||
  42. echo "%C(yellow)%h%Cblue%d%Creset %s - %C(white)%an %Cgreen(%cr)%Creset")
  43.  
  44. merge_base_sha=$(git merge-base "$previous_head_sha" "$remote/$parent")
  45. # Use the last commit on a merged branch if merge-base is a merge
  46. if git rev-parse $merge_base_sha^2 > /dev/null 2>&1; then
  47. merge_base_sha=$(git rev-parse $merge_base_sha^2)
  48. fi
  49. git log --format="$format" --graph "$merge_base_sha".."$remote_sha" "$merge_base_sha".."$previous_head_sha"
  50. }
  51.  
  52. git -c core.editor="grep --invert-match '^#'" pull --rebase=interactive --autostash $remote $parent
  53.  
  54. remote_sha=$(git rev-parse HEAD)
  55. __git_update_prettyprint_log
Add Comment
Please, Sign In to add comment