mirror of
https://github.com/Fakerr/git-recall.git
synced 2026-09-10 07:26:42 -04:00
Merge pull request #37 from Seanmcn/master
Allow limiting history to path/s or file/s
This commit is contained in:
commit
d18d910300
|
|
@ -17,6 +17,7 @@ check what you or other contributors in your team did. It doesn't aim to be a re
|
|||
$ git recall [-a <author name>]
|
||||
[-d <days-ago>]
|
||||
[-b <branch name>]
|
||||
[-p <paths>]
|
||||
[-f]
|
||||
[-h]
|
||||
[-v]
|
||||
|
|
@ -27,6 +28,7 @@ $ git recall [-a <author name>]
|
|||
- `-a` - Restrict search for a specific user (use -a "all" for all users)
|
||||
- `-d` - Display commits for the last n days
|
||||
- `-b` - Specify branch to display commits from
|
||||
- `-p` - Specify path/s or file/s to display commits from
|
||||
- `-f` - Fetch the latest changes
|
||||
- `-h` - Show help screen
|
||||
- `-v` - Show version
|
||||
|
|
|
|||
10
git-recall
10
git-recall
|
|
@ -9,6 +9,7 @@ usage() {
|
|||
-d, --date Show logs for last n days.
|
||||
-a, --author Author name.
|
||||
-b, --branch Specify branch to display commits from.
|
||||
-p --path Specify path or filename to display commits from.
|
||||
-f, --fetch fetch commits.
|
||||
-h, --help This message.
|
||||
-v, --version Show version.
|
||||
|
|
@ -29,6 +30,7 @@ SED_CMD="" # Sed command to use according OS.
|
|||
LESSKEY=false
|
||||
VERSION="1.2.3"
|
||||
BRANCH=""
|
||||
SEARCH_PATH=""
|
||||
|
||||
# Set key bindings.
|
||||
au="`echo -e '\e[A'`" # arrow up
|
||||
|
|
@ -93,6 +95,10 @@ while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
|
|||
BRANCH="$2"
|
||||
shift
|
||||
;;
|
||||
-p | --path )
|
||||
SEARCH_PATH="$2"
|
||||
shift
|
||||
;;
|
||||
* )
|
||||
echo "abort: unknown argument" 1>&2
|
||||
exit 1
|
||||
|
|
@ -134,7 +140,7 @@ GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%a
|
|||
# Log command.
|
||||
GIT_LOG="git log --pretty=format:'${GIT_FORMAT}'
|
||||
--author \"$AUTHOR\"
|
||||
--since \"$SINCE\" --abbrev-commit --no-merges $BRANCH"
|
||||
--since \"$SINCE\" --abbrev-commit --no-merges $BRANCH $SEARCH_PATH"
|
||||
|
||||
# Change temporary the IFS to store GIT_LOG's output into an array.
|
||||
IFS=$'\n'
|
||||
|
|
@ -191,7 +197,7 @@ fi
|
|||
function get_diff() {
|
||||
ELT="$(echo "${COMMITS_UNCOL[$CP-1]}")"
|
||||
DIFF_TIP=${ELT:0:7}
|
||||
DIFF_CMD="git show $DIFF_TIP --color=always"
|
||||
DIFF_CMD="git show $DIFF_TIP --color=always $SEARCH_PATH"
|
||||
DIFF=$(eval ${DIFF_CMD} 2>/dev/null)
|
||||
tmp_diff="$(echo "$DIFF" | $SED_CMD)"
|
||||
off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") # Number of lines in the diff that are longer than terminal width.
|
||||
|
|
|
|||
Loading…
Reference in a new issue