Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,14 +1296,20 @@ Creates a zip archive of the current git repository. The name of the archive wil

## git missing

Print out which commits are on one branch or the other but not both.
Print out which commits are on one branch or the other but not both. Optionally, you can specify a path to limit the comparison to a specific directory or file.

```bash
$ git missing master
< d14b8f0 only on current checked out branch
> 97ef387 only on master
```

```bash
$ git missing master -- src/
< ed52989 only on current branch, in src/ directory
> 7988c4b only on master, in src/ directory
```

## git lock

Lock a local file `filename`:
Expand Down
20 changes: 18 additions & 2 deletions bin/git-missing
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

usage() {
echo 1>&2 "usage: git missing [<first branch>] <second branch> [<git log options>]"
echo 1>&2 "usage: git missing [<first branch>] <second branch> [<git log options>] [[--] <path>...]"
}

if [ "${#}" -lt 1 ]
Expand All @@ -12,16 +12,28 @@ fi

declare -a git_log_args=()
declare -a branches=()
declare 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
shift
done

firstbranch=
Expand All @@ -38,4 +50,8 @@ else
exit 1
fi

git log "${git_log_args[@]}" "$firstbranch"..."$secondbranch" --format="%m %h %s" --left-right
if [[ -n "$pathspec" ]]; then
git log "${git_log_args[@]}" "$firstbranch"..."$secondbranch" --format="%m %h %s" --left-right -- "$pathspec"
else
git log "${git_log_args[@]}" "$firstbranch"..."$secondbranch" --format="%m %h %s" --left-right
fi