Guest User

Untitled

a guest
Jun 19th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #!/bin/sh
  2. # git-fetch-log: Ultimate git fetch-log
  3. #
  4. # It shows the diferences of `local...remote` if both side exists and there
  5. # are differences. Useful to find out what you have to do: `merge`, `rebase`,
  6. # `push`, etc. The arguments passed to log.
  7. #
  8. # Place it somewhere on Your `$PATH` and execute by the `git fetch-log`
  9. # command.
  10. #
  11. # EXAMPLE OUTPUT
  12. # ============================================================================
  13. #
  14. # ==== branch [behind 1]
  15. #
  16. # > commit 652b883 (origin/branch)
  17. # | Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  18. # | Date: 2016-03-10 09:11:11 +0100
  19. # |
  20. # | Commit on remote
  21. # |
  22. # o commit 2304667 (branch)
  23. # Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  24. # Date: 2015-08-28 13:21:13 +0200
  25. #
  26. # Commit on local
  27. #
  28. # ==== master [ahead 1]
  29. #
  30. # < commit 280ccf8 (master)
  31. # | Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  32. # | Date: 2016-03-25 21:42:55 +0100
  33. # |
  34. # | Commit on local
  35. # |
  36. # o commit 2369465 (origin/master, origin/HEAD)
  37. # Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  38. # Date: 2016-03-10 09:02:52 +0100
  39. #
  40. # Commit on remote
  41. #
  42. # ==== test [ahead 1, behind 1]
  43. #
  44. # < commit 83a3161 (test)
  45. # | Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  46. # | Date: 2016-03-25 22:50:00 +0100
  47. # |
  48. # | Diverged from remote
  49. # |
  50. # | > commit 4aafec7 (origin/test)
  51. # |/ Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  52. # | Date: 2016-03-14 10:34:28 +0100
  53. # |
  54. # | Pushed remote
  55. # |
  56. # o commit 0fccef3
  57. # Author: BimbaLaszlo <bimbalaszlo@gmail.com>
  58. # Date: 2015-09-03 10:33:39 +0200
  59. #
  60. # Last common commit
  61. #
  62. # ==================== BimbaLaszlo (.github.io|gmail.com) ====================
  63.  
  64. fmt='ref=%(refname:short); up=%(upstream:short); t=%(upstream:track); ts=%(upstream:trackshort);'
  65. git for-each-ref --shell --format="$fmt" refs/heads |
  66. while read entry; do
  67. eval "$entry"
  68. if test "z$ts" != 'z' && test "z$ts" != 'z='; then
  69. echo -e "n==== $ref $tn"
  70. git --no-pager log --graph --left-right --decorate --abbrev-commit --date-order --boundary $@ $ref...$up
  71. fi
  72. done
Add Comment
Please, Sign In to add comment