Commit graph

84 commits

Author SHA1 Message Date
Jonathan Nieder 948065a483 test: am of empty patch should not succeed
The "git am empty" test uses the construct

	git am empty-file && false || :

which unconditionally returns true.  Use test_must_fail instead, which
also has the benefit of noticing if "git am" has segfaulted.

While at it, tighten the test to check that the diagnostic appears on
stderr and not stdout.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-14 16:17:12 -07:00
Jonathan Nieder b1f5b7839c test: use test_i18ncmp for "Patch format detection failed" message
v1.7.8.5~2 (am: don't infloop for an empty input file, 2012-02-25)
added a check for the human-readable message "Patch format detection
failed." but we forgot to suppress that check when running tests with
git configured to write output in another language.

Noticed by running tests with GETTEXT_POISON=YesPlease.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-14 16:17:08 -07:00
Junio C Hamano 250f0a074a Merge branch 'jc/am-3-nonstandard-popt'
* jc/am-3-nonstandard-popt:
  test: "am -3" can accept non-standard -p<num>
  am -3: allow nonstandard -p<num> option
2012-03-04 23:35:12 -08:00
Junio C Hamano a61ba26a47 test: "am -3" can accept non-standard -p<num>
This adds a test for the previous one to make sure that "am -3 -p0" can
read patches created with the --no-prefix option.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-26 23:02:59 -08:00
Junio C Hamano 8080906245 Merge branch 'maint'
* maint:
  Document accumulated fixes since 1.7.9.2
  Git 1.7.8.5
  grep -P: Fix matching ^ and $
  am: don't infloop for an empty input file
  rebase -m: only call "notes copy" when rewritten exists and is non-empty
  git-p4: remove bash-ism in t9800
  git-p4: remove bash-ism in t9809
  git-p4: fix submit regression with clientSpec and subdir clone
  git-p4: set useClientSpec variable on initial clone
  Makefile: add thread-utils.h to LIB_H

Conflicts:
	RelNotes
	t/t9809-git-p4-client-view.sh
2012-02-26 17:39:04 -08:00
Junio C Hamano 4d06691eec Sync with 1.7.8.5 2012-02-26 16:42:35 -08:00
Jim Meyering f0c5793b37 am: don't infloop for an empty input file
git-am.sh's check_patch_format function would attempt to preview
the patch to guess its format, but would go into an infinite loop
when the patch file happened to be empty.  The solution: exit the
loop when "read" fails, not when the line var, "$l1" becomes empty.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-26 16:32:54 -08:00
Junio C Hamano 6f5e880c68 Sync with maint
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-13 11:48:00 -08:00
Ævar Arnfjörð Bjarmason 1f5ad6b1a7 t: use sane_unset instead of unset
Change several tests to use the sane_unset function introduced in
v1.7.3.1-35-g00648ba instead of the built-in unset function.

This fixes a failure I was having on t9130-git-svn-authors-file.sh on
Solaris, and prevents several other issues from occurring.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-13 02:29:15 -08:00
Junio C Hamano bff64a9cda Merge branch 'tr/maint-mailinfo'
* tr/maint-mailinfo:
  mailinfo: with -b, keep space after [foo]
  am: learn passing -b to mailinfo

Conflicts:
	git-am.sh
2012-01-29 13:18:53 -08:00
Thomas Rast ee2d1cb402 mailinfo: with -b, keep space after [foo]
The logic for the -b mode, where [PATCH] is dropped but [foo] is not,
silently ate all spaces after the ].

Fix this by keeping the next isspace() character, if there is any.
Being more thorough is pointless, as the later cleanup_space() call
will normalize any sequence of whitespace to a single ' '.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-16 16:06:57 -08:00
Thomas Rast f7e5ea171b am: learn passing -b to mailinfo
git-am could pass -k to mailinfo, but not -b.  Introduce an option
that does so.  We change the meaning of the 'keep' state file, but are
careful not to cause a problem unless you downgrade in the middle of
an 'am' run.

This uncovers a bug in mailinfo -b, hence the failing test.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-16 16:04:52 -08:00
David Barr 0e8341f29d am: ignore leading whitespace before patch
Some web-based email clients prepend whitespace to raw message
transcripts to workaround content-sniffing in some browsers.  Adjust
the patch format detection logic to ignore leading whitespace.

So now you can apply patches from GMail with "git am" in three steps:

 1. choose "show original"
 2. tell the browser to "save as" (for example by pressing Ctrl+S)
 3. run "git am" on the saved file

This fixes a regression introduced by v1.6.4-rc0~15^2~2 (git-am
foreign patch support: autodetect some patch formats, 2009-05-27).
GMail support was first introduced to "git am" by v1.5.4-rc0~274^2
(Make mailsplit and mailinfo strip whitespace from the start of the
input, 2007-11-01).

Signed-off-by: David Barr <davidbarr@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-11 13:01:18 -07:00
Ævar Arnfjörð Bjarmason dff1a98350 i18n: git-am core say messages
Make the core git-am messages that use say() translatable. These are
visible on almost every git am invocation.

There are tests that depend on the "Applying" output that need to be
changed to use the test_i18* functions along with this translation.

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
Jonathan Nieder a48fcd8369 tests: add missing &&
Breaks in a test assertion's && chain can potentially hide
failures from earlier commands in the chain.

Commands intended to fail should be marked with !, test_must_fail, or
test_might_fail.  The examples in this patch do not require that.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-09 11:59:49 -08:00
Junio C Hamano 18cdf802ca Teach "apply --index-info" to handle rename patches
With v1.5.3.2~14 (apply --index-info: fall back to current index for
mode changes, 2007-09-17), git apply learned to stop worrying
about the lack of diff index line when a file already present in the
current index had no content change.

But it still worries too much: for rename patches, it is checking
that both the old and new filename are present in the current
index.  This makes no sense, since a file rename generally
involves creating a file there was none before.

So just check the old filename.

Noticed while trying to use “git rebase” with diff.renames = copies.

[jn: add tests]

Reported-by: David D. Kilzer <ddkilzer@kilzer.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-23 14:44:38 -07:00
Jonathan Nieder 5d27485944 t4150 (am): futureproof against failing tests
Most tests in t4150 begin by navigating to a sane state and
applying some patch:

	git checkout first &&
	git am patch1

If a previous test left behind unmerged files or a .git/rebase-apply
directory, they are untouched and the test fails, causing later tests
to fail, too.  This is not a problem in practice because none of the
tests leave a mess behind.

But as a futureproofing measure, it is still best to avoid the problem
and clean up at the start of each test.  In particular, this
simplifies the process of adding new tests that are known to fail.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-23 14:43:24 -07:00
Jonathan Nieder 800f11040d t4150 (am): style fix
Place setup commands in test_expect_success blocks.  This makes the
rare event of the setup commands breaking on some platform easier to
diagnose, and more importantly, it visually distinguishes where
each test begins and ends.

Instead of running test -z against the result of "git diff" command
substitution, use "git diff --exit-code", to improve output when
running with the "-v" option.

Use test_cmp in place of "test $(foo) = $(bar)" for similar reasons.

Remove whitespace after the > and < redirection operators for
consistency with other tests.

The order of arguments to test_cmp is "test_cmp expected actual".

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-23 14:42:36 -07:00
Stephen Boyd 9524cf2993 fix portability issues with $ in double quotes
Using a dollar sign in double quotes isn't portable. Escape them with
a backslash or replace the double quotes with single quotes.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-26 15:16:54 -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 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
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 b3c32ead20 t4150: test applying with a newline in subject
Commit 4b7cc26 (git-am: use printf instead of echo on user-supplied
strings, 2007-05-25) fixed a bug where subjects with newlines would
cause git-am to echo multiple lines when it says "Applying: <subject>".

This test ensures that fix stays valid.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-18 09:50:14 -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
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
Jeff King 87539416fd tests: grep portability fixes
We try to avoid using the "-q" or "-e" options, as they are
largely useless, as explained in aadbe44f.

There is one exception for "-e" here, which is in t7701 used
to produce an "or" of patterns. This can be rewritten as an
egrep pattern.

This patch also removes use of "grep -F" in favor of the
more widely available "fgrep".

[sp: Tested on AIX 5.3 by Mike Ralphson,
     Tested on MinGW by Johannes Sixt]

Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:39:58 -07:00
Nanako Shiraishi 3604e7c5c6 tests: use "git xyzzy" form (t3600 - t6999)
Converts tests between t3600-t6300.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-03 14:13:59 -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 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
Stephan Beyer d492b31caf t/: Use "test_must_fail git" instead of "! git"
This patch changes every occurrence of "! git" -- with the meaning
that a git call has to gracefully fail -- into "test_must_fail git".

This is useful to

 - make sure the test does not fail because of a signal,
   e.g. SIGSEGV, and

 - advertise the use of "test_must_fail" for new tests.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13 13:21:26 -07:00
Jeff King 3b2eb186bb fix whitespace violations in test scripts
These violations are simply wrong, but were never caught
because whitespace policy checking is turned off in the test
scripts.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-14 11:39:16 -07:00
Stephan Beyer 8ec00d0534 Merge t4150-am-subdir.sh and t4151-am.sh into t4150-am.sh
This patch moves the am test cases in t4150-am.sh and the
am subdirectory test cases from t/t4150-am-subdir.sh into
t/4151-am.sh.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-31 15:42:12 -07:00
Renamed from t/t4151-am.sh (Browse further)