Updating from SVN
[jeenu-rep.git] / work / home / .mygitutils
blob8878c6b55112013de7816b6d521f5ee5a626fa7d
1 #!/bin/bash
3 # To list all git modified items in the given directory
4 function gitmodified()
6 git rev-parse || return 1
7 git diff --diff-filter=M --name-only "$@"
10 # Recursively show diffs for all the modified files
11 function gitshowdiffs()
14 git_patch_file="$HOME/tmp/gitpatchfile"
15 wd_now="$PWD"
17 git_dir="$(git rev-parse --git-dir)" || return 1
18 cd "$git_dir/.."
19 for i in $(gitmodified "$@"); do
20 # prompt for continue
21 if ! confirm "$i: continue" 1; then
22 if [ "$CONFIRMED" = "no" ]; then
23 echo
24 continue
25 elif [ "$CONFIRMED" = "quit" ]; then
26 echo
27 return
31 # With control character to clear the entire line
32 echo -e "\r\e[2Kgetting diff..."
33 git diff --no-prefix --no-ext-diff "$i" > "$git_patch_file" || return
35 if [ "$(stat -c %s "$git_patch_file")" -eq 0 ]; then
36 echo "gitshowdiffs: $i: no diff found"
37 continue
38 else
39 DISPLAY= vi -n '+set patchexpr=MyPatch()' \
40 "+leftabove vertical diffpatch $git_patch_file |cmap q qa|nmap <F7> ]c|nmap <F6> [c|windo set fdm=diff nolist|normal gg" \
41 "$i"
43 done