vim, gitconfig, update.sh
[dotfiles_afify.git] / .scripts / create_diff_git.sh
blob778719950357bd3b4c96e951a025e56b260a109d
1 #!/bin/sh
3 # Description : create diff file from 2 commits
5 # git_dir=$()
6 # --git-dir $git_dir/.git
7 # patch -p1 < path/to/patch.diff
9 # diff -u old new > patch.diff
10 # patch OriginalFile < PatchFile
11 # diff -r -x *.o -x *.so -x *.git dir1 dir2
14 old_commit=$(git log --all --pretty=format:'%h %s %d' |\
15 dmenu -p 'old commmit' -l 10 | awk '{print $1}')
17 if [ "$old_commit" ]; then
18 new_commit=$(git log --all --pretty=format:'%h %s' |\
19 dmenu -p 'new commmit' -l 10 | awk '{print $1}')
20 if [ "$new_commit" ]; then
21 # TODO
22 file_name=$(ls -p | grep -v /| dmenu -p 'select file' -l 10)
23 if [ "$file_name" ]; then
24 output_file="$old_commit"_"$new_commit"_"$file_name".diff
25 git diff "$old_commit" "$new_commit" -- "$file_name" > "$output_file" && echo "create diff for $file_name."
26 else
27 output_file="$old_commit"_"$new_commit".diff
28 git diff "$old_commit" "$new_commit" > "$output_file" && echo "create diff all dir."