diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-08-05 16:34:22 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-08-05 16:37:09 -0400 |
commit | cfd6ed0e077f3667b036902516a0348b1c596441 (patch) | |
tree | 678a5bf6ad901fc269a4315dfb7267c8339489a6 /etc | |
parent | 2da099e53d5c0a7597757bca5b53bbef5d449e8b (diff) |
Reorganize
Diffstat (limited to 'etc')
36 files changed, 69133 insertions, 0 deletions
diff --git a/etc/assets/syntaxes.bin b/etc/assets/syntaxes.bin Binary files differnew file mode 100644 index 00000000..2b12fad9 --- /dev/null +++ b/etc/assets/syntaxes.bin diff --git a/etc/assets/themes.bin b/etc/assets/themes.bin Binary files differnew file mode 100644 index 00000000..9de98391 --- /dev/null +++ b/etc/assets/themes.bin diff --git a/etc/ci/.gitattributes b/etc/ci/.gitattributes new file mode 100644 index 00000000..36eaad9f --- /dev/null +++ b/etc/ci/.gitattributes @@ -0,0 +1 @@ +* linguist-vendored diff --git a/etc/ci/before_deploy.sh b/etc/ci/before_deploy.sh new file mode 100755 index 00000000..c79b8c69 --- /dev/null +++ b/etc/ci/before_deploy.sh @@ -0,0 +1,166 @@ +#!/usr/bin/env bash +# Building and packaging for release + +set -ex + +build() { + cargo build --target "$TARGET" --release --verbose +} + +pack() { + local tempdir + local out_dir + local package_name + local gcc_prefix + + tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) + out_dir=$(pwd) + package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET" + + if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then + gcc_prefix="arm-linux-gnueabihf-" + elif [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then + gcc_prefix="aarch64-linux-gnu-" + else + gcc_prefix="" + fi + + # create a "staging" directory + mkdir "$tempdir/$package_name" + + # copying the main binary + cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/" + if [ "$TRAVIS_OS_NAME" != windows ]; then + "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME" + fi + + # manpage, readme and license + cp README.md "$tempdir/$package_name" + cp LICENSE "$tempdir/$package_name" + + # archiving + pushd "$tempdir" + if [ "$TRAVIS_OS_NAME" = windows ]; then + 7z a "$out_dir/$package_name.zip" "$package_name"/* + else + tar czf "$out_dir/$package_name.tar.gz" "$package_name"/* + fi + popd + rm -r "$tempdir" +} + +make_deb() { + local tempdir + local architecture + local version + local dpkgname + local conflictname + local gcc_prefix + local homepage + local maintainer + + homepage="https://github.com/dandavison/delta" + maintainer="Dan Davison <dandavison7@gmail.com>" + + case $TARGET in + x86_64*) + architecture=amd64 + gcc_prefix="" + ;; + i686*) + architecture=i386 + gcc_prefix="" + ;; + aarch64*) + architecture=arm64 + gcc_prefix="aarch64-linux-gnu-" + ;; + arm*hf) + architecture=armhf + gcc_prefix="arm-linux-gnueabihf-" + ;; + *) + echo "make_deb: skipping target '${TARGET}'" >&2 + return 0 + ;; + esac + version=${TRAVIS_TAG#v} + if [[ $TARGET = *musl* ]]; then + dpkgname=$PACKAGE_NAME-musl + conflictname=$PROJECT_NAME + else + dpkgname=$PACKAGE_NAME + conflictname=$PROJECT_NAME-musl + fi + + tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) + + # copy the main binary + install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME" + "${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME" + + # readme and license + install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md" + install -Dm644 LICENSE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE" + cat > "$tempdir/usr/share/doc/$PROJECT_NAME/copyright" <<EOF +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: $PROJECT_NAME +Source: $homepage + +Files: * +Copyright: $maintainer +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any + person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the + Software without restriction, including without + limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software + is furnished to do so, subject to the following + conditions: + . + The above copyright notice and this permission notice + shall be included in all copies or substantial portions + of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +EOF + + # Control file + mkdir "$tempdir/DEBIAN" + cat > "$tempdir/DEBIAN/control" <<EOF +Package: $dpkgname +Version: $version +Section: utils +Priority: optional +Maintainer: Dan Davison <dandavison7@gmail.com> +Architecture: $architecture +Provides: $PROJECT_NAME +Conflicts: $conflictname +Description: A syntax highlighter for git. +EOF + + fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb" +} + + +main() { + build + pack + if [[ $TARGET = *linux* ]]; then + make_deb + fi +} + +main diff --git a/etc/ci/before_install.sh b/etc/ci/before_install.sh new file mode 100755 index 00000000..9acf6025 --- /dev/null +++ b/etc/ci/before_install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -ex + +if [ "$TRAVIS_OS_NAME" != linux ]; then + exit 0 +fi + +sudo apt-get update + +# needed for musl targets +sudo apt-get install -y musl-tools + +# needed to build deb packages +sudo apt-get install -y fakeroot + +# needed for i686 linux gnu target +if [[ $TARGET == i686-unknown-linux-gnu ]]; then + sudo apt-get install -y gcc-multilib +fi + +# needed for cross-compiling for arm +if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then + sudo apt-get install -y \ + gcc-4.8-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + libc6-armhf-cross \ + libc6-dev-armhf-cross +fi + +# needed for cross-compiling for arm64 +if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then + sudo apt-get install -y \ + gcc-4.8-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu +fi diff --git a/etc/ci/script.sh b/etc/ci/script.sh new file mode 100755 index 00000000..e6e505ad --- /dev/null +++ b/etc/ci/script.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -ex + +# Incorporate TARGET env var to the build and test process +cargo build --target "$TARGET" --verbose + +# We cannot run arm executables on linux +if [[ $TARGET != arm-unknown-linux-gnueabihf ]] && [[ $TARGET != aarch64-unknown-linux-gnu ]]; then + cargo test --target "$TARGET" --verbose + cargo build --release + ./tests/test_raw_output_matches_git_on_full_repo_history + ./tests/test_deprecated_options > /dev/null + + cargo run --target "$TARGET" -- < /dev/null +fi diff --git a/etc/completion/completion.bash b/etc/completion/completion.bash new file mode 100644 index 00000000..9bb27207 --- /dev/null +++ b/etc/completion/completion.bash @@ -0,0 +1,69 @@ +#!/bin/bash + +__delta_previous_extglob_setting=$(shopt -p extglob) +shopt -s extglob + +__delta_complete_commands() { + COMPREPLY=( $(compgen -W "${commands[*]}" -- "$cur") ) +} + +_delta_delta() { + __delta_complete_commands +} + +_delta() { + local previous_extglob_setting=$(shopt -p extglob) + shopt -s extglob + + local commands=( + --raw + --commit-style + --dark + --file-style + --help + --highlight-removed + --hunk-style + --light + --list-languages + --list-themes + --list-theme-names + --minus-color + --minus-emph-color + --plus-color + --plus-emph-color + --keep-plus-minus-markers + --show-background-colors + --theme + --version + --width + ) + + COMPREPLY=() + local cur prev words cword + _get_comp_words_by_ref -n : cur prev words cword + + local command='delta' command_pos=0 + local counter=1 + while [ $counter -lt $cword ]; do + case "${words[$counter]}" in + *) + command="${words[$counter]}" + command_pos=$counter + break + ;; + esac + (( counter++ )) + done + + local completions_func=_delta_${command} + + declare -F $completions_func >/dev/null && $completions_func + + eval "$previous_extglob_setting" + return 0 +} + +eval "$__delta_previous_extglob_setting" +unset __delta_previous_extglob_setting + +complete -F _delta delta diff --git a/etc/completion/completion.zsh b/etc/completion/completion.zsh new file mode 100644 index 00000000..0ff59208 --- /dev/null +++ b/etc/completion/completion.zsh @@ -0,0 +1 @@ +compdef _gnu_generic delta diff --git a/etc/diagnostics b/etc/diagnostics new file mode 100755 index 00000000..82a2f2b0 --- /dev/null +++ b/etc/diagnostics @@ -0,0 +1,18 @@ +#!/bin/bash + +commands=( + "delta --version" + "less --version | head -n1" + "env | grep -E '(less|pager|bat)'" + "printf '\e[34m\e[43mtext\e[m\n'" + "printf '\e[38;5;19m\e[48;5;226mtext\e[m\n'" + "printf '\e[38;2;0;0;255m\e[48;2;255;255;0mtext\e[m\n'" + "delta <(echo a) <(echo b) | cat -A" + "delta <(echo a) <(echo b)" +) + +for cmd in "${commands[@]}"; do + echo "> $cmd" + eval "$cmd" + echo +done diff --git a/etc/examples/119-within-line-edits b/etc/examples/119-within-line-edits new file mode 100755 index 00000000..1bea9c0b --- /dev/null +++ b/etc/examples/119-within-line-edits @@ -0,0 +1,38 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +git init +git commit --allow-empty -m "Initial commit" + +cat > file1.js <<EOF +{ + if(g_themeController == nullptr) + { +EOF + +cat > file2.js <<EOF +myColor = color === control.palette.window ? themeController.themePalette.buttonColor + : themeController.themePalette.windowColor +EOF + +git add file1.js file2.js +git commit -m "Base commit" + +cat > file1.js <<EOF +{ + if(g_themeViewModel == nullptr) + { +EOF + +cat > file2.js <<EOF +myColor = color === control.palette.window ? themeViewModel.themePalette.basicBase + : themeViewModel.themePalette.windowColor +EOF + +git add file1.js file2.js +git commit -m "Changes" + +git log --patch diff --git a/etc/examples/121-unrecognized-content-before-diff-1 b/etc/examples/121-unrecognized-content-before-diff-1 new file mode 100755 index 00000000..c02c361e --- /dev/null +++ b/etc/examples/121-unrecognized-content-before-diff-1 @@ -0,0 +1,2 @@ +#!/bin/bash +git show -p --cc --format= --numstat --stat diff --git a/etc/examples/121-unrecognized-content-before-diff-2 b/etc/examples/121-unrecognized-content-before-diff-2 new file mode 100755 index 00000000..2d09108d --- /dev/null +++ b/etc/examples/121-unrecognized-content-before-diff-2 @@ -0,0 +1,2 @@ +#!/bin/bash +git stash show --stat --patch diff --git a/etc/examples/125-merge-conflict-1.diff b/etc/examples/125-merge-conflict-1.diff new file mode 100644 index 00000000..a13b761b --- /dev/null +++ b/etc/examples/125-merge-conflict-1.diff @@ -0,0 +1,48 @@ +diff --cc src/config.rs +index e35d2e4,fad673e..0000000 +--- a/src/config.rs ++++ b/src/config.rs +@@@ -1,4 -1,5 +1,10 @@@ +++<<<<<<< Updated upstream + +use std::process; +++||||||| constructed merge base +++======= ++ use std::process; ++ +++>>>>>>> Stashed changes + use std::str::FromStr; + + use syntect::highlighting::{Color, Style, StyleModifier, Theme, ThemeSet}; +@@@ -78,7 -40,9 +84,15 @@@ pub fn get_config<'a> + theme_set, + ); + +++<<<<<<< Updated upstream + + let theme = if style::is_no_syntax_highlighting_theme_name(&theme_name) { +++||||||| constructed merge base +++ let theme = if is_no_syntax_highlighting_theme_name(&theme_name) { +++======= ++ println!("theme_name: {}", theme_name); ++ ++ let theme = if is_no_syntax_highlighting_theme_name(&theme_name) { +++>>>>>>> Stashed changes + None + } else { + Some(&theme_set.themes[&theme_name]) +@@@ -190,10 -128,14 +204,14 @@@ fn get_is_light_mode_and_theme_name + ) -> (bool, String) { + let theme_arg = valid_theme_name_or_none(theme_arg, theme_set); + let bat_theme_env_var = valid_theme_name_or_none(bat_theme_env_var, theme_set); ++ ++ println!("theme_arg: {:?}", theme_arg); ++ println!("bat_theme_env_var: {:?}", bat_theme_env_var); ++ + match (theme_arg, bat_theme_env_var, light_mode_arg) { + (None, None, false) => (false, style::DEFAULT_DARK_THEME.to_string()), + - (Some(theme_name), _, false) => (is_light_theme(&theme_name), theme_name), + - (None, Some(theme_name), false) => (is_light_theme(&theme_name), theme_name), + + (Some(theme_name), _, false) => (style::is_light_theme(&theme_name), theme_name), + + (None, Some(theme_name), false) => (style::is_light_theme(&theme_name), theme_name), + (None, None, true) => (true, style::DEFAULT_LIGHT_THEME.to_string()), + (Some(theme_name), _, is_light_mode) => (is_light_mode, theme_name), + (None, Some(theme_name), is_light_mode) => (is_light_mode, theme_name), diff --git a/etc/examples/125-merge-conflict-2.diff b/etc/examples/125-merge-conflict-2.diff new file mode 100644 index 00000000..3fd66fac --- /dev/null +++ b/etc/examples/125-merge-conflict-2.diff @@ -0,0 +1,42 @@ +diff --cc Makefile +index 759070d,3daf9eb..0000000 +--- a/Makefile ++++ b/Makefile +@@@ -4,13 -4,16 +4,37 @@@ build + lint: + cargo clippy + +++<<<<<<< Updated upstream + +test: unit-test end-to-end-test + + + +unit-test: + + cargo test + + + +end-to-end-test: build + + bash -c "diff -u <(git log -p) <(git log -p | target/release/delta --color-only | perl -pe 's/\e\[[0-9;]*m//g')" +++||||||| constructed merge base +++test: +++ cargo test +++ bash -c "diff -u <(git log -p) \ +++ <(git log -p | delta --width variable \ +++ --tabs 0 \ +++ --retain-plus-minus-markers \ +++ --commit-style plain \ +++ --file-style plain \ +++ --hunk-style plain \ +++ | ansifilter)" +++======= ++ test: ++ cargo test --release ++ bash -c "diff -u <(git log -p) \ ++ <(git log -p | target/release/delta --width variable \ ++ --tabs 0 \ ++ --retain-plus-minus-markers \ ++ --commit-style plain \ ++ --file-style plain \ ++ --hunk-style plain \ ++ | ansifilter)" > /dev/null +++>>>>>>> Stashed changes + + release: + @make -f release.Makefile release diff --git a/etc/examples/127-paths-with-spaces--added b/etc/examples/127-paths-with-spaces--added new file mode 100755 index 00000000..3a5096c2 --- /dev/null +++ b/etc/examples/127-paths-with-spaces--added @@ -0,0 +1,18 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +mkdir "with space" +echo "file1 contents" > "with space/file1" + +mkdir "nospace" +echo "file2 contents" > "nospace/file2" + +git init +git commit --allow-empty -m "Initial commit" +git add . +git commit -m "Initial commit" + +git show diff --git a/etc/examples/127-paths-with-spaces--renamed b/etc/examples/127-paths-with-spaces--renamed new file mode 100755 index 00000000..740ce6e0 --- /dev/null +++ b/etc/examples/127-paths-with-spaces--renamed @@ -0,0 +1,22 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +mkdir "with space" +echo "file1 contents" > "with space/file1" + +mkdir "nospace" +echo "file2 contents" > "nospace/file2" + +git init +git commit --allow-empty -m "Initial commit" +git add . +git commit -m "Initial commit" + +git mv "with space/file1" "with space/file1-renamed" +git mv "nospace/file2" "nospace/file2-renamed" +git commit -m "Rename" + +git show diff --git a/etc/examples/128-empty-file b/etc/examples/128-empty-file new file mode 100755 index 00000000..a52bdb0c --- /dev/null +++ b/etc/examples/128-empty-file @@ -0,0 +1,15 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +git init +git commit --allow-empty -m "Initial commit" + +touch file + +git add file +git commit -m "Initial commit" + +git show diff --git a/etc/examples/139-file-with-space-delimited-dash.diff b/etc/examples/139-file-with-space-delimited-dash.diff new file mode 100644 index 00000000..58963b0a --- /dev/null +++ b/etc/examples/139-file-with-space-delimited-dash.diff @@ -0,0 +1,7 @@ +diff --git a/strange - file.txt b/strange - file.txt +new file mode 100644 +index 0000000..9daeafb +--- /dev/null ++++ b/strange - file.txt +@@ -0,0 +1,1 @@ ++test diff --git a/etc/examples/140-within-line-edits b/etc/examples/140-within-line-edits new file mode 100755 index 00000000..d2595518 --- /dev/null +++ b/etc/examples/140-within-line-edits @@ -0,0 +1,26 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +git init +git commit --allow-empty -m "Initial commit" + +echo "did_emsg = FALSE;" > file.R + +git add file.R +git commit -m "Base commit" + +echo "did_emsg == FALSE;" > file.R + +git add file.R +git commit -m "Short change" + +git revert --no-edit HEAD + +echo "did_emsg = TRUE;" > file.R +git add file.R +git commit -m "Long change" + +git log --patch diff --git a/etc/examples/140-within-line-edits-counter-example b/etc/examples/140-within-line-edits-counter-example new file mode 100755 index 00000000..b8913e90 --- /dev/null +++ b/etc/examples/140-within-line-edits-counter-example @@ -0,0 +1,28 @@ +#!/bin/bash + + +repo=$(mktemp -d) +cd $repo + +git init +git commit --allow-empty -m "Initial commit" + +cat > file <<EOF +aaaa a aaa +bbbb b bbb +cccc c ccc +EOF + +git add file +git commit -m "Base commit" + +cat > file <<EOF +bbbb ! bbb +dddd d ddd +cccc ! ccc +EOF + +git add file +git commit -m "Changes" + +git log --patch diff --git a/etc/examples/205-highlight-bug-1.diff b/etc/examples/205-highlight-bug-1.diff new file mode 100644 index 00000000..2d0c38f1 --- /dev/null +++ b/etc/examples/205-highlight-bug-1.diff @@ -0,0 +1,7 @@ +diff --git a/b b/b +index 1b647ff..b6467a2 100644 +--- a/b ++++ b/b +@@ -1 +1 @@ +-return parent_names ++parent_names diff --git a/etc/examples/205-highlight-bug-2.diff b/etc/examples/205-highlight-bug-2.diff new file mode 100644 index 00000000..1c62a7b8 --- /dev/null +++ b/etc/examples/205-highlight-bug-2.diff @@ -0,0 +1,7 @@ +diff --git i/diff-test.txt w/diff-test.txt +index 5fd0037..3f0bbd0 100644 +--- i/diff-test.txt ++++ w/diff-test.txt +@@ -1,1 +1,1 @@ +- [ ++= ( diff --git a/etc/examples/205-highlight-bug.diff b/etc/examples/205-highlight-bug.diff new file mode 100644 index 00000000..b79a48cb --- /dev/null +++ b/etc/examples/205-highlight-bug.diff @@ -0,0 +1,19 @@ +diff --git i/diff-test.txt w/diff-test.txt +index 5fd0037..3f0bbd0 100644 +--- i/diff-test.txt ++++ w/diff-test.txt +@@ -1,6 +1,10 @@ +-foo ++foo yeah + bar +-return parent_names + [self.tree_name.value] ++parent_names += (self.tree_name.value,) ++if include_module_names: ++ skdjfh ++ kjlkfjs ++return parent_names + +-foo +-bar ++foo-one ++bar-two |