am: Add --committer-date-is-author-date option
This new option tells 'git-am' to use the timestamp recorded in the Email message as both author and committer date. Signed-off-by: しらいしななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5dc1308562
commit
3f01ad6654
13
git-am.sh
13
git-am.sh
@ -24,6 +24,7 @@ resolvemsg= override error message when patch failure occurs
|
|||||||
r,resolved to be used after a patch failure
|
r,resolved to be used after a patch failure
|
||||||
skip skip the current patch
|
skip skip the current patch
|
||||||
abort restore the original branch and abort the patching operation.
|
abort restore the original branch and abort the patching operation.
|
||||||
|
committer-date-is-author-date lie about committer date
|
||||||
rebasing (internal use for git-rebase)"
|
rebasing (internal use for git-rebase)"
|
||||||
|
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
@ -134,6 +135,7 @@ dotest="$GIT_DIR/rebase-apply"
|
|||||||
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
|
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
|
||||||
resolvemsg= resume=
|
resolvemsg= resume=
|
||||||
git_apply_opt=
|
git_apply_opt=
|
||||||
|
committer_date_is_author_date=
|
||||||
|
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
@ -171,6 +173,8 @@ do
|
|||||||
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
|
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
|
||||||
--reject)
|
--reject)
|
||||||
git_apply_opt="$git_apply_opt $1" ;;
|
git_apply_opt="$git_apply_opt $1" ;;
|
||||||
|
--committer-date-is-author-date)
|
||||||
|
committer_date_is_author_date=t ;;
|
||||||
--)
|
--)
|
||||||
shift; break ;;
|
shift; break ;;
|
||||||
*)
|
*)
|
||||||
@ -524,7 +528,14 @@ do
|
|||||||
|
|
||||||
tree=$(git write-tree) &&
|
tree=$(git write-tree) &&
|
||||||
parent=$(git rev-parse --verify HEAD) &&
|
parent=$(git rev-parse --verify HEAD) &&
|
||||||
commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
|
commit=$(
|
||||||
|
if test -n "$committer_date_is_author_date"
|
||||||
|
then
|
||||||
|
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
|
||||||
|
export GIT_COMMITTER_DATE
|
||||||
|
fi &&
|
||||||
|
git commit-tree $tree -p $parent <"$dotest/final-commit"
|
||||||
|
) &&
|
||||||
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
|
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
|
||||||
stop_here $this
|
stop_here $this
|
||||||
|
|
||||||
|
@ -257,4 +257,24 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
|
|||||||
test -z "$(git diff second)"
|
test -z "$(git diff second)"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'am --committer-date-is-author-date' '
|
||||||
|
git checkout first &&
|
||||||
|
test_tick &&
|
||||||
|
git am --committer-date-is-author-date patch1 &&
|
||||||
|
git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
|
||||||
|
at=$(sed -ne "/^author /s/.*> //p" head1) &&
|
||||||
|
ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
|
||||||
|
test "$at" = "$ct"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'am without --committer-date-is-author-date' '
|
||||||
|
git checkout first &&
|
||||||
|
test_tick &&
|
||||||
|
git am patch1 &&
|
||||||
|
git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
|
||||||
|
at=$(sed -ne "/^author /s/.*> //p" head1) &&
|
||||||
|
ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
|
||||||
|
test "$at" != "$ct"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user