Advertisement
Guest User

git log question

a guest
Apr 10th, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. commit() {
  2.   sleep 1
  3.   git commit -m "$1" >/dev/null
  4.   git log -n 1 --pretty="Committed: %H ($(git branch --show-current)) %s"
  5. }
  6.  
  7. modify() {
  8.   mv $1 $1.copy
  9.   cat $1.copy | sed -e "$2s/.*/$3/" > $1
  10.   rm $1.copy
  11.   git add .
  12.   commit "Modified line $2 of $1."
  13. }
  14.  
  15. dummy_commits() {
  16.   touch dummy.txt
  17.   git add .
  18.   commit "Added dummy.txt"
  19.   git rm dummy.txt >/dev/null
  20.   commit "Removed dummy.txt"
  21. }
  22.  
  23. repo="$(mktemp -d)"
  24. echo "Created git repository at $repo"
  25. cd "$repo"
  26. git init &>/dev/null
  27. cat >foo.txt <<HERE
  28. This is line 1
  29. This is line 2
  30. This is line 3
  31. This is line 4
  32. This is line 5
  33. This is line 6
  34. This is line 7
  35. This is line 8
  36. This is line 9
  37. This is line 10
  38. HERE
  39. git add .
  40. commit "Initial commit"
  41. git checkout -b workbench 2>/dev/null
  42. mv foo.txt bar.txt
  43. git add .
  44. commit "Renamed foo.txt to bar.txt"
  45. modify bar.txt 3 "Modified bar"
  46. dummy_commits
  47. git checkout master 2>/dev/null
  48. mv foo.txt baz.txt
  49. git add .
  50. commit "Renamed foo.txt to baz.txt"
  51. modify baz.txt 8 "Modified baz"
  52. dummy_commits
  53. git merge workbench -m "Merging workbench (conflicts)" >/dev/null
  54. rm baz.txt
  55. mv bar.txt foo-merged.txt
  56. git add .
  57. commit "Merged bar.txt and baz.txt as foo-merged.txt"
  58.  
  59. # ----- Output Stats ------ #
  60. echo "----------------------------------------"
  61. git log --raw --follow -m --pretty=format:%H%n%P%n%aL%n%cs%n%s -- foo-merged.txt
  62. echo "----------------------------------------"
  63. git blame -elfwM --root --date=short foo-merged.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement