We start the pager too early for several git commands, which results in
the errors sometimes going to the pager rather than show up as errors.
This is often hidden by the fact that we pass in '-X' to less by default,
which causes 'less' to exit for small output, but if you do
export LESS=-S
you can then clearly see the problem by doing
git log --prretty
which shows the error message ("fatal: unrecognized argument: --prretty")
being sent to the pager.
This happens for pretty much all git commands that use USE_PAGER, and then
check arguments separately. But "git diff" does it too early too (even
though it does an explicit setup_pager() call)
This only fixes it for the trivial "git log" family case.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit introduces tests that verify that rev-parse
parses master@{n} correctly for various values of n less
than, equal to and greater than the number of revisions
in the reference log.
In particular, these tests check that rev-parse exits with a
non-zero status code and prints a message of the
following form to stderr.
fatal: Log for [^ ]* only has [0-9][0-9]* entries.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit changes sha1_name.c to use warning instead of
fprintf(stderr).
Trailing newlines from message formats have been removed
since warning adds one itself.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
"The current behaviour of ref@{...} syntax parser is suboptimal:
$ git rev-parse --verify jch@{99999} && echo true
warning: Log for 'jch' only has 1368 entries.
cfb88e9a8d
true
It even knows that it is running off the cut-off point; it should just
cause the caller to notice that fact. I don't think changing it to error
out should cause any harm to existing callers."
With this change:
$ git rev-parse --verify jch@{99999} || echo false
fatal: Log for 'jch' only has 1368 entries.
false
$ git rev-parse jch@{99999} || echo false
fatal: Log for 'jch' only has 1368 entries.
false
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Here "takes no argument" means "does not take an argument". The
latter phrasing might make it clearer that PARSE_OPT_NOARG does not
make an option with an argument that can optionally be left off.
Noticed-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The time_notes script, which uses POSIX shell features, is
currently sometimes run with a non-POSIX /bin/sh.
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
A file named 'head' gets confused with the HEAD ref on
case-insensitive file systems. Replace '>head' with '>head.new' to
match the '>head.old' files they are compared to.
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Like $GIT_CONFIG, $GIT_CONFIG_PARAMETERS needs to be suppressed by
"git push" and its cousins when running local transport helpers to
imitate remote transport well.
Noticed-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Git uses the "-c foo=bar" parameters to set a config
variable for a single git invocation. We currently do this
by making a list in the current process and consulting that
list in git_config.
This works fine for built-ins, but the config changes are
silently ignored by subprocesses, including dashed externals
and invocations to "git config" from shell scripts.
This patch instead puts them in an environment variable
which we consult when looking at config (both internally and
via calls "git config").
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Older versions of AsciiDoc used to literally pass double dashes when we
used them in our linkgit macros and manpage titles, but newer ones (the
issue was first reported with AsciiDoc 8.5.2) turn them into em dashes.
Define litdd (literal double-dash) custom attribute in asciidoc.conf to
work this around. While we are at it, fix a few double-dashes (e.g. the
description of "project--devo--version" convention used by tla, among
other things) that used to be incorrectly written as em dashes in the body
text to also use this attribute.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Instead of using `cd dir && (...) && cd..` use `(cd dir && ...)`
This ensures that the test doesn't get caught in the subdirectory if
there is an error in the subshell.
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Currently, one could think that 'git bundle create' groks
any 'git rev-list' expression. But in fact it requires a named reference
to be present. Try and make this clearer.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Acked-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cleanup various spellings of the same argument, as well as the code
for the tilde: Since neither '~' nor '\~' work consistently, use
'{tilde}'.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Acked-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When people try insane things such as delta-compressing 4GiB files, they
get this assertion:
diff-delta.c:285: create_delta_index: Assertion `packed_entry - (struct index_entry *)mem == entries' failed.
This happens because:
1) the 'entries' variable is an unsigned int
2) it is assigned with entries = (bufsize - 1) / RABIN_WINDOW
(that itself is not a problem unless bufsize > 4G * RABIN_WINDOW)
3) the buffer is indexed from top to bottom starting at
"data = buffer + entries * RABIN_WINDOW" and the multiplication
here does indeed overflows, making the resulting top of the buffer
much lower than expected.
This makes the number of actually produced index entries smaller than
what was computed initially, hence the assertion.
Furthermore, the current delta encoding format cannot represent offsets
into a reference buffer with more than 32 bits anyway. So let's just
limit the number of entries to what the delta format can encode.
Reported-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Update the documentation to indicate that git stash branch only attempts
to drop the specified stash if it looks like stash reference.
Also changed the synopsis to more clearly indicate which commands require
a stash entry reference as opposed to merely a stash-like commit.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Adds new tests which check that:
* git stash branch handles a stash-like argument when there is a stash stack
* git stash branch handles a stash-like argument when there is not a stash stack
* git stash show handles a stash-like argument when there is a stash stack
* git stash show handles a stash-like argument when there is not a stash stack
* git stash drop fails early if the specified argument is not a stash reference
* git stash pop fails early if the specified argument is not a stash reference
* git stash * fails early if the reference supplied is bogus
* git stash fails early with stash@{n} where n >= length of stash log
Helped-by: Johannes Sixt
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit refactors git stash show to make use of the assert_stash_like function.
git show now dies if the presented argument is non-stash-like.
Previous behaviour was to tolerate commits that were not even stash-like.
Previously, git stash show would accept stash-like arguments, but
only if there was a stash on the stack.
Now, git stash accepts stash-like arguments always and only fails
if no stash-like argument is specified and there is no stash stack.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This patch teaches git stash branch to tolerate stash-like arguments.
In particular, a stash is only required if an argument isn't specified
and the stash is only dropped if a stash entry reference was
specified or implied.
The implementation has been simplified by taking advantage of
assert_stash_like() and the variables established by
parse_flags_and_rev().
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git stash pop is abstracted into its own implementation function - pop_stash.
The behaviour is changed so that git stash pop fails early if the
the specified stash reference does not exist or does not refer to
an extant entry in the reflog of the reference stash.
This fixes the case where the apply succeeds, but the drop fails.
Previously this caused caused git stash pop to exit with a non-zero exit code
and a dirty tree.
Now, git stash pop fails with a non-zero exit code, but the working
tree is not modified.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Previously, git stash drop would fail noisily while executing git reflog
delete if the specified revision was not a stash reference.
Now, git stash drop fails with an error message which more precisely
indicates the reason for failure.
Furthermore, git stash drop will now fail with a non-zero status code
if stash@{n} specifies a stash log entry that does not actually exist.
This change in behaviour is achieved by delegating argument parsing
to the common parse_flags_and_rev() function (via a call to
assert_stash_ref).
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The implementation of stash_apply() is simplified to take
advantage of the common parsing function parse_flags_and_rev().
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is required because git rev-parse in 1.7.2 does not correctly
indicate invalid log references using a non-zero status code.
We use a proxy for the condition (non-empty error output) as
a substitute. This commit can be reverted when, and if, rev-parse
is fixed to indicate invalid log references with a status code.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Introduce parse_flags_and_revs. This function requires that
there is at most one stash-like revision parameter and
zero or more flags.
It knows how to parse -q,--quiet and --index flags, but leaves
other flags parsed.
Specified revisions are checked to see that they are at
least stash-like (meaning: they look like something created
by git stash save or git stash create).
If this is so, then IS_STASH_LIKE is initialized to a non-empty value.
If the specified revision also looks like a stash log entry reference,
then IS_STASH_REF is initialized to a non-empty value.
References of the form ref@{spec} are required to precisely identify
an individual commit.
If no reference is specified, stash@{0} is assumed.
Once the specified reference is validated to be at least stash_like
an ensemble of derived variables, (w_commit, w_tree, b_commit, etc)
is initialized with a single call to git rev-parse.
Repeated calls to parse_flags_and_rev() avoid repeated calls
to git rev-parse if the specified arguments have already been
parsed.
Subsequent patches in the series modify the existing
git stash subcommands to make use of these functions
as appropriate.
An ensemble of supporting functions that make use of the state
established by parse_flags_and_rev(). These are described below:
The ancillary functions are:
is_stash_like(): which can be used to test
whether a specified commit looks like a commit created with
git stash save or git stash create.
assert_stash_like(): which can be used by
commands that misbehave unless their arguments stash-like.
is_stash_ref(): which checks whether an argument
is valid stash reference(e.g. is of the form
['refs/']stash['@{'something'}])
assert_stash_ref(): which can be used by commands
that misbehave unless their arguments are both stash-like and
refer to valid stash entries.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mm/rebase-i-exec:
git-rebase--interactive.sh: use printf instead of echo to print commit message
git-rebase--interactive.sh: rework skip_unnecessary_picks
test-lib: user-friendly alternatives to test [-d|-f|-e]
rebase -i: add exec command to launch a shell command
Conflicts:
git-rebase--interactive.sh
t/t3404-rebase-interactive.sh
* mm/shortopt-detached:
log: parse separate option for --glob
log: parse separate options like git log --grep foo
diff: parse separate options --stat-width n, --stat-name-width n
diff: split off a function for --stat-* option parsing
diff: parse separate options like -S foo
Conflicts:
revision.c
* nd/fix-sparse-checkout:
unpack-trees: mark new entries skip-worktree appropriately
unpack-trees: do not check for conflict entries too early
unpack-trees: let read-tree -u remove index entries outside sparse area
unpack-trees: only clear CE_UPDATE|CE_REMOVE when skip-worktree is always set
t1011 (sparse checkout): style nitpicks
* hv/submodule-find-ff-merge:
Implement automatic fast-forward merge for submodules
setup_revisions(): Allow walking history in a submodule
Teach ref iteration module about submodules
Conflicts:
submodule.c
* dg/local-mod-error-messages:
t7609: test merge and checkout error messages
unpack_trees: group error messages by type
merge-recursive: distinguish "removed" and "overwritten" messages
merge-recursive: porcelain messages for checkout
Turn unpack_trees_options.msgs into an array + enum
Conflicts:
t/t3400-rebase.sh
When you call "git reset --mixed <paths>" git will warn that using mixed
with paths is deprecated:
warning: --mixed option is deprecated with paths.
That doesn't tell the user what he should use instead. Expand on the
warning and tell the user to just omit --mixed:
warning: --mixed with paths is deprecated; use 'git reset -- <paths>' instead
The exact wording of the warning was suggested by Jonathan Nieder.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
To discover filenames from the --- and +++ lines in a traditional
unified diff, currently "git apply" scans forward for a whitespace
character on each line and stops there. It can't use the whole line
because "diff -u" likes to include timestamps, like so:
--- foo 2000-07-12 16:56:50.020000414 -0500
+++ bar 2010-07-12 16:56:50.020000414 -0500
The whitespace-seeking heuristic works great, even when the tab
has been converted to spaces by some email + copy-and-paste
related corruption.
Except for one problem: if the filename itself contains whitespace,
the inferred filename will be too short.
When Giuseppe ran into this problem, it was for a file creation
patch (for debian/licenses/LICENSE.global BSD-style Chromium).
So one can't use the list of files present in the index to deduce an
appropriate filename (not to mention that way lies madness; see
v0.99~402, 2005-05-31).
Instead, look for a timestamp and use that if present to mark the end
of the filename. If no timestamp is present, the old heuristic is
used, with one exception: the space character \040 is not considered
terminating whitespace any more unless it is followed by a timestamp.
Reported-by: Giuseppe Iuculano <iuculano@debian.org>
Acked-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Check that "git apply" can cope with strange filenames, particularly
filenames with spaces.
Not all platforms have a sane enough diff -u and expand to
reliably create the such patches and maybe future versions of GNU
diff will handle funny characters differently, so this uses
pre-generated patches. The script used to generate them is in
t/t4135/make-patches.
Filenames with tabs are not usable on NTFS; use something like the
FUNNYNAMES prerequisite from v1.3.0-rc1~67 (2006-03-03) to skip the
relevant tests when appropriate. The detection is not shared in
test-lib.sh to avoid wasting time while running other test scripts.
Backslash is the path separator on Windows, so do not used it in
file names there (v1.6.3-rc0~93^2~6, 2009-03-13).
Finally, filenames starting with a quotation mark do not behave well
in msys (see v1.7.0-rc0~94^2, t4030, t4031: work around bogus MSYS
bash path conversion, 2010-01-01), so skip those tests on Windows,
too.
Helped-by: Andreas Schwab <schwab@linux-m68k.org>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The new find_name_gnu() function handles new-style '--- "a/foo"'
patch header lines, leaving find_name() itself a bit less
daunting.
Functional change: do not clobber the p-value when there are not
enough path components in a quoted file name to honor it.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
We use our custom xsl file to build the user manual, so make
sure we depend on it. We don't use it anywhere else, so we
can stick it straight in the rule.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Because there is no unescaped apostrophe to pair it with, asciidoc
does not consider this apostrophe a candidate for escaping and
the backslash passes through.
Reported-by: Frédéric Brière <fbriere@fbriere.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>