diff options
Diffstat (limited to 'pkgs/simple/git-preview/default.nix')
| -rw-r--r-- | pkgs/simple/git-preview/default.nix | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkgs/simple/git-preview/default.nix b/pkgs/simple/git-preview/default.nix new file mode 100644 index 00000000..f0ed4dfd --- /dev/null +++ b/pkgs/simple/git-preview/default.nix @@ -0,0 +1,16 @@ +{ coreutils, git, writeDashBin }: + +writeDashBin "git-preview" '' + set -efu + # Checked here: merge-tree fails with exit status 1 for a name it can't + # resolve, too, which would pass for a conflict below. + merge_commit=$(${git}/bin/git rev-parse --verify "$1^{commit}"); shift + # Merges in the object store, without a worktree: exit status 1 means + # conflicts, which the tree then holds as conflict markers. + output=$(${git}/bin/git merge-tree --write-tree HEAD "$merge_commit") || { + status=$? + test "$status" = 1 || exit "$status" + } + tree=$(printf '%s\n' "$output" | ${coreutils}/bin/head -n 1) + ${git}/bin/git diff HEAD "$tree" "$@" +'' |
