From: Simon Ruderich Date: Sat, 2 Jun 2018 11:31:07 +0000 (+0200) Subject: Merge branch 'vcs' X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=commitdiff_plain;h=b82ea1844de8988bac632a588c6308b22b5ac1a0;hp=ac56b3081d3e1563484e325851113d84c236f43b Merge branch 'vcs' --- diff --git a/vcs/.gitignore b/vcs/.gitignore new file mode 100644 index 0000000..90c6c6a --- /dev/null +++ b/vcs/.gitignore @@ -0,0 +1,4 @@ +# Ignore generated files. +cvsrc +gitconfig +hgrc diff --git a/vcs/Makefile b/vcs/Makefile new file mode 100644 index 0000000..23d5991 --- /dev/null +++ b/vcs/Makefile @@ -0,0 +1,4 @@ +all: + @./setup.sh + +.PHONY: all diff --git a/vcs/bin/tig.pl b/vcs/bin/tig.pl new file mode 100755 index 0000000..881583d --- /dev/null +++ b/vcs/bin/tig.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl + +# tig-like git log output. Used when tig is not available or broken. + +# Copyright (C) 2013 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +use strict; +use warnings; + +use POSIX (); +use Term::ANSIColor qw(colored); + + +my $color_graph = 'yellow'; +my $color_hash = 'cyan'; +my $color_ref_sep = 'cyan'; +my $color_ref_head = 'cyan bold'; +my $color_ref_branch = 'green bold'; +my $color_ref_reference = 'red bold'; +my $color_author = 'magenta'; + + +# Aliases in Git with "! ..." are always run in the top-level-directory. +# GIT_PREFIX contains the relative path to the current subdirectory. Thanks to +# dr_lepper in #git on Freenode (2013-04-03 23:17 CEST) for telling me about +# GIT_PREFIX. +if (defined $ENV{GIT_PREFIX} and $ENV{GIT_PREFIX} ne '') { + chdir $ENV{GIT_PREFIX} or die $!; +} + +my $format = '%x00' # separator from --graph + . '%h' . '%x00' # abbreviated commit hash + . '%at' . '%x00' # author date + . '%an' . '%x00' # author name + . '%s' . '%x00' # subject + . '%d'; # ref names +my @cmd = ('git', 'log', '--graph', "--format=$format", + # use either given arguments or --all to list all commits + (scalar @ARGV) ? @ARGV : '--all'); +open my $fh, '-|', @cmd or die $!; + +my $pager = $ENV{PAGER}; +# Try to find an usable pager without searching $PATH. +if (not defined $pager) { + foreach my $path (qw(/usr/bin/less /bin/less /usr/bin/more /bin/more)) { + next if not -x $path; + + $pager = $path; + last; + } +} +# Use a pager if STDOUT is a terminal. +if (-t STDOUT and defined $pager) { + open STDOUT, '|-', $pager or die $!; +} + +while (<$fh>) { + # History graph line. + if (m{^([|/\\_ ]+)$}) { + print colored($_, $color_graph); + next; + } + + # Commit line. + /^([ *|.\\-]+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)\x00(.*)$/ or die $_; + my $prefix = $1; + my $hash = colored($2, $color_hash); + my $date = POSIX::strftime('%Y-%m-%d', localtime($3)); + my $author = colored($4, $color_author); + my $message = $5; + my $refs = $6; + + # Strip trailing whitespace. + $prefix =~ s/\s+$//; + # Color "graph". + $prefix =~ s/\|/colored($&, $color_graph)/ge; + + # Strip leading whitespace and braces. + $refs =~ s/^\s+//; + $refs =~ tr/()//d; + + # Color refs. + $refs = join colored(', ', $color_ref_sep), map { + my $color; + if ($_ eq 'HEAD') { + $color = $color_ref_head; + } elsif (m{/}) { + $color = $color_ref_reference; + } else { + $color = $color_ref_branch; + } + colored($_, $color); + } split /, /, $refs; + + if ($refs ne '') { + $refs = ' ' + . colored('(', $color_ref_sep) + . $refs + . colored(')', $color_ref_sep); + } + + printf "%s %s %s %s%s %s\n", + $prefix, $hash, $date, $author, $refs, $message; +} + +close $fh or die $!; + +# Necessary for the redirection to a pager or the pager terminates after our +# script finishes without displaying all data. +if (defined $pager) { + close STDOUT or die $!; +} diff --git a/vcs/cvsrc.in b/vcs/cvsrc.in new file mode 100644 index 0000000..90b11b4 --- /dev/null +++ b/vcs/cvsrc.in @@ -0,0 +1,30 @@ +# CVS configuration file. + +# CVS doesn't support comments and newlines in ~/.cvsrc. They must be stripped +# before using this file. + +# Copyright (C) 2011-2014 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +# Don't display all checked directories. +cvs -q + +# Use unified diffs. +diff -u +# Create any directories which were removed locally. +update -d + +# vim: ft=cvsrc diff --git a/vcs/gitattributes b/vcs/gitattributes new file mode 100644 index 0000000..8258ef8 --- /dev/null +++ b/vcs/gitattributes @@ -0,0 +1,20 @@ +# Global Git configuration file for attributes. + +# Copyright (C) 2013 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +*.pdf diff=pdf +*.gz diff=gzip diff --git a/vcs/gitconfig.in b/vcs/gitconfig.in new file mode 100644 index 0000000..50d88a9 --- /dev/null +++ b/vcs/gitconfig.in @@ -0,0 +1,249 @@ +# Global Git configuration file. + +# Copyright (C) 2011-2017 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +[user] + name = Simon Ruderich + email = simon@ruderich.org + +[color] + ui = auto + +[color "diff"] + # Meta information. + meta = yellow bold + # Hunk header. + frag = magenta bold + # Function in hunk header. + func = blue bold + # Removed lines. + old = red bold + # Added lines. + new = green bold + # Commit headers. + commit = cyan + +[color "grep"] + # GNU grep-like colors. + filename = magenta + linenumber = green + +[core] + editor = vim + # Global gitattributes file. Thanks to canton7 in #git on Freenode + # (2011-11-09 13:23 CET). + attributesfile = PWD/gitattributes + +[pager] + # Use pager for the following commands. + status = true + tag = true + +[interactive] + # Don't require in interactive commands which require only a + # single key, for example `git add --patch`. Requires Perl module + # Term::Readkey. + singlekey = true + +[alias] + ## Shortcuts for often used commands. + # + ## Local. + c = commit --verbose + ca = commit --verbose --amend + cad = commit --verbose --amend --date= + d = diff + dw = diff --color-words + ds = diff --stat + dc = diff --cached + dcw = diff --cached --color-words + dcs = diff --cached --stat + g = grep + gi = grep --ignore-case + s = status + l = log + ls = log --stat + lp = log --patch + lpw = log --patch --color-words + ld = show --date=short -s --pretty='format:%h (\"%s\", %ad)' # describe + a = add + ap = add --patch + au = add --update + rs = reset + rsh = reset --hard + rsp = reset --patch + rv = revert + cl = clean -ndx + clf = clean -fdx + ## Branches. + co = checkout + b = branch -a -v + br = branch + m = merge + mo = merge origin/master + re = rebase + rei = rebase --interactive + rec = rebase --continue + cp = cherry-pick + ## Submodules. + sm = submodule + ## Remote. + f = fetch + t = tag + p = push + # Parallel git remote update. Also strips unnecessary output. + ru = "! git remote \ + | xargs -d '\\n' -n1 -P0 git remote update 2>&1 \ + | sed '/^$/d; \ + /^Please make sure you have the correct access rights$/d; \ + /^and the repository exists\\.$/d;'" + # Push to all remotes. Thanks to albel727 in #git on Freenode + # (2011-06-04 16:06 CEST) for the idea. Modified to push in parallel + # and to strip unnecessary output. + rp = "! git remote \ + | xargs -d '\\n' -n1 -P0 git push 2>&1 \ + | sed '/^$/d; \ + /^Please make sure you have the correct access rights$/d; \ + /^and the repository exists\\.$/d;'" + ## Patches. + fp = format-patch + ## Maintenance. + # (Redirection of stderr is necessary to prevent missing output with + # my "color stderr" solution in Zsh.) + fs = ! git fsck --strict --full 2>&1 + fg = ! git fs && git gc --aggressive 2>&1 # fsck and compress repo + ## Misc. + sl = stash list + ss = stash save + ssk = stash save --keep-index + ssu = stash save --include-untracked + sa = stash apply --index + sp = stash pop --index + + ## Custom commands. + # + # tig-like log view. Similar to the following but with author/date + # information. --pretty=format is not used because it doesn't allow + # precise enough control over formats and colors. + # + # tig = log --pretty=oneline --graph --all --decorate --abbrev-commit + tig = ! PWD/bin/tig.pl + + # Create backup of uncommitted and untracked changes. + ssb = "! git stash save --include-untracked \ + \"Backup on $(LANG=C date '+%a, %d %b %Y %H:%M:%S %z')\" \ + >/dev/null \ + && git stash apply >/dev/null" + + # Display list and content of untracked files. Untracked directories + # and symbolic links are only listed. + u = "! git ls-files --other --exclude-standard --directory -z \ + | xargs -0 sh -c '\ + for x; do \ + printf \"\\033[1;33m-> %s\\033[0m:\" \"$x\"; \ + if test -d \"$x\"; then \ + echo \" directory\"; \ + elif test -h \"$x\"; then \ + echo \" symbolic link\"; \ + else \ + echo; \ + cat \"$x\"; \ + fi; \ + echo; \ + done' argv0 \ + | less" + +[diff] + # Detect copies and renames. + renames = copy + + # Diff algorithm to use. + algorithm = histogram + + # Highlight moved code in a different color. + colorMoved = zebra + + # Replace "a/" and "b/" prefix in diffs with characters describing the + # context (e.g. "i/"ndex and "w/"ork tree). + mnemonicprefix = true + + # Change the definition of a word as used by diff --color-words to be + # shorter (not only spaces) and thus simplify the generated diffs. + # Words ([a-zA-Z0-9_]+) are matched, or a single non-word character + # ([^a-zA-Z0-9_]), therefore changes to words are shown in complete + # (e.g. from "word" to "newword" as "[-word-]{+newword+}"), but + # changes to non-word characters are shown character wise (e.g. from + # "==" to "!=" as "[-=-]{+!+}="); [-..-] is removal, {+..+} is + # addition. See t/ for some tests and examples. + wordRegex = [a-zA-Z0-9_]+|[^a-zA-Z0-9_] + +# Allow diffing of some binary files. +# +# "sh -c '..' ARGV0" is used when the programs require additional arguments +# which are passed after ARGV0 by git. +[diff "gzip"] + textconv = gzip -d -c +[diff "pdf"] + textconv = sh -c 'exec pdftotext "$@" -' ARGV0 +[diff "sqlite"] + textconv = sh -c 'exec sqlite3 "$@" .dump' ARGV0 + +[log] + # Display branches/tag names in log (same as log's --decorate option). + decorate = short + # If a single file is given to `git log`, automatically use --follow. + follow = true + +[merge] + tool = vimdiff + + # Merge upstream branch if `git merge` is called without arguments. + defaultToUpstream = true + +[rebase] + # Use single-letter command names in git rebase -i which are faster to + # change. + abbreviateCommands = true + +[push] + # When running git push without a refspec push only the current + # branch, see man page git-config(1) for details. Default since Git + # 2.0. + default = simple + +[format] + # When using git format-patch use threads and add all patches as + # replies to the first one. + thread = shallow + +[transfer] + # Automatically fsck objects when receiving them (respected by git + # receive-pack and git fetch (>= 1.7.8, for fetch)). + fsckObjects = true + +[advice] + # Disable annoying advice messages. + waitingForEditor = false + + +# NON-GIT SETTINGS + +[annex] + # My SSH config already uses ControlMaster where appropriate. + sshcaching = false + +# vim: ft=gitconfig diff --git a/vcs/hgrc b/vcs/hgrc new file mode 100644 index 0000000..ee4de57 --- /dev/null +++ b/vcs/hgrc @@ -0,0 +1,62 @@ +# This is the Mercurial configuration file. + +# Copyright (C) 2011-2012 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +[ui] +username = Simon Ruderich + +# Use git diffs with support for renames, binaries, access rights, etc. +[diff] +git = True + +[extensions] +# Convert other vcs to mercurial. +hgext.convert = +# Simplify pull and merge processes. +hgext.fetch = +# Log output similar to hg view but as ASCII. +hgext.graphlog = +# Enable hg view. +hgext.hgk = +# Patch stack support. +hgext.mq = +# Use a pager for all output. +hgext.pager = +# Partial commit utility. +hgext.record = +# Allows cherry-picking and rebasing. +hgext.transplant = + +# Necessary for hg view. +[hgk] +path = /usr/share/mercurial/hgk + +[hooks] +# Precommit hook which runs tests if they exist. +precommit = precommit-runtests +# Prevent "hg pull" if MQ patches are applied. +prechangegroup.mq-no-pull = ! hg qtop > /dev/null 2>&1 +# Prevent "hg push" if MQ patches are applied. +preoutgoing.mq-no-push = ! hg qtop > /dev/null 2>&1 + +# Use colordiff and less as pager so that output from diff is colored and +# everything is easily readable in a terminal. +[pager] +pager = colordiff | less +ignore = record, qrecord, view, clone + +# vim: ft=cfg diff --git a/vcs/setup.sh b/vcs/setup.sh new file mode 100755 index 0000000..bf22f99 --- /dev/null +++ b/vcs/setup.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# Setup script for VCS configuration files. + +# Copyright (C) 2011-2013 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +set -eu + +. ../lib.sh + + +if installed git; then + generate gitconfig .in simple_cpp PWD -- "`pwd`" + + # Older Git versions don't support push.default = simple. + if ! git status >/dev/null 2>&1; then + echo 'gitconfig: removing push.default = simple' + grep_i -v '^[[:space:]]default = simple$' gitconfig + fi + # Even older Git versions don't support color.function. + if ! git status >/dev/null 2>&1; then + echo 'gitconfig: removing color.function' + sed_i 's/^[[:space:]]*function = .*//' gitconfig + fi + # Even older Git versions don't support git log --patch but only -p. + if ! git log --patch >/dev/null 2>&1; then + echo 'gitconfig: replacing git log --patch with -p' + sed_i 's/log --patch/log -p/' gitconfig + fi + + # If coloredstderr is used to color stderr then remove the workaround for + # missing output to stderr. + if test -n "${LD_PRELOAD:+set}" \ + && printf '%s' "$LD_PRELOAD" | grep libcoloredstderr.so >/dev/null; then + echo 'gitconfig: removing stderr fix' + sed_i '/^\t\(fs\|fg\) =/ s/2>&1//' gitconfig + fi + + link gitconfig ~/.gitconfig +fi + +if installed tig; then + if tig --version | grep -F 'tig version 1.' >/dev/null; then + link tigrc.old ~/.tigrc + else + link tigrc ~/.tigrc + fi +fi + +if installed hg; then + link hgrc ~/.hgrc +fi + +if installed cvs; then + # CVS doesn't support any comments nor empty lines in cvsrc. + grep -E -v '^#' cvsrc.in | grep -E -v '^$' >cvsrc + + link cvsrc ~/.cvsrc +fi diff --git a/vcs/t/expected-empty.txt b/vcs/t/expected-empty.txt new file mode 100644 index 0000000..19c91bf --- /dev/null +++ b/vcs/t/expected-empty.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +==== + +Short sentence with words! + +Longer sentence even more words, ain't that nice! + +And other one, just testing. + +option: new value +option-two: new-value-two +option-three: "value-three" + +function testme() { + firstCall(); + while (a != b) { + if (!second_var) { + third_call() && fourth_call() \ + || fifth_call(); + } + } + return 42; +} + +allow = $0 $! $? $. +allow = $! $? +allow = $0 $! $? diff --git a/vcs/t/expected-nonspaces.txt b/vcs/t/expected-nonspaces.txt new file mode 100644 index 0000000..d6b3558 --- /dev/null +++ b/vcs/t/expected-nonspaces.txt @@ -0,0 +1,32 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +[-=====-]{+====+} + +[-Simple-]{+Short+} sentence with [-a few words.-]{+words!+} + +Longer sentence[-with-] even more [-words ..-]{+words,+} ain't that [-nice?-]{+nice!+} + +And [-another-]{+other+} one, just testing. + +option: {+new+} value +option-two: [-value-two-]{+new-value-two+} +option-three: [-value-three-]{+"value-three"+} + +function testme() { + [-first_call();-] +[- if-]{+firstCall();+} +{+ while+} (a [-==-]{+!=+} b) { + if [-(!second_call())-]{+(!second_var)+} { + [-third_call();-]{+third_call() && fourth_call() \+} +{+ || fifth_call();+} + } + } + return 42; +} + +allow = {+$0+} $! $? $. +allow = $! $?[-$.-] +allow = {+$0+} $! $?[-$.-] diff --git a/vcs/t/expected-word-nonword.txt b/vcs/t/expected-word-nonword.txt new file mode 100644 index 0000000..76b34ac --- /dev/null +++ b/vcs/t/expected-word-nonword.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +====[-=-] + +S[-imple-]{+hort+} sentence with [-a few -]words[-.-]{+!+} + +Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+} + +And [-an-]other one, just testing. + +option: {+new +}value +option-two: {+new-+}value-two +option-three: {+"+}value-three{+"+} + +function testme() { + first[-_c-]{+C+}all(); + {+wh+}i[-f-]{+le+} (a [-=-]{+!+}= b) { + if (!second_{+var) {+} +{+ third_+}call(){+ && fourth_call(+}) [-{-]{+\+} +{+ +} {+|| fif+}th[-ird-]_call(); + } + } + return 42; +} + +allow = ${+0 $+}! $? $. +allow = $! $?[- $.-] +allow = $[-!-]{+0+} $[-?-]{+!+} $[-.-]{+?+} diff --git a/vcs/t/expected-words-nonword.txt b/vcs/t/expected-words-nonword.txt new file mode 100644 index 0000000..5e0f6b1 --- /dev/null +++ b/vcs/t/expected-words-nonword.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +====[-=-] + +[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+} + +Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+} + +And [-another-]{+other+} one, just testing. + +option: {+new +}value +option-two: {+new-+}value-two +option-three: {+"+}value-three{+"+} + +function testme() { + [-first_call-]{+firstCall+}(); + [-if-]{+while+} (a [-=-]{+!+}= b) { + if (![-second_call()-]{+second_var+}) { + third_call(){+ && fourth_call() \+} +{+ || fifth_call()+}; + } + } + return 42; +} + +allow = ${+0 $+}! $? $. +allow = $! $?[- $.-] +allow = $[-!-]{+0+} $[-?-]{+!+} $[-.-]{+?+} diff --git a/vcs/t/expected-words-nonwords-spaces.txt b/vcs/t/expected-words-nonwords-spaces.txt new file mode 100644 index 0000000..cbc70dc --- /dev/null +++ b/vcs/t/expected-words-nonwords-spaces.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +[-=====-]{+====+} + +[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+} + +Longer sentence [-with -]even more words[- .. -]{+, +}ain't that nice[-?-]{+!+} + +And [-another-]{+other+} one, just testing. + +option: {+new +}value +option-two: {+new-+}value-two +option-three[-: -]{+: "+}value-three{+"+} + +function testme() { + [-first_call-]{+firstCall+}(); + [-if-]{+while+} (a[- == -]{+ != +}b) { + if (![-second_call()) {-]{+second_var) {+} + third_call{+() && fourth_call() \+} +{+ || fifth_call+}(); + } + } + return 42; +} + +allow[- = $! $? $.-]{+ = $0 $! $? $.+} +allow[- = $! $? $.-]{+ = $! $?+} +allow[- = $! $? $.-]{+ = $0 $! $?+} diff --git a/vcs/t/expected-words-nonwords.txt b/vcs/t/expected-words-nonwords.txt new file mode 100644 index 0000000..cbc70dc --- /dev/null +++ b/vcs/t/expected-words-nonwords.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +[-=====-]{+====+} + +[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+} + +Longer sentence [-with -]even more words[- .. -]{+, +}ain't that nice[-?-]{+!+} + +And [-another-]{+other+} one, just testing. + +option: {+new +}value +option-two: {+new-+}value-two +option-three[-: -]{+: "+}value-three{+"+} + +function testme() { + [-first_call-]{+firstCall+}(); + [-if-]{+while+} (a[- == -]{+ != +}b) { + if (![-second_call()) {-]{+second_var) {+} + third_call{+() && fourth_call() \+} +{+ || fifth_call+}(); + } + } + return 42; +} + +allow[- = $! $? $.-]{+ = $0 $! $? $.+} +allow[- = $! $? $.-]{+ = $! $?+} +allow[- = $! $? $.-]{+ = $0 $! $?+} diff --git a/vcs/t/expected-words-nonwordspaces-spaces.txt b/vcs/t/expected-words-nonwordspaces-spaces.txt new file mode 100644 index 0000000..11769da --- /dev/null +++ b/vcs/t/expected-words-nonwordspaces-spaces.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +[-=====-]{+====+} + +[-Simple-]{+Short+} sentence with [-a few -]words[-.-]{+!+} + +Longer sentence [-with -]even more words[- ..-]{+,+} ain't that nice[-?-]{+!+} + +And [-another-]{+other+} one, just testing. + +option: {+new +}value +option-two: {+new-+}value-two +option-three: {+"+}value-three{+"+} + +function testme() { + [-first_call-]{+firstCall+}(); + [-if-]{+while+} (a [-==-]{+!=+} b) { + if (![-second_call())-]{+second_var)+} { + third_call{+() && fourth_call() \+} +{+ || fifth_call+}(); + } + } + return 42; +} + +allow = {+$0 +}$! $? $. +allow = $! $?[- $.-] +allow = {+$0 +}$! $?[- $.-] diff --git a/vcs/t/expected-words-nonwordspaces.txt b/vcs/t/expected-words-nonwordspaces.txt new file mode 100644 index 0000000..ce5d927 --- /dev/null +++ b/vcs/t/expected-words-nonwordspaces.txt @@ -0,0 +1,31 @@ +diff --git a/test.txt b/test.txt +--- a/test.txt ++++ b/test.txt +@@ -1,26 +1,27 @@ +Tests +[-=====-]{+====+} + +[-Simple-]{+Short+} sentence with[-a few-] words[-.-]{+!+} + +Longer sentence[-with-] even more words[-..-]{+,+} ain't that nice[-?-]{+!+} + +And [-another-]{+other+} one, just testing. + +option: {+new+} value +option-two: {+new-+}value-two +option-three: {+"+}value-three{+"+} + +function testme() { + [-first_call-]{+firstCall+}(); + [-if-]{+while+} (a [-==-]{+!=+} b) { + if (![-second_call())-]{+second_var)+} { + third_call{+() && fourth_call() \+} +{+ || fifth_call+}(); + } + } + return 42; +} + +allow = {+$0+} $! $? $. +allow = $! $?[-$.-] +allow = {+$0+} $! $?[-$.-] diff --git a/vcs/t/test.sh b/vcs/t/test.sh new file mode 100755 index 0000000..6f1084b --- /dev/null +++ b/vcs/t/test.sh @@ -0,0 +1,111 @@ +#!/bin/sh + +# Small test file to check different --word-diff-regex settings in Git. + +# Copyright (C) 2012-2014 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +set -eu + +git_diff() { + git diff --color=never --word-diff=plain --word-diff-regex="$1" \ + | grep -v '^index ' >"result-$2.txt" + diff -u "../expected-$2.txt" "result-$2.txt" +} + + +# Setup test directory/files. +mkdir test +cd test + +git init >/dev/null +cat >test.txt </dev/null + +cat >test.txt <. + + +# Don't display uncommitted changes. +set show-changes = no + +# Ignore case when searching. +set ignore-case = yes + +# Don't write ~/.tig_history. +set history-size = 0 + + +# DISPLAY + +# Same as the default, but use relative dates. +set main-view = date:relative author:full commit-title:yes,graph,refs + + +# BINDINGS + +# Allow moving in the main menu while displaying a diff in the bottom of the +# screen. +bind generic J next +bind generic K previous + +# Mutt like bindings to move to first and last line. +bind generic = move-first-line +bind generic * move-last-line + +# Close current view like in mutt. +bind diff i view-close + +# Unbind unnecessary views. I only use the main view and view diffs of +# commits. +bind generic m none +bind generic d none +bind generic l none +bind generic t none +bind generic f none +bind generic b none +bind generic r none +bind generic s none +bind generic S none +bind generic c none +bind generic y none +bind generic g none +bind generic p none +# Unbind commands which may change the repository. I use tig only as a viewer. +bind main C none + + +# COLORS + +# Try to mimic gitk's colors. + +color date default default +color delimiter default default # ~ if text is too long + +# Main window. +color cursor black cyan # currently selected line +color author default default +color graph-commit magenta default # commit dots in graph +color main-head green default bold # HEAD +color main-ref green default # branches +color main-remote yellow default # remote branches +color main-tag yellow default bold # tags +color main-local-tag yellow default bold # local tags (normal tags) + +# Information at the top of the commit diff. +color commit default default +color "Author: " default default +color "Commit: " default default +color pp-merge default default +color "Date: " default default +color "AuthorDate: " default default +color "CommitDate: " default default +color pp-refs default default +# Special parts of the commit message. +color " Signed-off-by" default default +color " Acked-by" default default + +# Diff coloring. +color diff-header default default bold # diff --git a/.. b/.. +color diff-index default default bold # index abc..def +color diff-chunk cyan default # @@ -.. +.. @@ + +# vim: ft=muttrc diff --git a/vcs/tigrc.old b/vcs/tigrc.old new file mode 100644 index 0000000..8824257 --- /dev/null +++ b/vcs/tigrc.old @@ -0,0 +1,104 @@ +# tig configuration file. + +# Copyright (C) 2011-2012 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +# Show the revision graph like gitk does. +set show-rev-graph = yes + +# Use relative dates. +set show-date = relative + +# Don't display uncommitted changes. +set show-changes = no + +# Ignore case when searching. +set ignore-case = yes + + +# BINDINGS + +# Allow moving in the main menu while displaying a diff in the bottom of the +# screen. +bind generic J next +bind generic K previous + +# Mutt like bindings to move to first and last line. +bind generic = move-first-line +bind generic * move-last-line + +# Close current view like in mutt. +bind diff i view-close + +# Unbind unnecessary views. I only use the main view and view diffs of +# commits. +bind generic m none +bind generic d none +bind generic l none +bind generic t none +bind generic f none +bind generic B none +bind generic H none +bind generic p none +bind generic S none +bind generic c none +# Unbind commands which may change the repository. I use tig only as a viewer. +bind generic C none +bind generic u none +bind generic ! none +bind generic M none +bind generic 1 none +bind generic @ none +bind generic e none +bind generic G none + + +# COLORS + +# Try to mimic gitk's colors. + +color date default default +color delimiter default default # ~ if text is too long + +# Main window. +color cursor black cyan # currently selected line +color main-author default default # just 'author' in newer versions +color graph-commit magenta default # commit dots in graph +color main-head green default bold # HEAD +color main-ref green default # branches +color main-remote yellow default # remote branches +color main-tag yellow default bold # tags +color main-local-tag yellow default bold # local tags (normal tags) + +# Information at the top of the commit diff. +color commit default default +color pp-author default default +color pp-commit default default +color pp-merge default default +color pp-date default default +color pp-adate default default +color pp-cdate default default +color pp-refs default default +# Special parts of the commit message. +color signoff default default +color acked default default + +# Diff coloring. +color diff-header default default bold # diff --git a/.. b/.. +color diff-index default default bold # index abc..def +color diff-chunk cyan default # @@ -.. +.. @@ + +# vim: ft=muttrc