git
15 years agorepack: do not fall back to incremental repacking with [-a|-A]
Brandon Casey [Wed, 12 Nov 2008 17:59:06 +0000 (11:59 -0600)] 
repack: do not fall back to incremental repacking with [-a|-A]

When repack is called with either the -a or -A option, the user has
requested to repack all objects including those referenced by the
alternates mechanism. Currently, if there are no local packs without
.keep files, then repack will call pack-objects with the
'--unpacked --incremental' options which causes it to exclude alternate
packed objects. So, remove this fallback.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agorepack: don't repack local objects in packs with .keep file
Brandon Casey [Wed, 12 Nov 2008 17:59:05 +0000 (11:59 -0600)] 
repack: don't repack local objects in packs with .keep file

If the user created a .keep file for a local pack, then it can be inferred
that the user does not want those objects repacked.

This fixes the repack bug tested by t7700.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agopack-objects: new option --honor-pack-keep
Brandon Casey [Wed, 12 Nov 2008 17:59:04 +0000 (11:59 -0600)] 
pack-objects: new option --honor-pack-keep

This adds a new option to pack-objects which will cause it to ignore an
object which appears in a local pack which has a .keep file, even if it
was specified for packing.

This option will be used by the porcelain repack.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agopacked_git: convert pack_local flag into a bitfield and add pack_keep
Brandon Casey [Wed, 12 Nov 2008 17:59:03 +0000 (11:59 -0600)] 
packed_git: convert pack_local flag into a bitfield and add pack_keep

pack_keep will be set when a pack file has an associated .keep file.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agot7700: demonstrate mishandling of objects in packs with a .keep file
Brandon Casey [Wed, 12 Nov 2008 17:59:02 +0000 (11:59 -0600)] 
t7700: demonstrate mishandling of objects in packs with a .keep file

Objects residing in pack files that have an associated .keep file are not
supposed to be repacked into new pack files, but they are.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix non-literal format in printf-style calls
Daniel Lowe [Mon, 10 Nov 2008 21:07:52 +0000 (16:07 -0500)] 
Fix non-literal format in printf-style calls

These were found using gcc 4.3.2-1ubuntu11 with the warning:

    warning: format not a string literal and no format arguments

Incorporated suggestions from Brandon Casey <casey@nrlssc.navy.mil>.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit-submodule: Avoid printing a spurious message.
Alexandre Julliard [Tue, 11 Nov 2008 21:09:16 +0000 (22:09 +0100)] 
git-submodule: Avoid printing a spurious message.

Fix 'git submodule update' to avoid printing a spurious "Maybe you want
to use 'update --init'?" once for every uninitialized submodule it
encounters.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit ls-remote: make usage string match manpage
Stefan Naewe [Tue, 11 Nov 2008 15:52:31 +0000 (16:52 +0100)] 
git ls-remote: make usage string match manpage

The usage string of 'git ls-remote' is pretty terse. The manpage
however gives the correct 'synopsis'.

Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoMakefile: help people who run 'make check' by mistake
Junio C Hamano [Tue, 11 Nov 2008 21:12:17 +0000 (13:12 -0800)] 
Makefile: help people who run 'make check' by mistake

The target to run self test is 'make test', but there are people who try
'make check' and worse yet do not have sparse installed.

Suggest 'make test' target when they do not have 'sparse'.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocumentation: bisect: change a few instances of "git-cmd" to "git cmd"
Christian Couder [Sun, 9 Nov 2008 13:53:14 +0000 (14:53 +0100)] 
Documentation: bisect: change a few instances of "git-cmd" to "git cmd"

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocumentation: rev-list: change a few instances of "git-cmd" to "git cmd"
Christian Couder [Sun, 9 Nov 2008 13:46:35 +0000 (14:46 +0100)] 
Documentation: rev-list: change a few instances of "git-cmd" to "git cmd"

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agocheckout: Don't crash when switching away from an invalid branch.
Alexandre Julliard [Sat, 8 Nov 2008 12:03:59 +0000 (13:03 +0100)] 
checkout: Don't crash when switching away from an invalid branch.

When using alternates, it is possible for HEAD to end up pointing to
an invalid commit. git checkout should be able to recover from that
situation without crashing.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoGIT 1.6.0.4 v1.6.0.4
Junio C Hamano [Sun, 9 Nov 2008 01:33:50 +0000 (17:33 -0800)] 
GIT 1.6.0.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoUpdate RPM spec for the new location of git-cvsserver.
Quy Tonthat [Fri, 12 Sep 2008 16:22:44 +0000 (02:22 +1000)] 
Update RPM spec for the new location of git-cvsserver.

git-cvsserver has been moved from libexecdir to bindir.

Signed-off-by: Quy Tonthat <qtonthat@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoMerge branch 'cb/maint-update-ref-fix' into maint
Junio C Hamano [Sun, 9 Nov 2008 01:32:49 +0000 (17:32 -0800)] 
Merge branch 'cb/maint-update-ref-fix' into maint

* cb/maint-update-ref-fix:
  push: fix local refs update if already up-to-date
  do not force write of packed refs

15 years agoMerge branch 'cj/maint-gitpm-fix-maybe-self' into maint
Junio C Hamano [Sun, 9 Nov 2008 00:50:25 +0000 (16:50 -0800)] 
Merge branch 'cj/maint-gitpm-fix-maybe-self' into maint

* cj/maint-gitpm-fix-maybe-self:
  Git.pm: do not break inheritance

15 years agoMerge branch 'ar/maint-mksnpath' into maint
Junio C Hamano [Sun, 9 Nov 2008 00:13:19 +0000 (16:13 -0800)] 
Merge branch 'ar/maint-mksnpath' into maint

* ar/maint-mksnpath:
  Use git_pathdup instead of xstrdup(git_path(...))
  git_pathdup: returns xstrdup-ed copy of the formatted path
  Fix potentially dangerous use of git_path in ref.c
  Add git_snpath: a .git path formatting routine with output buffer
  Fix potentially dangerous uses of mkpath and git_path
  Fix mkpath abuse in dwim_ref and dwim_log of sha1_name.c
  Add mksnpath which allows you to specify the output buffer

Conflicts:
builtin-revert.c
rerere.c

15 years agoMerge branch 'mv/maint-branch-m-symref' into maint
Junio C Hamano [Sun, 9 Nov 2008 00:07:37 +0000 (16:07 -0800)] 
Merge branch 'mv/maint-branch-m-symref' into maint

* mv/maint-branch-m-symref:
  update-ref --no-deref -d: handle the case when the pointed ref is packed
  git branch -m: forbid renaming of a symref
  Fix git update-ref --no-deref -d.
  rename_ref(): handle the case when the reflog of a ref does not exist
  Fix git branch -m for symrefs.

15 years agopush: fix local refs update if already up-to-date
Clemens Buchacher [Wed, 5 Nov 2008 20:55:54 +0000 (21:55 +0100)] 
push: fix local refs update if already up-to-date

git push normally updates local refs only after a successful push. If the
remote already has the updates -- pushed indirectly through another repository,
for example -- we forget to update local tracking refs.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agodo not force write of packed refs
Clemens Buchacher [Wed, 5 Nov 2008 20:55:53 +0000 (21:55 +0100)] 
do not force write of packed refs

We force writing a ref if it does not exist. Originally, we only had to look
for the ref file to check if it existed. Now we have to look for a packed ref
as well. Luckily, resolve_ref already does all the work for us.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoformat-patch documentation: mention the special case of showing a single commit
Junio C Hamano [Mon, 3 Nov 2008 04:45:55 +0000 (20:45 -0800)] 
format-patch documentation: mention the special case of showing a single commit

Even long timers seem to have missed that "format-patch -1 $commit" is a
much simpler and more obvious way to say "format-patch $commit^..$commit"
from the current documentation (and an example "format-patch -3 $commit"
to get three patches).  Add an explicit instruction in a much earlier part
of the documentation to make it easier to find.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd reference for status letters in documentation.
Yann Dirson [Sun, 2 Nov 2008 13:37:28 +0000 (14:37 +0100)] 
Add reference for status letters in documentation.

Also fix error in diff_filepair::status documentation, and point to
the in-code reference as well as the doc.

Signed-off-by: Yann Dirson <ydirson@altern.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocument that git-log takes --all-match.
Mikael Magnusson [Sun, 2 Nov 2008 18:32:46 +0000 (19:32 +0100)] 
Document that git-log takes --all-match.

Signed-off-by: Mikael Magnusson <mikachu@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoUpdate draft 1.6.0.4 release notes
Junio C Hamano [Sun, 2 Nov 2008 22:35:41 +0000 (14:35 -0800)] 
Update draft 1.6.0.4 release notes

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoMerge branch 'js/maint-fetch-update-head' into maint
Junio C Hamano [Sun, 2 Nov 2008 21:37:16 +0000 (13:37 -0800)] 
Merge branch 'js/maint-fetch-update-head' into maint

* js/maint-fetch-update-head:
  pull: allow "git pull origin $something:$current_branch" into an unborn branch
  Fix fetch/pull when run without --update-head-ok

15 years agoMerge branch 'jk/maint-ls-files-other' into maint
Junio C Hamano [Sun, 2 Nov 2008 21:37:13 +0000 (13:37 -0800)] 
Merge branch 'jk/maint-ls-files-other' into maint

* jk/maint-ls-files-other:
  refactor handling of "other" files in ls-files and status

15 years agoMerge branch 'jc/maint-reset-remove-unmerged-new' into maint
Junio C Hamano [Sun, 2 Nov 2008 21:36:20 +0000 (13:36 -0800)] 
Merge branch 'jc/maint-reset-remove-unmerged-new' into maint

* jc/maint-reset-remove-unmerged-new:
  reset --hard/read-tree --reset -u: remove unmerged new paths

15 years agoMerge branch 'jc/maint-co-track' into maint
Junio C Hamano [Sun, 2 Nov 2008 21:36:14 +0000 (13:36 -0800)] 
Merge branch 'jc/maint-co-track' into maint

* jc/maint-co-track:
  Enhance hold_lock_file_for_{update,append}() API
  demonstrate breakage of detached checkout with symbolic link HEAD
  Fix "checkout --track -b newbranch" on detached HEAD

15 years agoStart 1.6.0.4 cycle
Junio C Hamano [Sun, 2 Nov 2008 07:14:04 +0000 (00:14 -0700)] 
Start 1.6.0.4 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoadd instructions on how to send patches to the mailing list with Gmail
Tom Preston-Werner [Sat, 1 Nov 2008 15:28:18 +0000 (15:28 +0000)] 
add instructions on how to send patches to the mailing list with Gmail

Gmail is one of the most popular email providers in the world. Now that Gmail
supports IMAP, sending properly formatted patches via `git imap-send` is
trivial. This section in SubmittingPatches explains how to do so.

Signed-off-by: Tom Preston-Werner <tom@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocumentation/gitattributes: Add subsection header for each attribute
Jakub Narebski [Sat, 1 Nov 2008 06:24:55 +0000 (06:24 +0000)] 
Documentation/gitattributes: Add subsection header for each attribute

This makes attributes easier to find; before this patch some
attributes had individual subsections, and some didn't.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit send-email: avoid leaking directory file descriptors.
Pierre Habouzit [Fri, 31 Oct 2008 18:57:10 +0000 (18:57 +0000)] 
git send-email: avoid leaking directory file descriptors.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agosend-pack: do not send out single-level refs such as refs/stash
Jeff King [Wed, 29 Oct 2008 05:17:55 +0000 (05:17 +0000)] 
send-pack: do not send out single-level refs such as refs/stash

Since no version of receive-pack accepts these "funny refs", we should
mirror the check when considering the list of refs to send. IOW, don't
even make them eligible for matching or mirroring.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agofix overlapping memcpy in normalize_absolute_path
Jeff King [Thu, 23 Oct 2008 04:32:23 +0000 (04:32 +0000)] 
fix overlapping memcpy in normalize_absolute_path

The comments for normalize_absolute_path explicitly claim
that the source and destination buffers may be the same
(though they may not otherwise overlap). Thus the call to
memcpy may involve copying overlapping data, and memmove
should be used instead.

This fixes a valgrind error in t1504.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agopack-objects: avoid reading uninitalized data
Jeff King [Thu, 23 Oct 2008 04:31:03 +0000 (04:31 +0000)] 
pack-objects: avoid reading uninitalized data

In the main loop of find_deltas, we do:

  struct object_entry *entry = *list++;
  ...
  if (!*list_size)
  ...
  break

Because we look at and increment *list _before_ the check of
list_size, in the very last iteration of the loop we will
look at uninitialized data, and increment the pointer beyond
one past the end of the allocated space. Since we don't
actually do anything with the data until after the check,
this is not a problem in practice.

But since it technically violates the C standard, and
because it provokes a spurious valgrind warning, let's just
move the initialization of entry to a safe place.

This fixes valgrind errors in t5300, t5301, t5302, t303, and
t9400.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agocorrect cache_entry allocation
Jeff King [Thu, 23 Oct 2008 04:30:58 +0000 (04:30 +0000)] 
correct cache_entry allocation

Most cache_entry structs are allocated by using the
cache_entry_size macro, which rounds the size of the struct
up to the nearest multiple of 8 bytes (presumably to avoid
memory fragmentation).

There is one exception: the special "conflict entry" is
allocated with an empty name, and so is explicitly given
just one extra byte to hold the NUL.

However, later code doesn't realize that this particular
struct has been allocated differently, and happily tries
reading and copying it based on the ce_size macro, which
assumes the 8-byte alignment.

This can lead to reading uninitalized data, though since
that data is simply padding, there shouldn't be any problem
as a result. Still, it makes sense to hold the padding
assumption so as not to surprise later maintainers.

This fixes valgrind errors in t1005, t3030, t4002, and
t4114.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoMerge branch 'maint' of git://repo.or.cz/git-gui into maint
Junio C Hamano [Sun, 2 Nov 2008 05:31:14 +0000 (22:31 -0700)] 
Merge branch 'maint' of git://repo.or.cz/git-gui into maint

* 'maint' of git://repo.or.cz/git-gui:
  git-gui: Help identify aspell version on Windows too

15 years agoupdate-ref --no-deref -d: handle the case when the pointed ref is packed
Miklos Vajna [Fri, 31 Oct 2008 23:25:44 +0000 (00:25 +0100)] 
update-ref --no-deref -d: handle the case when the pointed ref is packed

In this case we did nothing in the past, but we should delete the
reference in fact.

The problem was that when the symref is not packed but the referenced
ref is packed, then we assumed that the symref is packed as well, but
symrefs are never packed.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit-svn: change dashed git-commit-tree to git commit-tree
Deskin Miller [Fri, 31 Oct 2008 04:10:25 +0000 (00:10 -0400)] 
git-svn: change dashed git-commit-tree to git commit-tree

Signed-off-by: Deskin Miller <deskinm@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocumentation: clarify information about 'ident' attribute
Jan Krüger [Thu, 30 Oct 2008 18:14:33 +0000 (19:14 +0100)] 
Documentation: clarify information about 'ident' attribute

The documentation spoke of the attribute being set "to" a path; this can
mistakenly be interpreted as "the attribute needs to have its value set to
some kind of path". This clarifies things.

Signed-off-by: Jan Krüger <jk@jk.gs>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agobash completion: add doubledash to "git show"
Markus Heidelberg [Fri, 31 Oct 2008 00:04:46 +0000 (01:04 +0100)] 
bash completion: add doubledash to "git show"

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoUse test-chmtime -v instead of perl in t5000 to get mtime of a file
Alex Riesen [Thu, 30 Oct 2008 10:20:27 +0000 (11:20 +0100)] 
Use test-chmtime -v instead of perl in t5000 to get mtime of a file

The test was broken on admittedly broken combination of Windows, Cygwin,
and ActiveState Perl.

Signed-off-by: Alex Riesen <ariesen@harmanbecker.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd --verbose|-v to test-chmtime
Alex Riesen [Thu, 30 Oct 2008 09:00:29 +0000 (10:00 +0100)] 
Add --verbose|-v to test-chmtime

This allows us replace perl when getting the mtime of a file because
of time zone conversions, though at the moment only one platform which
does this has been identified: Cygwin when used with ActiveState Perl
(as usual).

The output format is:

    <mtime1> TAB <filename1> <LF>
    <mtime2> TAB <filename2> <LF>
    ...

which, if only mtime is needed can be parsed with cut(1):

    test-chmtime -v +0 filename1 | cut -f 1

Also, the change adds a description of programs features, with examples.

Signed-off-by: Alex Riesen <ariesen@harmanbecker.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoasciidoc: add minor workaround to add an empty line after code blocks
Jonas Fonseca [Thu, 30 Oct 2008 10:45:03 +0000 (11:45 +0100)] 
asciidoc: add minor workaround to add an empty line after code blocks

Insert an empty <simpara> in manpages after code blocks to force and
empty line.

The problem can be seen on the manpage for the git tutorial, where an
example command and the following paragraph is printed with no empty
line between them:

     First, note that you can get documentation for a command such as git
     log --graph with:

         $ man git-log
     It is a good idea to introduce yourself to git [...]

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoUse git_pathdup instead of xstrdup(git_path(...))
Alex Riesen [Mon, 27 Oct 2008 10:22:09 +0000 (11:22 +0100)] 
Use git_pathdup instead of xstrdup(git_path(...))

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit_pathdup: returns xstrdup-ed copy of the formatted path
Alex Riesen [Mon, 27 Oct 2008 10:17:51 +0000 (11:17 +0100)] 
git_pathdup: returns xstrdup-ed copy of the formatted path

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix potentially dangerous use of git_path in ref.c
Alex Riesen [Mon, 27 Oct 2008 10:11:40 +0000 (11:11 +0100)] 
Fix potentially dangerous use of git_path in ref.c

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd git_snpath: a .git path formatting routine with output buffer
Alex Riesen [Mon, 27 Oct 2008 09:22:21 +0000 (10:22 +0100)] 
Add git_snpath: a .git path formatting routine with output buffer

The function's purpose is to replace git_path where the buffer of
formatted path may not be reused by subsequent calls of the function
or will be copied anyway.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoPlug a memleak in builtin-revert
Alex Riesen [Tue, 28 Oct 2008 17:27:33 +0000 (18:27 +0100)] 
Plug a memleak in builtin-revert

Probably happened when working around git_path's problem with returned
buffer being reused.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit branch -m: forbid renaming of a symref
Miklos Vajna [Wed, 29 Oct 2008 00:05:27 +0000 (01:05 +0100)] 
git branch -m: forbid renaming of a symref

There may be cases where one would really want to rename the symbolic
ref without changing its value, but "git branch -m" is not such a
use-case.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd file delete/create info when we overflow rename_limit
Linus Torvalds [Mon, 27 Oct 2008 20:06:16 +0000 (13:06 -0700)] 
Add file delete/create info when we overflow rename_limit

When we refuse to do rename detection due to having too many files
created or deleted, let the user know the numbers.  That way there is a
reasonable starting point for setting the diff.renamelimit option.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoInstall git-cvsserver in $(bindir)
Nanako Shiraishi [Wed, 10 Sep 2008 11:03:18 +0000 (20:03 +0900)] 
Install git-cvsserver in $(bindir)

It is one of the server side programs and needs to be found on usual $PATH.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoInstall git-shell in bindir, too
Tommi Virtanen [Sun, 24 Aug 2008 20:23:25 +0000 (23:23 +0300)] 
Install git-shell in bindir, too

/etc/passwd shell field must be something execable, you can't enter
"/usr/bin/git shell" there. git-shell must be present as a separate
executable, or it is useless.

Signed-off-by: Tommi Virtanen <tv@eagain.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix potentially dangerous uses of mkpath and git_path
Alex Riesen [Sun, 26 Oct 2008 22:08:52 +0000 (23:08 +0100)] 
Fix potentially dangerous uses of mkpath and git_path

Replace them with mksnpath/git_snpath and a local buffer
for the resulting string.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix mkpath abuse in dwim_ref and dwim_log of sha1_name.c
Alex Riesen [Sun, 26 Oct 2008 22:07:24 +0000 (23:07 +0100)] 
Fix mkpath abuse in dwim_ref and dwim_log of sha1_name.c

Otherwise the function sometimes fail to resolve obviously correct
refnames, because the string data pointed to by "str" argument were
reused.

The change in dwim_log does not fix anything, just optimizes away
strcpy code as the path can be created directly in the available
buffer.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd mksnpath which allows you to specify the output buffer
Alex Riesen [Sun, 26 Oct 2008 21:59:13 +0000 (22:59 +0100)] 
Add mksnpath which allows you to specify the output buffer

This is just vsnprintf's but additionally calls cleanup_path() on the
result. To be used as alternatives to mkpath() where the buffer for the
created path may not be reused by subsequent calls of the same formatting
function.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoadd -p: warn if only binary changes present
Thomas Rast [Sun, 26 Oct 2008 19:37:06 +0000 (20:37 +0100)] 
add -p: warn if only binary changes present

Current 'git add -p' will say "No changes." if there are no changes to
text files, which can be confusing if there _are_ changes to binary
files.  Add some code to distinguish the two cases, and give a
different message in the latter one.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit-archive: work in bare repos
Charles Bailey [Sat, 25 Oct 2008 15:38:14 +0000 (11:38 -0400)] 
git-archive: work in bare repos

This moves the call to git_config to a place where it doesn't break the
logic for using git archive in a bare repository but retains the fix to
make git archive respect core.autocrlf.

Tests are by René Scharfe.

Signed-off-by: Charles Bailey <charles@hashpling.org>
Tested-by: Deskin Miller <deskinm@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix git update-ref --no-deref -d.
Miklos Vajna [Sun, 26 Oct 2008 02:33:58 +0000 (03:33 +0100)] 
Fix git update-ref --no-deref -d.

Till now --no-deref was just ignored when deleting refs, fix this.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agorename_ref(): handle the case when the reflog of a ref does not exist
Miklos Vajna [Sun, 26 Oct 2008 02:33:57 +0000 (03:33 +0100)] 
rename_ref(): handle the case when the reflog of a ref does not exist

We tried to check if a reflog of a ref is a symlink without first
checking if it exists, which is a bug.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix git branch -m for symrefs.
Miklos Vajna [Sun, 26 Oct 2008 02:33:56 +0000 (03:33 +0100)] 
Fix git branch -m for symrefs.

This had two problems with symrefs. First, it copied the actual sha1
instead of the "pointer", second it failed to remove the old ref after a
successful rename.

Given that till now delete_ref() always dereferenced symrefs, a new
parameters has been introduced to delete_ref() to allow deleting refs
without a dereference.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit-svn: change dashed git-config to git config
Deskin Miller [Thu, 23 Oct 2008 19:21:34 +0000 (15:21 -0400)] 
git-svn: change dashed git-config to git config

Signed-off-by: Deskin Miller <deskinm@umich.edu>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoGIT 1.6.0.3 v1.6.0.3
Junio C Hamano [Tue, 21 Oct 2008 20:37:42 +0000 (13:37 -0700)] 
GIT 1.6.0.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agorehabilitate 'git index-pack' inside the object store
Nicolas Pitre [Tue, 21 Oct 2008 01:17:07 +0000 (21:17 -0400)] 
rehabilitate 'git index-pack' inside the object store

Before commit d0b92a3f6e it was possible to run 'git index-pack'
directly in the .git/objects/pack/ directory.  Restore that ability.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix testcase failure when extended attributes are in use
Junio C Hamano [Mon, 20 Oct 2008 05:51:17 +0000 (22:51 -0700)] 
Fix testcase failure when extended attributes are in use

06cbe855 (Make core.sharedRepository more generic, 2008-04-16) made
several testcases in t1301-shared-repo.sh which fail if on a system
which creates files with extended attributes (e.g. SELinux), since ls
appends a '+' sign to the permission set in such cases.  In fact,
POSIX.1 allows ls to add a single printable character after the usual
3x3 permission bits to show that an optional alternate/additional access
method is associated with the path.

This fixes the testcase to strip any such sign prior to verifying the
permission set.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tested-by: Deskin Miller <deskinm@umich.edu>
15 years agoGit.pm: do not break inheritance
Christian Jaeger [Sat, 18 Oct 2008 18:25:12 +0000 (20:25 +0200)] 
Git.pm: do not break inheritance

Make it possible to write subclasses of Git.pm

Signed-off-by: Christian Jaeger <christian@jaeger.mine.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoEnhance hold_lock_file_for_{update,append}() API
Junio C Hamano [Fri, 17 Oct 2008 22:44:39 +0000 (15:44 -0700)] 
Enhance hold_lock_file_for_{update,append}() API

This changes the "die_on_error" boolean parameter to a mere "flags", and
changes the existing callers of hold_lock_file_for_update/append()
functions to pass LOCK_DIE_ON_ERROR.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agodemonstrate breakage of detached checkout with symbolic link HEAD
Junio C Hamano [Fri, 17 Oct 2008 22:56:11 +0000 (15:56 -0700)] 
demonstrate breakage of detached checkout with symbolic link HEAD

When core.prefersymlinkrefs is in use, detaching the HEAD by
checkout incorrectly clobbers the tip of the current branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoDocumentation: Clarify '--signoff' for git-commit
Abhijit Bhopatkar [Sun, 19 Oct 2008 04:19:23 +0000 (09:49 +0530)] 
Documentation: Clarify '--signoff' for git-commit

'--signoff' uses commiter name always to add the signoff line,
make it explicit in the documentation.

Signed-off-by: Abhijit Bhopatkar <bain@devslashzero.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoreset --hard/read-tree --reset -u: remove unmerged new paths
Junio C Hamano [Wed, 15 Oct 2008 23:00:06 +0000 (16:00 -0700)] 
reset --hard/read-tree --reset -u: remove unmerged new paths

When aborting a failed merge that has brought in a new path using "git
reset --hard" or "git read-tree --reset -u", we used to first forget about
the new path (via read_cache_unmerged) and then matched the working tree
to what is recorded in the index, thus ending up leaving the new path in
the work tree.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoHopefully the final draft release notes update before 1.6.0.3
Junio C Hamano [Sat, 18 Oct 2008 15:26:39 +0000 (08:26 -0700)] 
Hopefully the final draft release notes update before 1.6.0.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agodiff(1): clarify what "T"ypechange status means
Junio C Hamano [Sat, 18 Oct 2008 15:20:51 +0000 (08:20 -0700)] 
diff(1): clarify what "T"ypechange status means

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoMerge branch 'db/maint-checkout-b' into maint
Junio C Hamano [Sat, 18 Oct 2008 15:18:11 +0000 (08:18 -0700)] 
Merge branch 'db/maint-checkout-b' into maint

* db/maint-checkout-b:
  Check early that a new branch is new and valid

15 years agocontrib: update packinfo.pl to not use dashed commands
Dan McGee [Sat, 18 Oct 2008 02:41:18 +0000 (21:41 -0500)] 
contrib: update packinfo.pl to not use dashed commands

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoforce_object_loose: Fix memory leak
Björn Steinbrink [Sat, 18 Oct 2008 00:37:31 +0000 (02:37 +0200)] 
force_object_loose: Fix memory leak

read_packed_sha1 expectes its caller to free the buffer it returns, which
force_object_loose didn't do.

This leak is eventually triggered by "git gc", when it is manually invoked
or there are too many packs around, making gc totally unusable when there
are lots of unreachable objects.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Acked-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix "checkout --track -b newbranch" on detached HEAD
Junio C Hamano [Fri, 17 Oct 2008 06:37:44 +0000 (23:37 -0700)] 
Fix "checkout --track -b newbranch" on detached HEAD

The test to make sure that checkout fails when --track was asked for and
we cannot set up tracking information in t7201 was wrong, and it turns out
that the implementation for that feature itself was buggy.  This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agorefactor handling of "other" files in ls-files and status
Jeff King [Thu, 16 Oct 2008 15:07:26 +0000 (11:07 -0400)] 
refactor handling of "other" files in ls-files and status

When the "git status" display code was originally converted
to C, we copied the code from ls-files to discover whether a
pathname returned by read_directory was an "other", or
untracked, file.

Much later, 5698454e updated the code in ls-files to handle
some new cases caused by gitlinks.  This left the code in
wt-status.c broken: it would display submodule directories
as untracked directories. Nobody noticed until now, however,
because unless status.showUntrackedFiles was set to "all",
submodule directories were not actually reported by
read_directory. So the bug was only triggered in the
presence of a submodule _and_ this config option.

This patch pulls the ls-files code into a new function,
cache_name_is_other, and uses it in both places. This should
leave the ls-files functionality the same and fix the bug
in status.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agotests: shell negation portability fix
Jeff King [Mon, 13 Oct 2008 09:35:59 +0000 (05:35 -0400)] 
tests: shell negation portability fix

Commit 969c8775 introduced a test which uses the non-portable construct:

  command1 && ! command2 | command3

which must be

  command1 && ! (command2 | command3)

to work on bsd shells (this is another example of bbf08124, which fixed
several similar cases).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agopull: allow "git pull origin $something:$current_branch" into an unborn branch
Junio C Hamano [Tue, 14 Oct 2008 22:32:20 +0000 (15:32 -0700)] 
pull: allow "git pull origin $something:$current_branch" into an unborn branch

Some misguided documents floating on the Net suggest this sequence:

    mkdir newdir && cd newdir
    git init
    git remote add origin $url
    git pull origin master:master

"git pull" has known about misguided "pull" that lets the underlying fetch
update the current branch for a long time.  It also has known about
"git pull origin master" into a branch yet to be born.

These two workarounds however were not aware of the existence of each
other and did not work well together.  This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agot1301-shared-repo.sh: don't let a default ACL interfere with the test
Matt McCutchen [Fri, 17 Oct 2008 02:32:14 +0000 (22:32 -0400)] 
t1301-shared-repo.sh: don't let a default ACL interfere with the test

This test creates files with several different umasks and expects their
permissions to be initialized according to the umask, so a default ACL on the
trash directory (which overrides the umask for files created in that directory)
causes the test to fail.  To avoid that, remove the default ACL if possible with
setfacl(1).

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agogit-check-attr(1): add output and example sections
Jonas Fonseca [Wed, 15 Oct 2008 07:10:58 +0000 (09:10 +0200)] 
git-check-attr(1): add output and example sections

Plumbing tools should document what output can be expected.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoxdiff-interface.c: strip newline (and cr) from line before pattern matching
Brandon Casey [Wed, 1 Oct 2008 19:28:26 +0000 (14:28 -0500)] 
xdiff-interface.c: strip newline (and cr) from line before pattern matching

POSIX doth sayeth:

   "In the regular expression processing described in IEEE Std 1003.1-2001,
    the <newline> is regarded as an ordinary character and both a period and
    a non-matching list can match one. ... Those utilities (like grep) that
    do not allow <newline>s to match are responsible for eliminating any
    <newline> from strings before matching against the RE."

Thus far git has not been removing the trailing newline from strings matched
against regular expression patterns. This has the effect that (quoting
Jonathan del Strother) "... a line containing just 'FUNCNAME' (terminated by
a newline) will be matched by the pattern '^(FUNCNAME.$)' but not
'^(FUNCNAME$)'", and more simply not '^FUNCNAME$'.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agot4018-diff-funcname: demonstrate end of line funcname matching flaw
Brandon Casey [Thu, 16 Oct 2008 00:58:50 +0000 (19:58 -0500)] 
t4018-diff-funcname: demonstrate end of line funcname matching flaw

Since the newline is not removed from lines before pattern matching, a
pattern cannot match to the end of the line using the '$' operator without
using an additional operator which will indirectly match the '\n' character.

Introduce a test which should pass, but which does not due to this flaw.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agot4018-diff-funcname: rework negated last expression test
Brandon Casey [Thu, 16 Oct 2008 00:58:49 +0000 (19:58 -0500)] 
t4018-diff-funcname: rework negated last expression test

This test used the non-zero exit status of 'git diff' to indicate that a
negated funcname pattern, when placed last, was correctly rejected.

The problem with this is that 'git diff' always returns non-zero if it
finds differences in the files it is comparing, and the files must
contain differences in order to trigger the funcname pattern codepath.

Instead of checking for non-zero exit status, make sure the expected
error message is printed.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoTypo "does not exists" when git remote update remote.
Mikael Magnusson [Fri, 19 Sep 2008 13:48:08 +0000 (15:48 +0200)] 
Typo "does not exists" when git remote update remote.

15 years agoremote.c: correct the check for a leading '/' in a remote name
Brandon Casey [Tue, 14 Oct 2008 20:30:21 +0000 (15:30 -0500)] 
remote.c: correct the check for a leading '/' in a remote name

This test is supposed to disallow remote entries in the config file of the
form:

   [remote "/foobar"]
      ...

The leading slash in '/foobar' is not acceptable.

Instead it was incorrectly testing that the subkey had no leading '/', which
had no effect since the subkey pointer was made to point at a '.' in the
preceding lines.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoAdd testcase to ensure merging an early part of a branch is done properly
Miklos Vajna [Mon, 13 Oct 2008 20:54:25 +0000 (22:54 +0200)] 
Add testcase to ensure merging an early part of a branch is done properly

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoUpdate draft release notes to 1.6.0.3
Junio C Hamano [Mon, 13 Oct 2008 22:41:36 +0000 (15:41 -0700)] 
Update draft release notes to 1.6.0.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agoFix fetch/pull when run without --update-head-ok
Johannes Schindelin [Mon, 13 Oct 2008 09:36:52 +0000 (11:36 +0200)] 
Fix fetch/pull when run without --update-head-ok

Some confusing tutorials suggested that it would be a good idea to fetch
into the current branch with something like this:

git fetch origin master:master

(or even worse: the same command line with "pull" instead of "fetch").
While it might make sense to store what you want to pull, it typically is
plain wrong when the current branch is "master".  This should only be
allowed when (an incorrect) "git pull origin master:master" tries to work
around by giving --update-head-ok to underlying "git fetch", and otherwise
we should refuse it, but somewhere along the lines we lost that behavior.

The check for the current branch is now _only_ performed in non-bare
repositories, which is an improvement from the original behaviour.

Some newer tests were depending on the broken behaviour of "git fetch"
this patch fixes, and have been adjusted.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 years agotest-lib: fix broken printf
Shawn O. Pearce [Sun, 12 Oct 2008 20:13:59 +0000 (13:13 -0700)] 
test-lib: fix broken printf

b8eecafd888d219633f4c29e8b6a90fc21a46dfd introduced usage of
printf without a format string.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agogit apply --directory broken for new files
Jeff King [Sun, 12 Oct 2008 04:06:11 +0000 (00:06 -0400)] 
git apply --directory broken for new files

We carefully verify that the input to git-apply is sane,
including cross-checking that the filenames we see in "+++"
headers match what was provided on the command line of "diff
--git". When --directory is used, however, we ended up
comparing the unadorned name to one with the prepended root,
causing us to complain about a mismatch.

We simply need to prepend the root directory, if any, when
pulling the name out of the git header.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agorebase -i: do not fail when there is no commit to cherry-pick
Johannes Schindelin [Fri, 10 Oct 2008 11:42:12 +0000 (13:42 +0200)] 
rebase -i: do not fail when there is no commit to cherry-pick

In case there is no commit to apply (for example because you rebase to
upstream and all your local patches have been applied there), do not
fail.  The non-interactive rebase already behaves that way.

Do this by introducing a new command, "noop", which is substituted for
an empty commit list, so that deleting the commit list can still abort
as before.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agotest-lib: fix color reset in say_color()
Miklos Vajna [Thu, 9 Oct 2008 22:07:10 +0000 (00:07 +0200)] 
test-lib: fix color reset in say_color()

When executing a single test with colors enabled, the cursor was not set
back to the previous one, and you had to hit an extra enter to get it
back.

Work around this problem by calling 'tput sgr0' before printing the
final newline.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agofix pread()'s short read in index-pack
Nicolas Pitre [Fri, 10 Oct 2008 02:08:51 +0000 (22:08 -0400)] 
fix pread()'s short read in index-pack

Since v1.6.0.2~13^2~ the completion of a thin pack uses sha1write() for
its ability to compute a SHA1 on the written data.  This also provides
data buffering which, along with commit 92392b4a45, will confuse pread()
whenever an appended object is 1) freed due to memory pressure because
of the depth-first delta processing, and 2) needed again because it has
many delta children, and 3) its data is still buffered by sha1write().

Let's fix the issue by simply forcing cached data out when such an
object is written so it can be pread()'d at leisure.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agoMerge branch 'sg/maint-intrebase-msghook' into maint
Shawn O. Pearce [Thu, 9 Oct 2008 16:33:23 +0000 (09:33 -0700)] 
Merge branch 'sg/maint-intrebase-msghook' into maint

* sg/maint-intrebase-msghook:
  rebase -i: remove leftover debugging
  rebase -i: proper prepare-commit-msg hook argument when squashing

15 years agobuiltin-apply: fix typo leading to stack corruption
Imre Deak [Wed, 8 Oct 2008 21:24:16 +0000 (00:24 +0300)] 
builtin-apply: fix typo leading to stack corruption

This typo led to stack corruption for lines with whitespace fixes
and length > 1024.

Signed-off-by: Imre Deak <imre.deak@gmail.com>
Looks-good-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agogit-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c1)
Brandon Casey [Thu, 2 Oct 2008 23:52:11 +0000 (18:52 -0500)] 
git-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c1)

The referenced commit tried to fix a flaw in stash's handling of a user
supplied invalid ref. i.e. 'git stash apply fake_ref@{0}' should fail
instead of applying stash@{0}. But, it did so in a naive way by avoiding the
use of the --default option of rev-parse, and instead manually supplied the
default revision if the user supplied an empty command line. This prevented
a common usage scenario of supplying flags on the stash command line (i.e.
non-empty command line) which would be parsed by lower level git commands,
without supplying a specific revision. This should fall back to the default
revision, but now it causes an error. e.g. 'git stash show -p'

The correct fix is to use the --verify option of rev-parse, which fails
properly if an invalid ref is supplied, and still allows falling back to a
default ref when one is not supplied.

Convert stash-drop to use --verify while we're at it, since specifying
multiple revisions for any of these commands is also an error and --verify
makes it so.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agoMerge branch 'jk/maint-soliconv' into maint
Shawn O. Pearce [Thu, 9 Oct 2008 16:08:43 +0000 (09:08 -0700)] 
Merge branch 'jk/maint-soliconv' into maint

* jk/maint-soliconv:
  Makefile: do not set NEEDS_LIBICONV for Solaris 8

15 years agobuiltin-merge.c: allocate correct amount of memory
Brandon Casey [Thu, 9 Oct 2008 00:07:54 +0000 (19:07 -0500)] 
builtin-merge.c: allocate correct amount of memory

Fix two memory allocation errors which allocate space for a pointer
rather than enough space for the structure itself.

This:

    struct commit_list *parent = xmalloc(sizeof(struct commit_list *));

should have been this:

    struct commit_list *parent = xmalloc(sizeof(struct commit_list));

But while we're at it, change the allocation to reference the
variable it is allocating memory for to try to prevent a similar
mistake, for example if the type is changed, in the future.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Acked-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 years agoDo not use errno when pread() returns 0
Samuel Tardieu [Mon, 6 Oct 2008 17:28:41 +0000 (19:28 +0200)] 
Do not use errno when pread() returns 0

If we use pread() while at the end of the file, it will return 0, which is
not an error from the operating system point of view. In this case, errno
has not been set and must not be used.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>