Hi, here it is. Style may be crude as I usually write perl.
#!/bin/sh # # A variant of git pull which operates over Tor and # - figures out when 'torify' needs to be used # - shows the changes that were made to the repository # - before attempting to merge # --lynX & heldensaga, 2017 # # I recommend piping the output into # vim -R "+set syntax=diff" # but since that isn't everybody's choice of editor # I won't work it into this script...
# would be more elegant to tell you how to # configure this in your .git/config? gitdiff="git diff -b -M77% --minimal"
# 'resolve' has served me well as default strategy gitmerge="git merge -s resolve"
branch="$*" if test x"$*" = x; then branch="origin" fi # echo $branch
url=`git remote get-url $branch` if test x"$url" = x; then exit fi # echo $url
case $url in http*) torify="" echo "*** Fetching from $url via web proxy" ;; *) torify="torsocks" echo "*** Fetching from $url via torsocks" esac # echo $torify
$torify git fetch $branch \ && $gitdiff master..$branch/master \ && exec $gitmerge $branch/master
test x"$url" = x
Some users may be a bit unfamiliar with this longform 'test' construct having trended from that in say their distro's example rc scripts over recent posix and bugfixed decades, easier visual delimited parsing, 4 chars of line width saved, to form of...
[ ! "$var" ]
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
Some like $() over ``, or indenting line continuations too. As in perl, tmtowtdi, no worries.
On Tue, Jan 31, 2017 at 04:53:20AM -0500, grarpamp wrote:
[ ! "$var" ]
Thank you. That was one of the constructs why I never took bourne shell seriously.. ;) but this looks a lot more acceptable. In the spirit of sharing, here's one more privacy-oriented git script:
#!/bin/sh # # working habits privacy-preserving git commit command # --lynX & heldensaga, 2016 # # ever wondered what implications it can have that the git # logs of the projects you are working on give a lot of # insight in your working habits.. your discipline, your # real-life duties or absence of duties? this script # censors such invasive information. by means of this # script it will no longer be visible when you committed # work items and how much time you spent on them. to keep # tools, such as redmine, from breaking as they actually # make assumptions regarding the continuity of time, this # script simply takes the timestamp of the previous commit # and adds *one second* to it.
# default for new repositories is "1984-04-04 00:44:04 GMT" # don't try a unixtime before 1973 as git-commit will ignore that. # last=`git log -1 --pretty=%ct 2>/dev/null` || last=449887443
next=$(($last+1))
export GIT_AUTHOR_DATE="$next GMT" export GIT_COMMITTER_DATE="$next GMT"
exec git commit $*
# then check the results using 'git log --pretty=fuller'