|
6 | 6 | # While looking at the git log you can press CTRL+o to open it in a browser. |
7 | 7 | # |
8 | 8 | # Examples: |
9 | | -# gl |
10 | | -# gl --side |
| 9 | +# gl # Search commit messages and use -S for searching code |
| 10 | +# gl -G # Use -G instead of -S for searching code |
| 11 | +# gl --side # Show diffs side by side |
11 | 12 | # gl [any flag that git log supports] |
12 | 13 |
|
13 | 14 | set -o errexit |
@@ -53,11 +54,17 @@ export -f open_commit_url |
53 | 54 |
|
54 | 55 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
55 | 56 | GIT_ARGS=("--color=always" "--date=short") |
| 57 | + GIT_LOG_SEARCH_MODE="-S" |
56 | 58 |
|
57 | | - # Handle displaying side by side on demand. |
58 | 59 | for arg in "${@}"; do |
59 | 60 | if [ "${arg}" = "--side" ]; then |
| 61 | + # Handle displaying side by side. |
60 | 62 | export DELTA_FEATURES="${DELTA_FEATURES} side-by-side" |
| 63 | + elif [ "${arg}" = "-G" ]; then |
| 64 | + # Handle the search mode, -G is much slower on large repos but supports |
| 65 | + # regular expression searches and will return more results, but as a |
| 66 | + # default -S tends to produce less noise and more relevant results. |
| 67 | + GIT_LOG_SEARCH_MODE="-G" |
61 | 68 | else |
62 | 69 | GIT_ARGS+=("${arg}") |
63 | 70 | fi |
@@ -108,7 +115,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
108 | 115 | ${GIT_LOG_DEFAULT} |
109 | 116 | else |
110 | 117 | [[ \"\${query}\" =~ [A-Z] ]] && case= || case=\"--regexp-ignore-case\" |
111 | | - (git log \${case} --pretty='${FORMAT_CODE}' ${GIT_ARGS_STR:-} -G \"\${query}\" |
| 118 | + (git log \${case} --pretty='${FORMAT_CODE}' ${GIT_ARGS_STR:-} ${GIT_LOG_SEARCH_MODE} \"\${query}\" |
112 | 119 | git log \${case} --pretty='${FORMAT_MESSAGE}' ${GIT_ARGS_STR:-} --grep \"\${query}\") | |
113 | 120 | sort --numeric-sort --reverse --unique --key 1,1 | |
114 | 121 | ${STRIP_TIMESTAMP} |
|
0 commit comments