{"thread":{"id":"1646","subject":"[PATCH] cogito -- add -c $commit support","startedAt":"2005-08-25T18:19:55Z","lastAt":"2005-08-25T18:19:55Z","messageCount":1,"participants":["James Ketrenos"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7751","messageId":"430E0BCB.5010402@linux.intel.com","threadId":"1646","inReplyTo":null,"subject":"[PATCH] cogito -- add -c $commit support","fromName":"James Ketrenos","fromEmail":"jketreno@linux.intel.com","sentAt":"2005-08-25T18:19:55Z","receivedAt":"2005-08-25T18:19:55Z","isPatch":true,"sender":{"key":"jketreno@linux.intel.com","avatar":"https://gravatar.com/avatar/f4a487ad53c70943ed10ba220390cc7a004e4ba617c962bc4b7afcbd2bc08cc7?d=mp&s=160"},"body":"Add -c parameter to cg-commit to set commit data based on prior commit.\n\nThis will then commit any changes using the author and message from the commit\nspecified.  The actual logic for parsing the old commit values was taken from\ngit-commit-script.\n\ngit-commit-script supports this option via -C, which was already used in cg-commit\nfor something else.\n\nSigned-off-by: James Ketrenos <jketreno@linux.intel.com>\n---\n\n cg-commit |   46 +++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 45 insertions(+), 1 deletions(-)\n\nb07037397659763271e946fc15c0b3c61a8fcdfa\ndiff --git a/cg-commit b/cg-commit\n--- a/cg-commit\n+++ b/cg-commit\n@@ -3,6 +3,8 @@\n # Commit into a GIT repository.\n # Copyright (c) Petr Baudis, 2005\n # Based on an example script fragment sent to LKML by Linus Torvalds.\n+# \n+# -c commit based on code in git-commit-script by Linus Torvalds\n #\n # Commits changes to a GIT repository. Accepts the commit message from\n # `stdin`. If the commit message is not modified the commit will be\n@@ -45,6 +47,12 @@\n #\tmight not actually _have_ any object database. This option is\n #\tnormally not interesting.\n #\n+# -c::\n+#\tSpecifify the commit SHA to inherit the GIT_AUTHOR_* variables and\n+#\tcommit message from.  The GIT_COMMITTER_* variables will not be\n+#\tinherited from the specified commit.  This option is typically used\n+#\twhen replaying commits from one lineage or repository to another.\n+#\t\n # FILES\n # -----\n # $GIT_DIR/author::\n@@ -112,6 +120,7 @@ ignorecache=\n infoonly=\n commitalways=\n missingok=\n+use_commit=\n msgs=()\n while optparse; do\n \tif optparse -C; then\n@@ -128,6 +137,8 @@ while optparse; do\n \t\tforce=1\n \telif optparse -m=; then\n \t\tmsgs[${#msgs[@]}]=\"$OPTARG\"\n+\telif optparse -c=; then\n+\t    use_commit=\"$OPTARG\"\n \telse\n \t\toptfail\n \tfi\n@@ -196,6 +207,39 @@ for msg in \"${msgs[@]}\"; do\n \techo \"$msg\" | fmt -s >>$LOGMSG\n \twritten=1\n done\n+\n+if [ \"$use_commit\" ]; then\n+\tpick_author_script='\n+\t\t/^author /{\n+\t\t\th\n+\t\t\ts/^author \\([^<]*\\) <[^>]*> .*$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_NAME='\\''&'\\''/p\n+\n+\t\t\tg\n+\t\t\ts/^author [^<]* <\\([^>]*\\)> .*$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_EMAIL='\\''&'\\''/p\n+\n+\t\t\tg\n+\t\t\ts/^author [^<]* <[^>]*> \\(.*\\)$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_DATE='\\''&'\\''/p\n+\n+\t\t\tq\n+\t\t}\n+\t\t'\n+\tset_author_env=`git-cat-file commit \"$use_commit\" |\n+\tsed -ne \"$pick_author_script\"`\n+\teval \"$set_author_env\"\n+\texport GIT_AUTHOR_NAME\n+\texport GIT_AUTHOR_EMAIL\n+\texport GIT_AUTHOR_DATE\n+\tgit-cat-file commit \"$use_commit\" |\n+\tsed -e '1,/^$/d'\n+        written=1\n+fi >> $LOGMSG\n+\n # Always have at least one blank line, to ease the editing for\n # the poor people whose text editor has no 'O' command.\n [ \"$written\" ] || echo >>$LOGMSG\n@@ -239,7 +283,7 @@ echo \"CG: vim: textwidth=75\" >>$LOGMSG\n \n cp $LOGMSG $LOGMSG2\n if tty -s; then\n-\tif ! [ \"$msgs\" ] || [ \"$forceeditor\" ]; then\n+\tif ! ([ \"$use_commit\" ] || [ \"$msgs\" ]) || [ \"$forceeditor\" ]; then\n \t\t${EDITOR:-vi} $LOGMSG2\n \t\tif ! [ \"$commitalways\" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then\n \t\t\techo \"Log message unchanged or not specified\" >&2\n\n\n\n\n[PATCH] Add -c parameter to cg-commit to set commit data based on prior commit.\n\nThis will then commit any changes using the author and message from the commit\nspecified.  The actual logic for parsing the old commit values was taken from\ngit-commit-script.\n\ngit-commit-script supports this option via -C, which was already used in cg-commit\nfor something else.\n\nSigned-off-by: James Ketrenos <jketreno@linux.intel.com>\n---\n\n cg-commit |   46 +++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 45 insertions(+), 1 deletions(-)\n\nb07037397659763271e946fc15c0b3c61a8fcdfa\ndiff --git a/cg-commit b/cg-commit\n--- a/cg-commit\n+++ b/cg-commit\n@@ -3,6 +3,8 @@\n # Commit into a GIT repository.\n # Copyright (c) Petr Baudis, 2005\n # Based on an example script fragment sent to LKML by Linus Torvalds.\n+# \n+# -c commit based on code in git-commit-script by Linus Torvalds\n #\n # Commits changes to a GIT repository. Accepts the commit message from\n # `stdin`. If the commit message is not modified the commit will be\n@@ -45,6 +47,12 @@\n #\tmight not actually _have_ any object database. This option is\n #\tnormally not interesting.\n #\n+# -c::\n+#\tSpecifify the commit SHA to inherit the GIT_AUTHOR_* variables and\n+#\tcommit message from.  The GIT_COMMITTER_* variables will not be\n+#\tinherited from the specified commit.  This option is typically used\n+#\twhen replaying commits from one lineage or repository to another.\n+#\t\n # FILES\n # -----\n # $GIT_DIR/author::\n@@ -112,6 +120,7 @@ ignorecache=\n infoonly=\n commitalways=\n missingok=\n+use_commit=\n msgs=()\n while optparse; do\n \tif optparse -C; then\n@@ -128,6 +137,8 @@ while optparse; do\n \t\tforce=1\n \telif optparse -m=; then\n \t\tmsgs[${#msgs[@]}]=\"$OPTARG\"\n+\telif optparse -c=; then\n+\t    use_commit=\"$OPTARG\"\n \telse\n \t\toptfail\n \tfi\n@@ -196,6 +207,39 @@ for msg in \"${msgs[@]}\"; do\n \techo \"$msg\" | fmt -s >>$LOGMSG\n \twritten=1\n done\n+\n+if [ \"$use_commit\" ]; then\n+\tpick_author_script='\n+\t\t/^author /{\n+\t\t\th\n+\t\t\ts/^author \\([^<]*\\) <[^>]*> .*$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_NAME='\\''&'\\''/p\n+\n+\t\t\tg\n+\t\t\ts/^author [^<]* <\\([^>]*\\)> .*$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_EMAIL='\\''&'\\''/p\n+\n+\t\t\tg\n+\t\t\ts/^author [^<]* <[^>]*> \\(.*\\)$/\\1/\n+\t\t\ts/'\\''/'\\''\\'\\'\\''/g\n+\t\t\ts/.*/GIT_AUTHOR_DATE='\\''&'\\''/p\n+\n+\t\t\tq\n+\t\t}\n+\t\t'\n+\tset_author_env=`git-cat-file commit \"$use_commit\" |\n+\tsed -ne \"$pick_author_script\"`\n+\teval \"$set_author_env\"\n+\texport GIT_AUTHOR_NAME\n+\texport GIT_AUTHOR_EMAIL\n+\texport GIT_AUTHOR_DATE\n+\tgit-cat-file commit \"$use_commit\" |\n+\tsed -e '1,/^$/d'\n+        written=1\n+fi >> $LOGMSG\n+\n # Always have at least one blank line, to ease the editing for\n # the poor people whose text editor has no 'O' command.\n [ \"$written\" ] || echo >>$LOGMSG\n@@ -239,7 +283,7 @@ echo \"CG: vim: textwidth=75\" >>$LOGMSG\n \n cp $LOGMSG $LOGMSG2\n if tty -s; then\n-\tif ! [ \"$msgs\" ] || [ \"$forceeditor\" ]; then\n+\tif ! ([ \"$use_commit\" ] || [ \"$msgs\" ]) || [ \"$forceeditor\" ]; then\n \t\t${EDITOR:-vi} $LOGMSG2\n \t\tif ! [ \"$commitalways\" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then\n \t\t\techo \"Log message unchanged or not specified\" >&2\n"}]}