mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
* feat: Add pathspec support in git-missing Allow to specify a path to limit the commit difference list. This improvement allows users to focus on changes in specific directories or files when comparing branches for missing commits. * refactor: Improve pathspec handling in git-missing - Change pathspec from string to array to support multiple pathspecs - Remove unnecessary 'shift' command in argument processing loop - Simplify git log command execution by using a single codepath * chore: Update git-missing docs * chore: Fix a typo in git-missing docs
53 lines
993 B
Bash
Executable file
53 lines
993 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
usage() {
|
|
echo 1>&2 "usage: git missing [<first branch>] <second branch> [<git log options>] [[--] <path>...]"
|
|
}
|
|
|
|
if [ "${#}" -lt 1 ]
|
|
then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
declare -a git_log_args=()
|
|
declare -a branches=()
|
|
declare -a pathspec=()
|
|
declare parse_path=false
|
|
|
|
for arg in "$@" ; do
|
|
|
|
if [[ $parse_path == true ]]; then
|
|
pathspec+=("$@")
|
|
break
|
|
fi
|
|
|
|
case "$arg" in
|
|
--)
|
|
parse_path=true
|
|
;;
|
|
--*)
|
|
git_log_args+=( "$arg" )
|
|
;;
|
|
*)
|
|
branches+=( "$arg" )
|
|
;;
|
|
esac
|
|
done
|
|
|
|
firstbranch=
|
|
secondbranch=
|
|
if [ ${#branches[@]} -eq 2 ]
|
|
then
|
|
firstbranch="${branches[0]}"
|
|
secondbranch="${branches[1]}"
|
|
elif [ ${#branches[@]} -eq 1 ]
|
|
then
|
|
secondbranch="${branches[0]}"
|
|
else
|
|
echo >&2 "error: at least one branch required"
|
|
exit 1
|
|
fi
|
|
|
|
git log "${git_log_args[@]}" "$firstbranch"..."$secondbranch" --format="%m %h %s" --left-right -- "${pathspec[@]}"
|