If we are in a git directory, get_git_work_tree() can return NULL.
While trying to determine whether or not the given paths are outside
the work tree, the following command would read from it anyways and
trigger a segmentation fault.
git diff / /
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This function takes a sha1 and produces a loose object
filename. It caches the location of the object directory so
that it can fill the sha1 information directly without
allocating a new buffer (and in its original incarnation,
without calling getenv(), though these days we cache that
with the code in environment.c).
This cached base directory can become stale, however, if in
a single process git changes the location of the object
directory (e.g., by running setup_work_tree, which will
chdir to the new worktree).
In most cases this isn't a problem, because we tend to set
up the git repository location and do any chdir()s before
actually looking up any objects, so the first lookup will
cache the correct location. In the case of reset --hard,
however, we do something like:
1. look up the commit object
2. notice we are doing --hard, run setup_work_tree
3. look up the tree object to reset
Step (3) fails because our cache object directory value is
bogus.
This patch simply removes the caching. We use a static
buffer instead of allocating one each time (the original
version treated the malloc'd buffer as a static, so there is
no change in calling semantics).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Bigger writes to network drives on Windows XP fail. Cap them at 31MB to
allow them to succeed. Callers need to be prepared for write() calls
that do less work than requested anyway.
On local drives, write() calls are translated to WriteFile() calls with
a cap of 64KB on Windows XP and 256KB on Vista. Thus a cap of 31MB won't
affect the number of WriteFile() calls which do the actual work. There's
still room for some other version of Windows to use a chunk size of 1MB
without increasing the number of system calls.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Fix the problem where the cmd->err passed into start_command wasn't
being properly closed when certain types of errors occurr. (Compare
the affected code with the clean shutdown code later in the function.)
On Windows, this problem would be triggered if mingw_spawnvpe()
failed, which would happen if the command to be executed was malformed
(e.g. a text file that didn't start with a #! line). If cmd->err was
a pipe, the failure to close it could result in a hang while the other
side was waiting (forever) for either input or pipe close, e.g. while
trying to shove the output into the side band. On msysGit, this
problem was causing a hang in t5516-fetch-push.
[J6t: With a slight adjustment of the test case, the hang is also
observed on Linux.]
Signed-off-by: bert Dvornik <dvornik+git@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The git_mmap implementation was broken for file sizes that wouldn't fit
into a size_t (32 bits). This was caused by intermediate variables that
were only 32 bits wide when they should be 64 bits.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Coloring the extended headers where done as a whole not per line. less with
option -R (which is the default from git) does not support this coloring
mode because of performance reasons. The -r option would be an alternative
but has problems with lines that are longer than the screen. Therefore
stick to the idiom to color each line separately. The problem is, that the
result of ill_metainfo() will also be used as an parameter to an external
diff driver, so we need to disable coloring in this case.
Because coloring is now done inside fill_metainfo() we can simply add this
string to the diff header and therefore keep the last newline in the
extended header. This results also into the fact that the external diff
driver now gets this last newline too. Which is a change in behavior
but a good one.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
According to the default hooks/post-receive file, the hook is called
with three arguments on stdin:
<oldrev> <newrev> <refname>
In command-line mode, the arguments come in a different order, because
the email hook instead calls:
generate_email $2 $3 $1
Add a comment to explain why, based on comments from the mailing list
and the commit message to v1.5.1~9. Thanks to Andy for the
explanation.
Requested-by: martin f. krafft <madduck@debian.org>
Cc: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The name "Z" for the UTC timezone is required to properly parse ISO 8601
timestamps. Add it to the list of recognized timezones.
Because timezone names can be shorter than 3 letters, loosen the
restriction in match_alpha() that used to require at least 3 letters to
match to allow a short timezone name as long as it matches exactly. Prior
to the introduction of the "Z" zone, this already affected the timezone
"NT" (Nome).
Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
Reviewed-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reverse the order of "origin" and "result" so that the sentence
really describes an addition rather than a removal.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
While we don't always write out commands in full (`git command`) we
should do it consistently in adjacent paragraphs.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The check whether size is zero was done after if size <= SMALL_FILE_SIZE,
as result, zero size case was never triggered. Instead zero length file
was treated as any other small file. This did not caused any problem, but
if we have a special case for size equal to zero, it is better to make it
work and avoid redundant malloc().
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
As an option to the "diff" family, it is fairly obvious what
"detect renames" means. However, for revision traversal, the
"-M" option is just included in the long list of options,
with no indication that it is about showing renames in diffs
versus following renames. Let's make it more explicit.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Restrict the tags used to generate the version string to those that
begin with "v", since git's tags for git-core (ie. excluding git-gui)
are all of the form "vX.Y...".
This is to avoid using private tags by the user in a clone of the git
code repository, which may break certain machinery (eg. Makefile, gitk).
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When the user specifies a message, use fmt_merge_msg_shortlog() to
append the shortlog.
Previously, when a message was specified, we ignored the merge title
("Merge <foo> into <bar>") and shortlog from fmt_merge_msg().
Update the documentation for -m to reflect this too.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shift implementation into a private function, do_fmt_merge_msg(). This
allows for further changes to the implementation, without affecting the
interface.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
It is more accurate to call it 'merge_names' instead of 'msg', as it
does not contain the final message.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ce9d823 (merge: do not add standard message when message is given with
-m option) changed the behaviour of the code that the comment addressed,
but the comment was not similarly updated.
Fix this.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
If we know we are creating a bare repository, we use setenv
to set the GIT_DIR directory to the current directory
(either where we already were, or one we created and chdir'd
into with "git init --bare <dir>").
However, with "git --bare init <dir>" (note the --bare as a
git wrapper option), the setup code actually sets GIT_DIR
for us, but it uses the wrong, original cwd when a directory
is given. Because our setenv does not use the overwrite
flag, it is ignored.
We need to set the overwrite flag, but only when we are
given a directory on the command line. That still allows:
GIT_DIR=foo.git git init --bare
to work. The behavior is changed for:
GIT_DIR=foo.git git init --bare bar.git
which used to create the repository in foo.git, but now will
use bar.git. This is more sane, as command line options
should generally override the environment.
Noticed by Oliver Hoffmann.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When cloning into a non-bare repository, e.g. "git clone $URL mine",
we used to report that we are cloning into "mine/.git". Reword the
report to say "Cloning into mine" instead, as that matches what the
end-user asked for closer.
Make the message for "git clone --bare $URL mine" to say "Cloning
into bare repository mine" do make the distinction between this case and
the above stand out a bit more prominently.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Pete Harlan <pgit@pcharlan.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Spell out “or” in the NAME line and simplify the leading sentence
in the DESCRIPTION.
Some other language cleanups, too.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Clarify that the GIT_NOTES_REWRITE_REFS environment variable
overrides both ‘[notes "rewrite"] <command>’ and ‘[notes] rewriteRef’.
Add explanations of GIT_NOTES_REWRITE_MODE and GIT_NOTES_REWRITE_REFS
to the ENVIRONMENT section.
Cc: Leif Arne Storset <lstorset@opera.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The main description of display refs for notes should be in
git-log.1, where there is a chance to give a leisurely description
of all the ways they can be set, what they are used for, and so
on. The description in git-notes.1 is only meant to be a quick
reminder of how notes are used.
So simplify it.
Also add an entry for GIT_NOTES_DISPLAY_REF to the environment
section.
Cc: Thomas Rast <trast@student.ethz.ch>
Cc: Johan Herland <johan@herland.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Add a configuration section summarizing variables that affect the
log family of commands.
Cc: Thomas Rast <trast@student.ethz.ch>
Cc: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Separate the documentation of the semantics, command-line option,
configuration item, and environment variable for the default notes
ref. The documentation is easier to digest in bite-sized pieces.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Copy the descriptions of configuration variables from git-config.1.
Once the descriptions have been ironed out, it would be nice to
refactor them to share text, but for now it is simplest to experiment
with separate copies.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
stripspace/text-based formatting kicks in when specifying the notes
content with -m or -F, or when an editor is used to edit the notes.
To binary-safely create notes from files, the following construct is
required:
git notes add -C $(git hash-object -w <file>) <object>
Explain this trick (thanks, Johan!) in the manual. Add an ordinary
example, too, to keep this esoteric one company.
Cc: Johan Herland <johan@herland.net>
Cc: Thomas Rast <trast@student.ethz.ch>
Cc: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Separate the specification of the notes format exposed in
git-config.1 from the description of the option; or in other
words, move the explanation for what to expect to find at
refs/notes/commits from git-config.1 to git-notes.1.
Suggested-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When cherry-picking, usually the new and old commit encodings are both
UTF-8. Most old iconv implementations do not support this trivial
conversion, so on old platforms, out->message remains NULL, and later
attempts to read it segfault.
Fix this by noticing the input and output encodings match and skipping
the iconv step, like the other reencode_string() call sites already do.
Also stop segfaulting on other iconv failures: if iconv fails for some
other reason, the best we can do is to pass the old message through.
This fixes a regression introduced in v1.7.1-rc0~15^2~2 (revert:
clarify label on conflict hunks, 2010-03-20).
Reported-by: Andreas Krey <a.krey@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
In particular the gitweb/GITWEB-BUILD-OPTIONS file was not being
removed by the main Makefile. However, the gitweb/Makefile has a
'clean' target that correctly removes all the build products.
In order to fix the problem, rather than duplicate the clean-up
instructions, we change the main Makefile so that it delegates
the clean-up actions to the gitweb Makefile.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The documentation erroneously mentions the GIT_NOTES_REWRITE_REF
override in the description of notes.rewrite.<command>. Move it
under notes.rewriteRef where it belongs.
Signed-off-by: Leif Arne Storset <lstorset@opera.com>
Acked-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Previously the test would print to stdout which interfered with the
TAP output. Now this scaffolding code is just a normal test.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The naming of this test library conflicted with the recommendation in
t/README's "Naming Tests" section.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Both `-M` and `-C` have default values and the <num> argument
the last `-C` option takes effect.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Currently, status gives a lot of hints even when advice.statusHints is
false. Change this so that all hints depend on the config variable.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
edf563f (status: make "how to stage" messages optional, 2009-09-09)
introduced advice.statusHints without tests. Add a few tests to describe
and test the status quo.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
In 3bf7886 (test-lib: Let tests specify commands to be run at end of
test, 2010-05-02), the git test harness learned to run cleanup
commands unconditionally at the end of a test. During each test,
the intended cleanup actions are collected in the test_cleanup variable
and evaluated. That variable looks something like this:
eval_ret=$?; clean_something && (exit "$eval_ret")
eval_ret=$?; clean_something_else && (exit "$eval_ret")
eval_ret=$?; final_cleanup && (exit "$eval_ret")
eval_ret=$?
All cleanup actions are run unconditionally but if one of them fails
it is properly reported through $eval_ret.
On FreeBSD, unfortunately, $? is set at the beginning of an ‘eval’
to 0 instead of the exit status of the previous command. This results
in tests using test_expect_code appearing to fail and all others
appearing to pass, unless their cleanup fails. Avoid the problem by
setting eval_ret before the ‘eval’ begins.
Thanks to Jeff King for the explanation.
Cc: Jeff King <peff@peff.net>
Cc: Johannes Sixt <j6t@kdbg.org>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Prior to this, the output of git log -1 --format=%h was always 7
characters long, without regard to whether --abbrev had been passed.
Signed-off-by: Will Palmer <wmpalmer@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Do not document the --pretty synonym, since it takes too long to
explain the name to people.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Follow the current prevailing style. This also has the benefit of
capturing any stray output and noticing if any of the setup commands
start failing.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
When passed no revision arguments, ‘git shortlog’ reads a log from
stdin if and only if stdin is not a tty. So scripts that need to
function identically when standard input is a terminal (as when run
interactively) and not (as when run through a cron job) should either
supply a log themselves or specify the desired revisions explicitly.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Though I have not seen this in the wild, it has been said that there
are likely to be git repositories converted from other version control
systems with an invalid ident line like this one:
author <user@example.com> 18746342 +0000
Because there is no space between the (empty) user name and the email
address, commit --amend chokes. When searching for a
space-left-bracket sequence on the ident line, it finds it in the
committer line, ending up utterly confused.
Better for commit --amend to treat this like a valid ident line with
empty username and complain.
The tests remove the questionable commit objects after use so there is
no chance for them to confuse later tests.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Certain actions can imply that if the test fails early, recovery from
within other tests is too much to expect:
- creating unwritable directories, like the EACCESS test in t0001-init
- setting unusual configuration, like user.signingkey in t7004-tag
- crashing and leaving the index lock held, like t3600-rm once did
Some test scripts work around this by running cleanup actions outside
the supervision of the test harness, with the unfortunate consequence
that those commands are not appropriately echoed and their output not
suppressed. Others explicitly save exit status, clean up, and then
reset the exit status within the tests, which has excellent behavior
but makes the tests hard to read. Still others ignore the problem.
Allow tests a fourth option: by calling this function, tests can
stack up commands they would like to be run to clean up.
Commands passed to test_when_finished during a test are
unconditionally run in the test environment immediately before the
test is completed, in last-in-first-out order. If some cleanup
command fails, then the other cleanup commands are still run before
the failure is reported and the test script allowed to continue.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>