Merge remote-tracking branch 'ni/master'
This commit is contained in:
commit
d380d6060e
|
@ -1,15 +1,16 @@
|
||||||
{ coreutils, git, stdenv, writeDashBin }:
|
{ coreutils, git, writeDashBin }:
|
||||||
|
|
||||||
writeDashBin "git-preview" ''
|
writeDashBin "git-preview" ''
|
||||||
PATH=${stdenv.lib.makeBinPath [
|
set -efu
|
||||||
coreutils
|
head_commit=$(${git}/bin/git log -1 --format=%H)
|
||||||
git
|
merge_commit=$1; shift
|
||||||
]}''${PATH+:$PATH}
|
merge_message='Merge for git-preview'
|
||||||
hashes=$(git log --format=%h "..$1")
|
preview_dir=$(${coreutils}/bin/mktemp --tmpdir -d git-preview.XXXXXXXX)
|
||||||
end=$(echo "$hashes" | head -1)
|
preview_name=$(${coreutils}/bin/basename "$preview_dir")
|
||||||
start=$(echo "$hashes" | tail -1)
|
${git}/bin/git worktree add --detach -f "$preview_dir" 2>/dev/null
|
||||||
# exit if no diff was found
|
${git}/bin/git -C "$preview_dir" checkout -q "$head_commit"
|
||||||
test -z "$start" && exit 0
|
${git}/bin/git -C "$preview_dir" merge -qm "$merge_message" "$merge_commit"
|
||||||
shift
|
${git}/bin/git -C "$preview_dir" diff "$head_commit.." "$@"
|
||||||
git diff "$start^..$end" "$@"
|
${coreutils}/bin/rm -fR "$preview_dir"
|
||||||
|
${coreutils}/bin/rm -R .git/worktrees/"$preview_name"
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in a new issue