зеркало из https://github.com/microsoft/git.git
Merge branch 'ns/am-slacker'
* ns/am-slacker: git-am: Add --ignore-date option am: Add --committer-date-is-author-date option Conflicts: git-am.sh
This commit is contained in:
Коммит
a4f004bffc
|
@ -10,7 +10,8 @@ SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
|
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
|
||||||
[--3way] [--interactive]
|
[--3way] [--interactive] [--committer-date-is-author-date]
|
||||||
|
[--ignore-date]
|
||||||
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
|
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
|
||||||
[--reject]
|
[--reject]
|
||||||
[<mbox> | <Maildir>...]
|
[<mbox> | <Maildir>...]
|
||||||
|
@ -73,6 +74,20 @@ default. You could use `--no-utf8` to override this.
|
||||||
--interactive::
|
--interactive::
|
||||||
Run interactively.
|
Run interactively.
|
||||||
|
|
||||||
|
--committer-date-is-author-date::
|
||||||
|
By default the command records the date from the e-mail
|
||||||
|
message as the commit author date, and uses the time of
|
||||||
|
commit creation as the committer date. This allows the
|
||||||
|
user to lie about the committer date by using the same
|
||||||
|
timestamp as the author date.
|
||||||
|
|
||||||
|
--ignore-date::
|
||||||
|
By default the command records the date from the e-mail
|
||||||
|
message as the commit author date, and uses the time of
|
||||||
|
commit creation as the committer date. This allows the
|
||||||
|
user to lie about author timestamp by using the same
|
||||||
|
timestamp as the committer date.
|
||||||
|
|
||||||
--skip::
|
--skip::
|
||||||
Skip the current patch. This is only meaningful when
|
Skip the current patch. This is only meaningful when
|
||||||
restarting an aborted patch.
|
restarting an aborted patch.
|
||||||
|
|
21
git-am.sh
21
git-am.sh
|
@ -23,6 +23,8 @@ 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
|
||||||
|
ignore-date use current timestamp for author date
|
||||||
rebasing* (internal use for git-rebase)"
|
rebasing* (internal use for git-rebase)"
|
||||||
|
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
|
@ -133,6 +135,8 @@ 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=
|
||||||
|
ignore_date=
|
||||||
|
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
|
@ -170,6 +174,10 @@ 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 ;;
|
||||||
|
--ignore-date)
|
||||||
|
ignore_date=t ;;
|
||||||
--)
|
--)
|
||||||
shift; break ;;
|
shift; break ;;
|
||||||
*)
|
*)
|
||||||
|
@ -520,7 +528,18 @@ 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 "$ignore_date"
|
||||||
|
then
|
||||||
|
GIT_AUTHOR_DATE=
|
||||||
|
fi
|
||||||
|
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,37 @@ 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"
|
||||||
|
'
|
||||||
|
|
||||||
|
# This checks for +0000 because TZ is set to UTC and that should
|
||||||
|
# show up when the current time is used. The date in message is set
|
||||||
|
# by test_tick that uses -0700 timezone; if this feature does not
|
||||||
|
# work, we will see that instead of +0000.
|
||||||
|
test_expect_success 'am --ignore-date' '
|
||||||
|
git checkout first &&
|
||||||
|
test_tick &&
|
||||||
|
git am --ignore-date patch1 &&
|
||||||
|
git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
|
||||||
|
at=$(sed -ne "/^author /s/.*> //p" head1) &&
|
||||||
|
echo "$at" | grep "+0000"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче