Commit graph

244 commits

Author SHA1 Message Date
Ævar Arnfjörð Bjarmason 865207a6dd i18n: git-am "Falling back" say message
Make the "Falling back to patching base and 3-way merge..." message
used by fall_back_3way() translatable.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason 7a74d04a46 i18n: git-am "Apply?" message
Make the "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all" message
translatable, and leave a note in a TRANSLATORS comment explaining
that translators have to preserve a mention of the y/n/e/v/a
characters since the program will expect them, and not their
localized equivalents.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason d62a1461c3 i18n: git-am clean_abort messages
Messages that used the clean_abort function needed both gettext(1) and
eval_gettext(). These need to be interpolated in a string like the die
and cannot_fallback messages.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason a424ca157f i18n: git-am cannot_fallback messages
Translate messages with gettext(1) before they're passed to the
cannot_fallback function, just like we handle the die function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason 790872592e i18n: git-am die messages
The die messages in git-am need to use:

    die "$(gettext "string")"

Since gettext(1) emits the message instead of returning it like the C
equivalent, and our die() function in git-sh-setup needs to get a
string as an argument.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason 22fdd11432 i18n: git-am gettext + gettext to stderr message
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:14 -07:00
Ævar Arnfjörð Bjarmason a4372c373b i18n: git-am eval_gettext messages
Messages that use variables to be interpolated need to use
eval_gettext(), this wrapper will eval the message and expand the
variable for us.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:13 -07:00
Ævar Arnfjörð Bjarmason bd8643ae51 i18n: git-am multi-line getttext $msg; echo
When we have multi-line `gettext $msg; echo' messages we can't
preserve the existing indenting because gettext(1) can't accept input
on stdin.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:13 -07:00
Ævar Arnfjörð Bjarmason 81dd2fe542 i18n: git-am one-line gettext $msg; echo
One-line `gettext $msg; echo' messages are the simplest use case for
gettext(1).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:13 -07:00
Ævar Arnfjörð Bjarmason b9a972691e i18n: git-am add git-sh-i18n
Source git-sh-i18n in git-am.sh, it's needed to import the Git gettext
shell functions.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-21 11:57:13 -07:00
Junio C Hamano 5765870d53 Merge branch 'jc/maint-rebase-rewrite-last-skip'
* jc/maint-rebase-rewrite-last-skip:
  rebase --skip: correctly wrap-up when skipping the last patch
2010-12-28 11:26:59 -08:00
Junio C Hamano ef88ad2387 rebase --skip: correctly wrap-up when skipping the last patch
When "rebase --skip" is used to skip the last patch in the series, the
code to wrap up the rewrite by copying the notes from old to new commits
and also by running the post-rewrite hook was bypassed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-22 16:50:28 -08:00
Junio C Hamano cfa775c10e Merge branch 'jc/maint-am-abort-safely'
* jc/maint-am-abort-safely:
  am --abort: keep unrelated commits since the last failure and warn
2010-12-22 14:41:19 -08:00
Junio C Hamano 7b3b7e3758 am --abort: keep unrelated commits since the last failure and warn
After making commits (either by pulling or doing their own work) after a
failed "am", the user will be reminded by next "am" invocation that there
was a failed "am" that the user needs to decide to resolve or to get rid
of the old "am" attempt.  The "am --abort" option was meant to help the
latter.  However, it rewinded the HEAD back to the beginning of the failed
"am" attempt, discarding commits made (perhaps by mistake) since.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-21 11:16:28 -08:00
Junio C Hamano d4c4369752 Sync with 1.7.3.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-21 17:16:10 -07:00
Junio C Hamano f7bff60de9 Merge branch 'sn/doc-opt-notation' into maint
* sn/doc-opt-notation:
  Fix {update,checkout}-index usage strings
  Put a space between `<' and argument in pack-objects usage string
  Remove stray quotes in --pretty and --format documentation
  Use parentheses and `...' where appropriate
  Fix odd markup in --diff-filter documentation
  Use angles for placeholders consistently
2010-10-21 16:26:42 -07:00
Junio C Hamano 38a18873b2 Merge branch 'maint'
* maint:
  Better advice on using topic branches for kernel development
  Documentation: update implicit "--no-index" behavior in "git diff"
  Documentation: expand 'git diff' SEE ALSO section
  Documentation: diff can compare blobs
  Documentation: gitrevisions is in section 7
  shell portability: no "export VAR=VAL"
  CodingGuidelines: reword parameter expansion section
  Documentation: update-index: -z applies also to --index-info
  Documentation: No argument of ALLOC_GROW should have side-effects
2010-10-13 20:20:09 -07:00
Junio C Hamano 69ae92bda1 shell portability: no "export VAR=VAL"
It is more portable to say "VAR=VAL && export VAR" instead.

Noticed by Ævar.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-13 11:36:36 -07:00
Štěpán Němec 0adda9362a Use parentheses and `...' where appropriate
Remove some stray usage of other bracket types and asterisks for the
same purpose.

Signed-off-by: Štěpán Němec <stepnem@gmail.com>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-08 12:31:07 -07:00
Pat Thoyts 5e9677cbdf git-am: fix detection of absolute paths for windows
Add an is_absolute_path function to abstract out platform differences
in checking for an absolute or relative path.
Specifically fixes t4150-am on Windows.

[PT: updated following suggestion from j6t to support \* and //*]

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2010-10-03 23:31:59 +01:00
Junio C Hamano bcdfb20ae9 Merge branch 'js/maint-am-rebase-invalid-author'
* js/maint-am-rebase-invalid-author:
  am: use get_author_ident_from_commit instead of mailinfo when rebasing
2010-06-27 12:07:44 -07:00
Junio C Hamano 8b8063cef3 Merge branch 'rr/am-help'
* rr/am-help:
  git am: Remove stray error message from sed
  git am: Display some help text when patch is empty
  git am: Set cmdline globally
2010-06-18 11:16:56 -07:00
Jay Soffian 43c23251f9 am: use get_author_ident_from_commit instead of mailinfo when rebasing
In certain situations, commit authorship can consist of an invalid
e-mail address. For example, this is the case when working with git svn
repos where the author email has had the svn repo UUID appended such as:

 author@example.com <author@example.com@deadbeef-dead-beef-dead-beefdeadbeef>

Given such an address, mailinfo extracts the authorship incorrectly as
it assumes a valid domain. However, when rebasing the original
authorship should be preserved irrespective of its validity as an email
address.

Using get_author_ident_from_commit instead of mailinfo when rebasing
preserves the original authorship.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-16 10:00:58 -07:00
Ramkumar Ramachandra 92f65e6ab6 git am: Remove stray error message from sed
When --continue is invoked without any changes, the following stray
error message appears- sed: can't read $dotest/final-commit: No such
file or directory. Remove this by making sure that the file actually
exists.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-02 09:53:45 -07:00
Ramkumar Ramachandra dc267b1ab4 git am: Display some help text when patch is empty
When a patch is found to be empty, prompt the user to use either
--skip or --abort.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-02 09:51:48 -07:00
Ramkumar Ramachandra d2c4631061 git am: Set cmdline globally
Set the $cmdline variable globally, and not in stop_here_user_resolve
so it can be used in other code fragments as well.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-02 09:51:39 -07:00
Jan Krüger 05bdcfe5fc git-am: suggest what to do with superfluous patches
Particularly in the context of rebase, conflicts frequently occur
because the change in the patch to be applied was made obsolete by new
upstream commits. In this case, solving the conflict effectively means
skipping the patch. However, it's not always readily apparent that the
patch needs to be skipped, and when people solve the conflict and try
git rebase --continue, they get confronted with a message of

  No changes - did you forget to use 'git add'?

That's not very helpful if you did actually stage your changes and they
happen to turn the patch into a no-op. This extends the message to point
out what's going on.

Signed-off-by: Jan Krüger <jk@jk.gs>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-31 17:48:38 -07:00
Junio C Hamano edea184a58 Merge branch 'jc/am-3-show-corrupted-patch'
* jc/am-3-show-corrupted-patch:
  am -3: recover the diagnostic messages for corrupt patches
2010-05-21 04:02:18 -07:00
Junio C Hamano 0ba17dd022 am -3: recover the diagnostic messages for corrupt patches
"git am -3" first tries to apply the patch without any extra trick, and
applies it to a synthesized tree for 3-way merge after the first attempt
fails.  "git apply" exits with status 1 for a patch that is well-formed
but is not applicable (and it dies on other errors with non-zereo, non-1
status) and has an optimization to fall back to the 3-way merge only in
the case.

An earlier patch 3ddd170 (am: suppress apply errors when using 3-way,
2009-06-16) squelched diagnostic messages from the first attempt, not to
be shown to the end user.  This worked reasonably well if the reason the
first application failed was because the patch was made against a wrong
version.

When the patch is corrupt (e.g. line-wrapped or leading whitespaces got
dropped), however, because the second patch application is not even
attempted, the error message from the first application is never shown
and is forever lost.  This message is necessary to locate where the patch
is corrupt and fix it up.

We could fix this issue by reverting 3dd170, or keeping the error message
to somewhere and showing it, but because this is an error codepath, the
easiest is to disable the optimization.  The second patch application is
attempted even when the input is corrupt, and it will notice, diagnose,
and stop with an error message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-14 11:20:27 -07:00
Junio C Hamano a86ed83cce Merge branch 'tr/notes-display'
* tr/notes-display:
  git-notes(1): add a section about the meaning of history
  notes: track whether notes_trees were changed at all
  notes: add shorthand --ref to override GIT_NOTES_REF
  commit --amend: copy notes to the new commit
  rebase: support automatic notes copying
  notes: implement helpers needed for note copying during rewrite
  notes: implement 'git notes copy --stdin'
  rebase -i: invoke post-rewrite hook
  rebase: invoke post-rewrite hook
  commit --amend: invoke post-rewrite hook
  Documentation: document post-rewrite hook
  Support showing notes from more than one notes tree
  test-lib: unset GIT_NOTES_REF to stop it from influencing tests

Conflicts:
	git-am.sh
	refs.c
2010-03-24 16:26:43 -07:00
Thomas Rast eb2151bb89 rebase: support automatic notes copying
Luckily, all the support already happens to be there.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-12 21:55:40 -08:00
Thomas Rast 96e19488f1 rebase: invoke post-rewrite hook
We have to deal with two separate code paths: a normal rebase, which
actually goes through git-am; and rebase {-m|-s}.

The only small issue with both is that they need to remember the
original sha1 across a possible conflict resolution.  rebase -m
already puts this information in $dotest/current, and we just
introduce a similar file for git-am.

Note that in git-am, the hook really only runs when coming from
git-rebase: the code path that sets the $dotest/original-commit file
is guarded by a test for $dotest/rebasing.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-12 21:55:39 -08:00
Junio C Hamano c505a85015 Merge branch 'sh/am-keep-cr'
* sh/am-keep-cr:
  git-am: Add tests for `--keep-cr`, `--no-keep-cr` and `am.keepcr`
  git-am: Add am.keepcr and --no-keep-cr to override it
  git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit
  documentation: 'git-mailsplit --keep-cr' is not hidden anymore
2010-03-10 15:32:34 -08:00
Junio C Hamano 52ebb06f14 Merge branch 'jn/maint-fix-pager'
* jn/maint-fix-pager:
  tests: Fix race condition in t7006-pager
  t7006-pager: if stdout is not a terminal, make a new one
  tests: Add tests for automatic use of pager
  am: Fix launching of pager
  git svn: Fix launching of pager
  git.1: Clarify the behavior of the --paginate option
  Make 'git var GIT_PAGER' always print the configured pager
  Fix 'git var' usage synopsis
2010-03-02 12:44:11 -08:00
Stefan-W. Hahn e80d4cbefc git-am: Add am.keepcr and --no-keep-cr to override it
This patch adds the configuration `am.keepcr` for git-am. It also adds
`--no-keep-cr` parameter for git-am to give the possibility to
override configuration from command line.

Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-28 11:07:49 -08:00
Stefan-W. Hahn ad2c928001 git-am: Add command line parameter --keep-cr passing it to git-mailsplit
c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF
line-endings, 2009-08-04) fixed "git mailsplit" to help people with
MUA whose output from save-as command uses CRLF as line terminators by
stripping CR at the end of lines.

However, when you know you are feeding output from "git format-patch"
directly to "git am", and especially when your contents have CR at the
end of line, such stripping is undesirable.  To help such a use case,
teach --keep-cr option to "git am" and pass that to "git mailinfo".

Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-28 11:06:10 -08:00
Jonathan Nieder 29b67543d3 am: remove rebase-apply directory before gc
When git am does an automatic gc it doesn't clean up the rebase-apply
directory until after this has finished.  This means that if the user
aborts the gc then future am or rebase operations will report that an
existing operation is in progress, which is undesirable and confusing.

Reported by Mark Brown <broonie@debian.org> through
http://bugs.debian.org/570966

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-23 14:26:29 -08:00
Jonathan Nieder f6dff119d5 am: Fix launching of pager
The pagination functionality in git am has some problems:

 - It does not check if stdout is a tty, so it always paginates.

 - If $GIT_PAGER uses any environment variables, they are being
   ignored, since it does not run $GIT_PAGER through eval.

 - If $GIT_PAGER is set to the empty string, instead of passing
   output through to stdout, it tries to run $dotest/patch.

Fix them.  While at it, move the definition of git_pager() to
git-sh-setup so authors of other commands are not tempted to
reimplement it with the same mistakes.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-14 22:05:17 -08:00
Jeff King c8089af6c6 am: switch --resolved to --continue
Rebase calls this same function "--continue", which means
users may be trained to type it. There is no reason to
deprecate --resolved (or -r), so we will keep it as a
synonym.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-11 22:10:00 -08:00
Stephen Boyd e3f67d30b2 am: fix patch format detection for Thunderbird "Save As" emails
The patch detection wants to inspect all the headers of a rfc2822 message
and ensure that they look like header fields. The headers are always
separated from the message body with a blank line. When Thunderbird saves
the message the blank line separating the headers from the body includes a
CR. The patch detection is failing because a CRLF doesn't match /^$/. Fix
this by allowing a CR to exist on the separating line.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-25 16:43:36 -08:00
Junio C Hamano cb6020bb01 Teach --[no-]rerere-autoupdate option to merge, revert and friends
Introduce a command line option to override rerere.autoupdate configuration
variable to make it more useful.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-04 00:20:48 -08:00
Junio C Hamano 5e2f779cbf Merge branch 'jc/maint-am-keep' 2009-11-30 14:35:07 -08:00
Junio C Hamano c970a6fd01 Remove dead code from "git am"
Ever since the initial implementation, "git am" had kept a dead code that
never triggered due to a typo in the variable name.  Worse yet, the code,
if it weren't for the typo, would have attempted to add "[PATCH] " at the
beginning of the Subject: header when "git am" is run with its "-k"
option.  However, because "git am -k" tells mailinfo to keep such prefix
when parsing the input, the "[PATCH] " added by this dead code would have
really been unnecessary duplicate.

Embarrassing is that we kept _maintaining_ the codepath without anybody
noticing for four years.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-27 15:11:47 -08:00
Junio C Hamano ad7ace714d Merge branch 'rs/work-around-grep-opt-insanity'
* rs/work-around-grep-opt-insanity:
  Protect scripted Porcelains from GREP_OPTIONS insanity
  mergetool--lib: simplify guess_merge_tool()

Conflicts:
	git-instaweb.sh
2009-11-25 11:45:07 -08:00
Junio C Hamano e1622bfcba Protect scripted Porcelains from GREP_OPTIONS insanity
If the user has exported the GREP_OPTIONS environment variable, the output
from "grep" and "egrep" in scripted Porcelains may be different from what
they expect.  For example, we may want to count number of matching lines,
by "grep" piped to "wc -l", and GREP_OPTIONS=-C3 will break such use.

The approach taken by this change to address this issue is to protect only
our own use of grep/egrep.  Because we do not unset it at the beginning of
our scripts, hook scripts run from the scripted Porcelains are exposed to
the same insanity this environment variable causes when grep/egrep is used
to implement logic (e.g. "grep | wc -l"), and it is entirely up to the
hook scripts to protect themselves.

On the other hand, applypatch-msg hook may want to show offending words in
the proposed commit log message using grep to the end user, and the user
might want to set GREP_OPTIONS=--color to paint the match more visibly.
The approach to protect only our own use without unsetting the environment
variable globally will allow this use case.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-23 16:31:07 -08:00
Junio C Hamano 6d975c24a9 Merge branch 'ls/maint-mailinfo-no-inbody'
* ls/maint-mailinfo-no-inbody:
  git am/mailinfo: Don't look at in-body headers when rebasing
2009-11-22 16:40:26 -08:00
Lukas Sandström d25e51596b git am/mailinfo: Don't look at in-body headers when rebasing
When we are rebasing we know that the header lines in the
patch are good and that we don't need to pick up any headers
from the body of the patch.

This makes it possible to rebase commits whose commit message
start with "From" or "Date".

Test vectors by Jeff King.

Signed-off-by: Lukas Sandström <luksan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-20 23:14:02 -08:00
Jonathan Nieder dec543e62d am -i, git-svn: use "git var GIT_PAGER"
Use the new "git var GIT_PAGER" command to ask what pager to use.

Without this change, the core.pager configuration is ignored by
these commands.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-13 12:20:52 -08:00
Christian Himpel fa9d3485ea git-am: force egrep to use correct characters set
According to egrep(1) the US-ASCII table is used when LC_ALL=C is set.
We do not rely here on the LC_ALL value we get from the environment.

Signed-off-by: Christian Himpel <chressie@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2009-09-25 15:35:05 -07:00
Christian Himpel 6900d750f4 git-am: fixed patch_format detection according to RFC2822
RFC2822 specifies in paragraph 3.6.8, that optional header fields are
made up of any printable US-ASCII character except ' ' (space) and ':'
(colon).

The pattern for the egrep command is changed to match all of these
characters.

Signed-off-by: Christian Himpel <chressie@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2009-09-25 15:35:05 -07:00
Junio C Hamano 017678b4f4 am/mailinfo: Disable scissors processing by default
You can enable it by giving --scissors to "git am".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 22:22:22 -07:00
Junio C Hamano 5e092b5bce Merge branch 'gb/apply-ignore-whitespace'
* gb/apply-ignore-whitespace:
  git apply: option to ignore whitespace differences
2009-08-21 18:47:48 -07:00
Junio C Hamano bcd45e27d8 Merge branch 'bc/mailsplit-cr-at-eol'
* bc/mailsplit-cr-at-eol:
  Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings
  builtin-mailsplit.c: remove read_line_with_nul() since it is no longer used
  builtin-mailinfo,builtin-mailsplit: use strbufs
  strbuf: add new function strbuf_getwholeline()
2009-08-21 18:47:44 -07:00
Nicolas Sebrecht 46caf5053f git-am: print fair error message when format detection fails
Avoid git ending with this message:
	"Patch format  is not supported."

With improved error message in the format detection failure case by
Giuseppe Bilotta.

Signed-off-by: Nicolas Sebrecht <ni.s@laposte.net>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-06 20:52:09 -07:00
Junio C Hamano 0fcb2caf29 am: allow individual e-mail files as input
We traditionally allowed a mbox file or a directory name of a maildir (but
never an individual file inside a maildir) to be given to "git am".  Even
though an individual file in a maildir (or more generally, a piece of
RFC2822 e-mail) is not a mbox file, it contains enough information to
create a commit out of it, so there is no reason to reject one.  Running
mailsplit on such a file feels stupid, but it does not hurt.

This builds on top of a5a6755 (git-am foreign patch support: introduce
patch_format, 2009-05-27) that introduced mailbox format detection.  The
codepath to deal with a mbox requires it to begin with "From " line and
also allows it to begin with "From: ", but a random piece of e-mail can
and often do begin with any valid RFC2822 header lines.

Instead of checking the first line, we extract all the lines up to the
first empty line, and make sure they look like e-mail headers.

A test is added to t4150 to demonstrate this feature.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-06 20:50:15 -07:00
Junio C Hamano c2ca1d79db Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings
It is not that uncommon to have mails with DOS line-ending, notably
Thunderbird and web mailers like Gmail (when saving what they call
"original" message).  So modify mailsplit to convert CRLF line-endings to
just LF.

Since git-rebase is built on top of git-am, add an option to mailsplit to
be used by git-am when it is acting on behalf of git-rebase, to refrain
from doing this conversion.

And add a test to make sure that rebase still works.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-05 12:14:00 -07:00
Giuseppe Bilotta 86c91f9179 git apply: option to ignore whitespace differences
Introduce --ignore-whitespace option and corresponding config bool to
ignore whitespace differences while applying patches, akin to the
'patch' program.

'git am', 'git rebase' and the bash git completion are made aware of
this option.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-05 11:59:56 -07:00
Junio C Hamano 7557b34310 Merge branch 'gb/am-foreign'
* gb/am-foreign:
  git-am: refactor 'cleaning up and aborting'
  git-am foreign patch support: StGIT support
  git-am foreign patch support: autodetect some patch formats
  git-am foreign patch support: introduce patch_format
2009-07-06 09:38:33 -07:00
Stephen Boyd 0e987a12fc am, rebase: teach quiet option
git-am and git-rebase are talkative scripts. Teach them to be quiet when
told, allowing them to speak only when they fail or experience errors.

The quiet option is maintained when git-am or git-rebase fails to apply
a patch. This means subsequent --resolved, --continue, --skip, --abort
invocations will be quiet if the original invocation was quiet.

Drop a handful of >&2 redirection; the rest of the program sends all the
info messages to stdout, not to stderr.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-18 11:54:48 -07:00
Stephen Boyd 3ddd170323 am: suppress apply errors when using 3-way
git-am with 3-way outputs errors when applying, even though the
3-way will usually be successful. We suppress these errors from
git-apply because they are not "true" errors until the 3-way has been
attempted.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-18 09:50:25 -07:00
Giuseppe Bilotta 0cd29a0371 git-am: refactor 'cleaning up and aborting'
Introduce a clean_abort function that echoes an optional error message
to standard error, removes the dotest directory and exits with status 1.

Use it when patch format detection or patch splitting fails early.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-13 17:30:38 -07:00
Giuseppe Bilotta c574e683b5 git-am foreign patch support: StGIT support
Support StGIT patches by implementing a simple perl-based converter
mimicking StGIT's own parse_patch. Also support StGIT patch series by
'exploding' the index into a list of files and re-running the mail
splitting with patch_format set to stgit.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-28 23:07:43 -07:00
Giuseppe Bilotta 15ced753ac git-am foreign patch support: autodetect some patch formats
Default to mbox format if input is from stdin. Otherwise, look at the
first few lines of the first patch to try to guess its format.

Include checks for mailboxes, stgit patch series, stgit single patches
and hg patches.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-28 23:06:34 -07:00
Giuseppe Bilotta a5a6755a1d git-am foreign patch support: introduce patch_format
Set up a framework to allow git-am to support patches which are not in
mailbox format. Introduce a patch_format variable that presently can
only be set from the command line, defaulting to 'mbox' (the only
supported format) if not specified.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-28 23:04:50 -07:00
Christian Couder 47c9739e5e am: simplify "sq" function by using "git rev-parse --sq-quote"
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-10 00:30:29 -07:00
Ben Jackson ea10b60c91 Work around ash "alternate value" expansion bug
Ash (used as /bin/sh on many distros) has a shell expansion bug
for the form ${var:+word word}.  The result is a single argument
"word word".  Work around by using ${var:+word} ${var:+word} or
equivalent.

Signed-off-by: Ben Jackson <ben@ben.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-18 21:37:46 -07:00
Nanako Shiraishi f79d4c8a0f git-am: teach git-am to apply a patch to an unborn branch
People sometimes wonder why they cannot apply a patch that only
creates new files to an unborn branch.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-12 18:42:15 -07:00
Junio C Hamano 2d56a13643 git-am: make --abort less dangerous
When you are in the middle of "git rebase", "git am --abort" by mistake
would have referred to nonexistent ORIG_HEAD and barfed, or worse yet, used
a stale ORIG_HEAD and taken you to an unexpected commit.

Also the option parsing did not reject "git am --abort --skip".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-26 23:06:38 -08:00
Michael J Gruber c767184d8f git-am: Keep index in case of abort with dirty index
git am --abort resets the index unconditionally. But in case a previous
git am exited due to a dirty index it is preferable to keep that index.
Make it so.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-26 23:06:27 -08:00
Junio C Hamano a4f004bffc 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
2009-02-04 13:07:02 -08:00
Jay Soffian 98ef23b3b1 git-am: minor cleanups
Update usage statement to remove a no-longer supported option, and to hide two
options (one a no-op, one internal) unless --help-all is used.

Use "test -t 0" instead of "tty -s" to detect when stdin is a terminal. (test
-t 0 is used elsewhere in git-am and in other git shell scripts, tty -s is
not, and appears to be deprecated by POSIX)

Use "test ..." instead of "[ ... ]" and "die <msg>" instead of "echo <msg>
>&2; exit 1" to be consistent with rest of script.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-28 10:53:34 -08:00
Nanako Shiraishi a79ec62d06 git-am: Add --ignore-date option
This new option tells 'git-am' to ignore the date header field
recorded in the format-patch output. The commits will have the
timestamp when they are created instead.

You can work a lot in one day to accumulate many changes, but
apply and push to the public repository only some of them at
the end of the first day. Then next day you can spend all your
working hours reading comics or chatting with your coworkers,
and apply your remaining patches from the previous day using
this option to pretend that you have been working at the end
of the day.

Signed-off-by: しらいしななこ <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-25 18:56:13 -08:00
Junio C Hamano 3f01ad6654 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>
2009-01-25 18:55:49 -08:00
martin f. krafft b80da424a1 git-am: implement --reject option passed to git-apply
With --reject, git-am simply passes the --reject option to git-apply and thus
allows people to work with reject files if they so prefer.

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-23 17:00:12 -08:00
Junio C Hamano 07adc43f3a Merge branch 'jf/am-failure-report'
* jf/am-failure-report:
  git-am: re-fix the diag message printing
  git-am: Make it easier to see which patch failed
2009-01-21 16:51:18 -08:00
Junio C Hamano 4d2e283a1e git-am: re-fix the diag message printing
The $FIRSTLINE variable is from the user's commit and can contain
arbitrary backslash escapes that may be (mis)interpreted when given to
"echo", depending on the implementation.  Use "printf" to work around the
issue.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-18 19:34:31 -08:00
Jonas Flodén a70d4100d0 git-am: Make it easier to see which patch failed
When git-am fails it's not always easy to see which patch failed,
since it's often hidden by a lot of error messages.
Add an extra line which prints the name of the failed patch just
before the resolve message to make it easier to find.

Signed-off-by: Jonas Flodén <jonas@floden.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-17 21:43:33 -08:00
Junio C Hamano 17f26a9ee3 git-am: fix shell quoting
Noticed by Stephan Beyer; the new test is mine.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-14 16:29:59 -08:00
Junio C Hamano b47dfe9e9c git-am: add --directory=<dir> option
Thanks to a200337 (git-am: propagate -C<n>, -p<n> options as well,
2008-12-04) and commits around it, "git am" is equipped to correctly
propagate the command line flags such as -C/-p/-whitespace across a patch
failure and restart.

It is trivial to support --directory option now, resurrecting previous
attempts by Kevin and Simon.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-12 02:26:01 -08:00
Junio C Hamano 9b9f5a2258 git-am: rename apply_opt_extra file to apply-opt
All other state files use dash in their names, not underscores.
Also, there is no reason to call this "extra".  Drop it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-05 20:02:10 -08:00
Junio C Hamano 22db240dd1 git-am: propagate --3way options as well
The reasoning is the same as the previous patch, where we made -C<n>
and -p<n> propagate across a failure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-04 18:45:02 -08:00
Junio C Hamano a20033796b git-am: propagate -C<n>, -p<n> options as well
These options are meant to deal with patches that do not apply cleanly
due to the differences between the version the patch was based on and
the version "git am" is working on.

Because a series of patches applied in the same "git am" run tends to
come from the same source, it is more useful to propagate these options
after the application stops.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-04 18:45:01 -08:00
Junio C Hamano 1556ef1e37 git-am --whitespace: do not lose the command line option
When you start "git am --whitespace=fix" and the patch application process
is interrupted by an unapplicable patch early in the series, after
fixing the offending patch, the remainder of the patch should be processed
still with --whitespace=fix when restarted with "git am --resolved" (or
dropping the offending patch with "git am --skip").

The breakage was introduced by the commit 67dad68 (add -C[NUM] to git-am,
2007-02-08); this should fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-04 18:45:01 -08:00
Stephan Beyer cb3a160d60 git-am: ignore --binary option
The git-apply documentation says that --binary is a historical option.
This patch lets git-am ignore --binary and removes advertisements of this
option.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-16 02:32:36 -07:00
Todd Zullinger 5354a56fe7 Replace uses of "git-var" with "git var"
Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-30 11:42:01 -07:00
Stephan Beyer 09f8d055f9 git-am: Mention --abort in usage string part of OPTIONS_SPEC
The three separate lines for --skip, --resolved and --abort
are merged into one so that it is easy to see that they're
alternative and related options.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 17:10:20 -07:00
Stephan Beyer c8fe1980b2 git-am: Add colon before the subject that is printed out as being applied
git-am output can be confusing, because the subject of the applied
patch can look like the rest of a sentence starting with "Applying".
The added colon should make this clearer.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 12:31:37 -07:00
Olivier Marin 95f8ebbfc7 git am --skip: clean the index while preserving local changes
In 3-way merge, "am" will let the index with unmerged path waiting
for us to resolve conflicts and continue. But if we want to --skip
instead, "am" refuses to continue because of the dirty index.

With this patch, "am" will clean the index without touching files
locally modified, before continuing.

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-22 00:06:04 -07:00
Olivier Marin 75e1645fbe git-am: remove dash from help message
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 19:56:56 -07:00
Johannes Schindelin 51ef1daa4a Rename .git/rebase to .git/rebase-apply
With git-am, it sounds awkward to have the patches in ".git/rebase/",
but for technical reasons, we have to keep the same directory name
for git-am and git-rebase. ".git/rebase-apply" seems to be a good
compromise.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 18:51:47 -07:00
Junio C Hamano 245648dede Merge branch 'ns/am-abort'
* ns/am-abort:
  git am --abort
2008-07-20 18:00:13 -07:00
Nanako Shiraishi 3e5057a8b4 git am --abort
After failing to apply patches in the middle of a series, "git am --abort"
lets you go back to the original commit.

[jc: doc/help update from Olivier, and fixups for "am -3" squashed in]

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 15:26:28 -07:00
Junio C Hamano 588c038ac6 Merge branch 'sb/dashless'
* sb/dashless:
  Make usage strings dash-less
  t/: Use "test_must_fail git" instead of "! git"
  t/test-lib.sh: exit with small negagive int is ok with test_must_fail

Conflicts:
	builtin-blame.c
	builtin-mailinfo.c
	builtin-mailsplit.c
	builtin-shortlog.c
	git-am.sh
	t/t4150-am.sh
	t/t4200-rerere.sh
2008-07-16 17:22:50 -07:00
Johannes Schindelin 28ed6e7b32 Rename ".dotest/" to ".git/rebase" and ".dotest-merge" to "rebase-merge"
Since the files generated and used during a rebase are never to be
tracked, they should live in $GIT_DIR.  While at it, avoid the rather
meaningless term "dotest" to "rebase", and unhide ".dotest-merge".

This was wished for on the mailing list, but so far unimplemented.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-15 18:49:28 -07:00
Junio C Hamano 633ce9a3ba Merge branch 'jc/rebase-orig-head'
* jc/rebase-orig-head:
  Documentation: mention ORIG_HEAD in am, merge, and rebase
  Teach "am" and "rebase" to mark the original position with ORIG_HEAD
2008-07-14 23:45:49 -07:00
Stephan Beyer 356a32a23a git-am/git-mailsplit: correct synopsis for reading from stdin
Invoking git-am or git-mailsplit without mbox or Maildir results in
reading an mbox from stdin.  Mention this in the synopsis and usage
strings.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13 16:08:27 -07:00
Stephan Beyer 1b1dd23f2d Make usage strings dash-less
When you misuse a git command, you are shown the usage string.
But this is currently shown in the dashed form.  So if you just
copy what you see, it will not work, when the dashed form
is no longer supported.

This patch makes git commands show the dash-less version.

For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh
generates a dash-less usage string now.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13 14:12:48 -07:00
Stephan Beyer 460abee5cd git-am: Do not exit silently if committer is unset
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13 12:46:18 -07:00
Junio C Hamano 22e407951e Teach "am" and "rebase" to mark the original position with ORIG_HEAD
"merge" and "reset" leave the original point in history in ORIG_HEAD,
which makes it easy to go back to where you were before you inflict a
major damage to your history and realize that you do not like the result
at all.  These days with reflog, we technically do not need to use
ORIG_HEAD, but it is a handy way nevertheless.

This teaches "am" and "rebase" (all forms --- the vanilla one that uses
"am" as its backend, "-m" variant that cherry-picks, and "--interactive")
to do the same.

The original idea and a partial implementation to do this only for "rebase
-m" was by Brian Gernhardt; this extends on his idea.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-07 13:12:56 -07:00
Alejandro Mery 1d9b26562e git-am: head -1 is obsolete and doesn't work on some new systems
head -<n> was deprecated by POSIX, and as modern versions of coreutils
package don't support it at least one exports _POSIX2_VERSION=199209
it's fails on some systems.

head -n<n> is portable, but sed <n>q is even more.

Signed-off-by: Alejandro Mery <amery@geeks.cl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-17 16:40:09 -07:00