From 7b67eb8c64818976c702af4b98986a2118f4a164 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 19 Apr 2018 18:19:06 +0300 Subject: [PATCH 1/9] Update git-redate Fixed #13 --- git-redate | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/git-redate b/git-redate index b129d6b..99a58c6 100755 --- a/git-redate +++ b/git-redate @@ -77,14 +77,16 @@ while read commit; do else DATE_NO_SPACE="$(echo "${date}")" fi + + COMMIT_ENV=$(cat <<-END - if [ \$GIT_COMMIT = $hash ]; - then - export GIT_AUTHOR_DATE="$DATE_NO_SPACE" - export GIT_COMMITTER_DATE="$DATE_NO_SPACE"; - fi; - END - ) +if [ \$GIT_COMMIT = $hash ]; +then + export GIT_AUTHOR_DATE="$DATE_NO_SPACE" + export GIT_COMMITTER_DATE="$DATE_NO_SPACE"; +fi; +END +) ENVFILTER="$ENVFILTER$COMMIT_ENV" done < $tmpfile From 3301af0de2d7e96ad8b9e8ec73ce95b37690fbe2 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 5 May 2018 18:03:47 +0300 Subject: [PATCH 2/9] Make choice for two editors Vi is a flexible and scalable editor. But it requires certain skills in order to use it. So i added choice between Vi and Nano. --- git-redate | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/git-redate b/git-redate index 99a58c6..9c37ede 100755 --- a/git-redate +++ b/git-redate @@ -11,6 +11,35 @@ is_git_repo() { is_git_repo +make_editor_choice() { + + echo "Which editor do you want to use for this repo?\n"; + echo "1. VI\n"; + echo "2. NANO\n"; + echo "You Choose: "; + + read CHOOSE_EDITOR +} + +is_has_editor() { + SETTINGS_FILE="redate-settings"; + if [ -f "$SETTINGS_FILE" ] + then + OUR_EDITOR=$(cat ${SETTINGS_FILE}); + else + make_editor_choice; + if [ ${CHOOSE_EDITOR} == 1 ] || [ ${CHOOSE_EDITOR} == "1" ]; + then + OUR_EDITOR="vi"; + else + OUR_EDITOR="nano"; + fi + echo ${OUR_EDITOR} > ${SETTINGS_FILE} + fi +} + +is_has_editor + ALL=0 while [[ $# -ge 1 ]] @@ -60,8 +89,7 @@ else fi fi -${VISUAL:-${EDITOR:-vi}} $tmpfile - +${VISUAL:-${EDITOR:-${OUR_EDITOR}}} $tmpfile ENVFILTER="" while read commit; do From 5d9b010a37713173d49e3e038b19ec3babd6bed1 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 22 May 2018 19:02:21 +0300 Subject: [PATCH 3/9] Added commits chunks, Debug mode, etc - Chunks collection - Debug operation (Operation progress) - Fix bug with last line (last commit) in tempfile - Added some params Tested on 2000+ commits - spent some time (5 min) but working. fixed #16 --- git-redate | 85 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 10 deletions(-) diff --git a/git-redate b/git-redate index 9c37ede..adf7e80 100755 --- a/git-redate +++ b/git-redate @@ -21,6 +21,7 @@ make_editor_choice() { read CHOOSE_EDITOR } + is_has_editor() { SETTINGS_FILE="redate-settings"; if [ -f "$SETTINGS_FILE" ] @@ -40,7 +41,10 @@ is_has_editor() { is_has_editor + ALL=0 +DEBUG=0 +LIMITCHUNKS=20 while [[ $# -ge 1 ]] do @@ -52,6 +56,15 @@ case $key in if [ -z "${COMMITS}" ]; then COMMITS="5"; fi; shift ;; + -l| --limit) + LIMITCHUNKS="$2" + if [ -z "${LIMITCHUNKS}" ]; then LIMITCHUNKS="20"; fi; + shift + ;; + -d| --debug) + DEBUG=1 + shift + ;; -a| --all) ALL=1 shift @@ -84,15 +97,22 @@ then git log --pretty=format:"$datefmt | %H | %s" > $tmpfile; else if [ -n "${COMMITS+set}" ]; - then git log -n $COMMITS --pretty=format:"$datefmt | %H | %s" > $tmpfile; + then git log -n ${COMMITS} --pretty=format:"$datefmt | %H | %s" > $tmpfile; else git log -n 5 --pretty=format:"$datefmt | %H | %s" > $tmpfile; fi fi ${VISUAL:-${EDITOR:-${OUR_EDITOR}}} $tmpfile -ENVFILTER="" -while read commit; do + +ITER=0 +COLITER=0 +declare -a COLLECTION + +COUNTCOMMITS=$(awk 'END {print NR}' $tmpfile) + +while read commit || [ -n "$commit" ]; do + IFS="|" read date hash message <<< "$commit" shopt -s nocasematch if [[ "$date" == 'now' ]]; then @@ -115,15 +135,60 @@ then fi; END ) - ENVFILTER="$ENVFILTER$COMMIT_ENV" + + ((ITER++)) + + if [ "${DEBUG}" -eq 1 ] && [ $((ITER % LIMITCHUNKS)) == $((LIMITCHUNKS - 1)) ]; + then + echo "Chunk $COLITER Finished" + fi + + if [ $((ITER % LIMITCHUNKS)) == 0 ] + then + ((COLITER++)) + + if [ "${DEBUG}" -eq 1 ]; + then + echo "Chunk $COLITER Started" + fi + + fi + + COLLECTION[$COLITER]=${COLLECTION[COLITER]}"$COMMIT_ENV" + if [ "${DEBUG}" -eq 1 ] + then + echo "Commit $ITER/$COUNTCOMMITS Collected" + fi + done < $tmpfile -if [ "${ALL}" -eq 1 ]; -then - git filter-branch -f --env-filter "$ENVFILTER" -- --all >/dev/null -else - git filter-branch -f --env-filter "$ENVFILTER" HEAD~$COMMITS..HEAD >/dev/null -fi +ITERATOR=0 +for each in "${COLLECTION[@]}" +do + + ((ITERATOR++)) + + if [ "${ALL}" -eq 1 ]; + then + if [ "${DEBUG}" -eq 1 ]; + then + echo "Chunk $ITERATOR/"${#COLLECTION[@]}" Started" + git filter-branch -f --env-filter "$each" -- --all + echo "Chunk $ITERATOR/"${#COLLECTION[@]}" Finished" + else + git filter-branch -f --env-filter "$each" -- --all >/dev/null + fi + else + if [ "${DEBUG}" -eq 1 ]; + then + echo "Chunk $ITERATOR/"${#COLLECTION[@]}" Started" + git filter-branch -f --env-filter "$each" HEAD~${COMMITS}..HEAD + echo "Chunk $ITERATOR/"${#COLLECTION[@]}" Finished" + else + git filter-branch -f --env-filter "$each" HEAD~${COMMITS}..HEAD >/dev/null + fi + fi +done if [ $? = 0 ] ; then echo "Git commit dates updated. Run 'git push -f BRANCH_NAME' to push your changes." From 570866697b89a93b09ee7ab2a00f711c0d7b7f37 Mon Sep 17 00:00:00 2001 From: Olivier Date: Sun, 1 Jul 2018 08:51:37 +0200 Subject: [PATCH 4/9] Use the standard environment variables EDITOR instead of asking the user --- git-redate | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-redate b/git-redate index adf7e80..7ed6868 100755 --- a/git-redate +++ b/git-redate @@ -27,6 +27,9 @@ is_has_editor() { if [ -f "$SETTINGS_FILE" ] then OUR_EDITOR=$(cat ${SETTINGS_FILE}); + elif [ ! -z "$EDITOR" ] + then + OUR_EDITOR="$EDITOR"; else make_editor_choice; if [ ${CHOOSE_EDITOR} == 1 ] || [ ${CHOOSE_EDITOR} == "1" ]; From f900c21f726fd2547f9eed7d0942403d4a08ce55 Mon Sep 17 00:00:00 2001 From: Andrej Date: Fri, 3 Aug 2018 17:45:24 +0200 Subject: [PATCH 5/9] user-wide settings file --- git-redate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-redate b/git-redate index 7ed6868..66e1788 100755 --- a/git-redate +++ b/git-redate @@ -23,7 +23,7 @@ make_editor_choice() { is_has_editor() { - SETTINGS_FILE="redate-settings"; + SETTINGS_FILE="~/.redate-settings"; if [ -f "$SETTINGS_FILE" ] then OUR_EDITOR=$(cat ${SETTINGS_FILE}); From 4bef29b569163f0a7d9353d159c5092955be3885 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Tue, 13 Nov 2018 22:04:13 -0500 Subject: [PATCH 6/9] adding third option to specify any test editor --- git-redate | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/git-redate b/git-redate index 66e1788..066fd95 100755 --- a/git-redate +++ b/git-redate @@ -16,11 +16,18 @@ make_editor_choice() { echo "Which editor do you want to use for this repo?\n"; echo "1. VI\n"; echo "2. NANO\n"; + echo "3. Your own\n" echo "You Choose: "; read CHOOSE_EDITOR } +get_editor_executable() { + + echo "What is the path to your prefered test editor?\n"; + read EDITOR_PATH +} + is_has_editor() { SETTINGS_FILE="~/.redate-settings"; @@ -32,8 +39,10 @@ is_has_editor() { OUR_EDITOR="$EDITOR"; else make_editor_choice; - if [ ${CHOOSE_EDITOR} == 1 ] || [ ${CHOOSE_EDITOR} == "1" ]; - then + if [ ${CHOOSE_EDITOR} == 3 ] || [ ${CHOOSE_EDITOR} == "3" ]; then + get_editor_executable + OUR_EDITOR=${EDITOR_PATH} + elif [ ${CHOOSE_EDITOR} == 1 ] || [ ${CHOOSE_EDITOR} == "1" ]; then OUR_EDITOR="vi"; else OUR_EDITOR="nano"; From 72de64e24b7afba0b31b36b353296c90a7911576 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Tue, 13 Nov 2018 22:11:57 -0500 Subject: [PATCH 7/9] adding snippet for windows install --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b9070ec..01c1bc8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ For homebrew users, you need to run `brew tap PotatoLabs/homebrew-git-redate` an If you're not using homebrew, you can clone this repo and move the `git-redate` file into any folders in your $PATH. Restart your terminal afterwards and you're good to go! +For window's users, you may paste the file into `${INSTALLATION_PATH}\mingw64\libexec\git-core`. Assuming you used the default settings the installation path will be `C:\Program Files\Git`. + # Usage Simply run: `git redate --commits [[number of commits to view]]`. You'll have to force push in order for your commit history to be rewritten. From 8e8077ff5f8fbe0f3ae54d74bf7eeb4fa08deb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyeon=20Kim=20=28=EA=B9=80=EC=A7=80=ED=98=84=29?= Date: Mon, 4 Jan 2021 00:08:10 +0900 Subject: [PATCH 8/9] Replace preview image TinyPic Has Ceased Operations Reference: https://tinypic.com/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01c1bc8..034b2bc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Change the dates of several git commits with a single command. -![alt tag](http://oi68.tinypic.com/3ud82.jpg) +![alt tag](https://i.stack.imgur.com/yE4cQ.gif) # Installation From 6985e3474d73eafe8b15d2b93e45718db93c049c Mon Sep 17 00:00:00 2001 From: Faiz Jazadi Date: Tue, 4 Jan 2022 18:17:33 +0800 Subject: [PATCH 9/9] Remove "\n" at the end of some echo statements --- git-redate | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-redate b/git-redate index 066fd95..d4a3399 100755 --- a/git-redate +++ b/git-redate @@ -13,18 +13,18 @@ is_git_repo make_editor_choice() { - echo "Which editor do you want to use for this repo?\n"; - echo "1. VI\n"; - echo "2. NANO\n"; - echo "3. Your own\n" - echo "You Choose: "; + echo "Which editor do you want to use for this repo?"; + echo "1. VI"; + echo "2. NANO"; + echo "3. Your own" + echo -n "You Choose: "; read CHOOSE_EDITOR } get_editor_executable() { - echo "What is the path to your prefered test editor?\n"; + echo "What is the path to your prefered test editor?"; read EDITOR_PATH }