-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit
More file actions
33 lines (29 loc) · 1.01 KB
/
git
File metadata and controls
33 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode/
# A wrapper that injects the -w -M options into git blame commands.
# https://github.com/chrisdanford/BetterXcodeGitBlame/
# Xcode will pass arguments to git that look like:
# ls-remote --heads
# or
# -c color.ui=false -c core.pager= -c core.quotepath=false --no-pager blame --no-color --line-porcelain -- SomeFile.m
#
# We want to inject out extra flags into any `blame` command.
# We'll process each arg, inject our flags when we find the one `blame` (if any)
# and not inject once we see the `--` separator because everything after
# the separator are file names (and there could be legitimate files with
# the name `blame`).
ARGS=()
found_separator=0
for var in "$@"; do
ARGS+=("$var")
if [[ "$found_separator" -eq 1 ]]; then
:
elif [[ "$var" == "--" ]]; then
found_separator=1
elif [[ "$var" == "blame" ]]; then
ARGS+=("-w")
ARGS+=("-M")
fi
done
DIR=$(dirname $0)
"$DIR"/xcode-git "${ARGS[@]}"