config/git: fix old migrated scripts

This commit is contained in:
xeruf 2023-05-10 17:47:39 +02:00
parent 89790fdd10
commit d74eef021f
3 changed files with 9 additions and 9 deletions

View File

@ -37,7 +37,6 @@ gcn() {
# if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm # if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm
git() { git() {
case "$1" in case "$1" in
(reset) test "$2" = "--hard" && return 66;;
(config) ;; (config) ;;
(clone) ;; (clone) ;;
(*) case "$PWD" in (*) case "$PWD" in

View File

@ -1,32 +1,33 @@
#!/bin/sh -e #!/bin/sh -e
# The git [c]ommit st[ash] # The git [c]ommit st[ash]
# Given a committish, this command saves a list of commits between the HEAD and the given committish into the .git directory. # Given a committish,
# this command saves a list of commits between the HEAD and the given committish
# into the .git directory.
# Without parameters it applies the saved list of commits onto the current HEAD. # Without parameters it applies the saved list of commits onto the current HEAD.
# NOTE: You should prefer rebase -i to this brewery. # NOTE: You should prefer rebase -i to this brewery.
local verbosity=1 verbosity=1
while test $# -gt 0; do while test $# -gt 0; do
case $1 in case $1 in
(-v) verbosity=2; shift 1;; (-v) verbosity=2; shift 1;;
(-q|--quiet) verbosity=0; shift 1;; (-q|--quiet) verbosity=0; shift 1;;
(--theirs) local params=(-X theirs); shift 1;; (--theirs) params=(-X theirs); shift 1;;
(*) break;; (*) break;;
esac esac
done done
local stashed="$(git rev-parse --git-path stashed-commits)" stashed="$(git rev-parse --git-path stashed-commits)"
if [ $1 ]; then if [ $1 ]; then
if [ $verbosity -eq 0 ] if [ $verbosity -eq 0 ]
then git rev-list --reverse "HEAD...$1" >$stashed then git rev-list --reverse "HEAD...$1" >$stashed
else git rev-list --reverse "HEAD...$1" | tee $stashed else git rev-list --reverse "HEAD...$1" | tee $stashed
fi fi
else else
local aborted
for commit in $(cat $stashed); do for commit in $(cat $stashed); do
[ $aborted ] && rest+=($commit) && continue [ $aborted ] && rest+=($commit) && continue
[ $verbosity -gt 0 ] && git --no-pager log --oneline -1 $commit [ $verbosity -gt 0 ] && git --no-pager log --oneline -1 $commit
git-withdate $commit cherry-pick $commit ${params:0} >/dev/null git-withdate $commit cherry-pick $commit ${params:0} >/dev/null
local last=$? last=$?
[ $last -gt 0 ] && local aborted=true && typeset -a rest && continue [ $last -gt 0 ] && aborted=true && typeset -a rest && continue
[ $verbosity -gt 0 ] && echo -e "\e[1A$(git log --color=always --pretty=format:"%C(yellow)$(git rev-parse --short 'HEAD^^')%C(bold) -> %Creset%C(yellow)%h%Creset %s" -1)" [ $verbosity -gt 0 ] && echo -e "\e[1A$(git log --color=always --pretty=format:"%C(yellow)$(git rev-parse --short 'HEAD^^')%C(bold) -> %Creset%C(yellow)%h%Creset %s" -1)"
[ $verbosity -gt 1 ] && git status -s [ $verbosity -gt 1 ] && git status -s
done done

View File

@ -1,4 +1,4 @@
#!/bin/sh -e #!/bin/sh -e
# Execute a git command (usually commit) using the AuthorDate of a given committish # Execute a git command (usually commit) using the AuthorDate of a given committish
local date=$(git log --pretty=format:%at -1 "$1") date=$(git log --pretty=format:%at -1 "$1")
GIT_AUTHOR_DATE="$date" GIT_COMMITTER_DATE="$date" git "${@:2}" GIT_AUTHOR_DATE="$date" GIT_COMMITTER_DATE="$date" git "${@:2}"