]> Pileus Git - ~andy/git/log
~andy/git
11 years agoclone: leave repo in place after checkout errors
Jeff King [Tue, 26 Mar 2013 22:22:09 +0000 (18:22 -0400)]
clone: leave repo in place after checkout errors

If we manage to clone a remote repository but run into an
error in the checkout, it is probably sane to leave the repo
directory in place. That lets the user examine the situation
without spending time to re-clone from the remote (which may
be a lengthy process).

Rather than try to convert each die() from the checkout code
path into an error(), we simply set a flag that tells the
"remove_junk" atexit function to print a helpful message and
leave the repo in place.

Note that the test added in this patch actually passes
without the code change. The reason is that the cleanup code
is buggy; we chdir into the working tree for the checkout,
but still may use relative paths to remove the directories
(which means if you cloned into "foo", we would accidentally
remove "foo" from the working tree!).  There's no point in
fixing it now, since this patch means we will never try to
remove anything after the chdir, anyway.

[jc: replaced the message with a more succinct version from
Jonathan]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoclone: run check_everything_connected
Jeff King [Mon, 25 Mar 2013 20:26:27 +0000 (16:26 -0400)]
clone: run check_everything_connected

When we fetch from a remote, we do a revision walk to make
sure that what we received is connected to our existing
history. We do not do the same check for clone, which should
be able to check that we received an intact history graph.

The upside of this patch is that it will make clone more
resilient against propagating repository corruption. The
downside is that we will now traverse "rev-list --objects
--all" down to the roots, which may take some time (it is
especially noticeable for a "--local --bare" clone).

Note that we need to adjust t5710, which tries to make such
a bogus clone. Rather than checking after the fact that our
clone is bogus, we can simplify it to just make sure "git
clone" reports failure.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoclone: die on errors from unpack_trees
Jeff King [Mon, 25 Mar 2013 20:23:59 +0000 (16:23 -0400)]
clone: die on errors from unpack_trees

When clone is populating the working tree, it ignores the
return status from unpack_trees; this means we may report a
successful clone, even when the checkout fails.

When checkout fails, we may want to leave the $GIT_DIR in
place, as it might be possible to recover the data through
further use of "git checkout" (e.g., if the checkout failed
due to a transient error, disk full, etc). However, we
already die on a number of other checkout-related errors, so
this patch follows that pattern.

In addition to marking a now-passing test, we need to adjust
t5710, which blindly assumed it could make bogus clones of
very deep alternates hierarchies. By using "--bare", we can
avoid it actually touching any objects.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoadd tests for cloning corrupted repositories
Jeff King [Mon, 25 Mar 2013 20:22:29 +0000 (16:22 -0400)]
add tests for cloning corrupted repositories

We try not to let corruption pass unnoticed over fetches and
clones. For the most part, this works, but there are some
broken corner cases, including:

  1. We do not detect missing objects over git-aware
     transports. This is a little hard to test, because the
     sending side will actually complain about the missing
     object.

     To fool it, we corrupt a repository such that we have a
     "misnamed" object: it claims to be sha1 X, but is
     really Y. This lets the sender blindly transmit it, but
     it is the receiver's responsibility to verify that what
     it got is sane (and it does not).

  2. We do not detect missing or misnamed blobs during the
     checkout phase of clone.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agostreaming_write_entry: propagate streaming errors
Jeff King [Mon, 25 Mar 2013 21:49:36 +0000 (17:49 -0400)]
streaming_write_entry: propagate streaming errors

When we are streaming an index blob to disk, we store the
error from stream_blob_to_fd in the "result" variable, and
then immediately overwrite that with the return value of
"close". That means we catch errors on close (e.g., problems
committing the file to disk), but miss anything which
happened before then.

We can fix this by using bitwise-OR to accumulate errors in
our result variable.

While we're here, we can also simplify the error handling
with an early return, which makes it easier to see under
which circumstances we need to clean up.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoadd test for streaming corrupt blobs
Jeff King [Mon, 25 Mar 2013 20:21:34 +0000 (16:21 -0400)]
add test for streaming corrupt blobs

We do not have many tests for handling corrupt objects. This
new test at least checks that we detect a byte error in a
corrupt blob object while streaming it out with cat-file.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoavoid infinite loop in read_istream_loose
Jeff King [Mon, 25 Mar 2013 20:21:14 +0000 (16:21 -0400)]
avoid infinite loop in read_istream_loose

The read_istream_loose function loops on inflating a chunk of data
from an mmap'd loose object. We end the loop when we run out
of space in our output buffer, or if we see a zlib error.

We need to treat Z_BUF_ERROR specially, though, as it is not
fatal; it is just zlib's way of telling us that we need to
either feed it more input or give it more output space. It
is perfectly normal for us to hit this when we are at the
end of our buffer.

However, we may also get Z_BUF_ERROR because we have run out
of input. In a well-formed object, this should not happen,
because we have fed the whole mmap'd contents to zlib. But
if the object is truncated or corrupt, we will loop forever,
never giving zlib any more data, but continuing to ask it to
inflate.

We can fix this by considering it an error when zlib returns
Z_BUF_ERROR but we still have output space left (which means
it must want more input, which we know is a truncation
error). It would not be sufficient to just check whether
zlib had consumed all the input at the start of the loop, as
it might still want to generate output from what is in its
internal state.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoread_istream_filtered: propagate read error from upstream
Jeff King [Mon, 25 Mar 2013 20:18:16 +0000 (16:18 -0400)]
read_istream_filtered: propagate read error from upstream

The filter istream pulls data from an "upstream" stream,
running it through a filter function. However, we did not
properly notice when the upstream filter yielded an error,
and just returned what we had read. Instead, we should
propagate the error.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agocheck_sha1_signature: check return value from read_istream
Jeff King [Mon, 25 Mar 2013 20:17:17 +0000 (16:17 -0400)]
check_sha1_signature: check return value from read_istream

It's possible for read_istream to return an error, in which
case we just end up in an infinite loop (aside from EOF, we
do not even look at the result, but just feed it straight
into our running hash).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agostream_blob_to_fd: detect errors reading from stream
Jeff King [Mon, 25 Mar 2013 20:16:50 +0000 (16:16 -0400)]
stream_blob_to_fd: detect errors reading from stream

We call read_istream, but never check its return value for
errors. This can lead to us looping infinitely, as we just
keep trying to write "-1" bytes (and we do not notice the
error, as we simply check that write_in_full reports the
same number of bytes we fed it, which of course is also -1).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoSecond wave of topics toward 1.8.3
Junio C Hamano [Mon, 25 Mar 2013 21:08:00 +0000 (14:08 -0700)]
Second wave of topics toward 1.8.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'jk/fully-peeled-packed-ref'
Junio C Hamano [Mon, 25 Mar 2013 21:01:07 +0000 (14:01 -0700)]
Merge branch 'jk/fully-peeled-packed-ref'

Not that we do not actively encourage having annotated tags outside
refs/tags/ hierarchy, but they were not advertised correctly to the
ls-remote and fetch with recent version of Git.

* jk/fully-peeled-packed-ref:
  pack-refs: add fully-peeled trait
  pack-refs: write peeled entry for non-tags
  use parse_object_or_die instead of die("bad object")
  avoid segfaults on parse_object failure

11 years agoMerge branch 'jk/fast-export-object-lookup'
Junio C Hamano [Mon, 25 Mar 2013 21:01:05 +0000 (14:01 -0700)]
Merge branch 'jk/fast-export-object-lookup'

* jk/fast-export-object-lookup:
  fast-export: do not load blob objects twice
  fast-export: rename handle_object function

11 years agoMerge branch 'jk/peel-ref'
Junio C Hamano [Mon, 25 Mar 2013 21:01:02 +0000 (14:01 -0700)]
Merge branch 'jk/peel-ref'

Recent optimization broke shallow clones.

* jk/peel-ref:
  upload-pack: load non-tip "want" objects from disk
  upload-pack: make sure "want" objects are parsed
  upload-pack: drop lookup-before-parse optimization

11 years agoMerge branch 'lf/setup-prefix-pathspec'
Junio C Hamano [Mon, 25 Mar 2013 21:01:00 +0000 (14:01 -0700)]
Merge branch 'lf/setup-prefix-pathspec'

"git cmd -- ':(top'" was not diagnosed as an invalid syntax, and
instead the parser kept reading beyond the end of the string.

* lf/setup-prefix-pathspec:
  setup.c: check that the pathspec magic ends with ")"
  setup.c: stop prefix_pathspec() from looping past the end of string

11 years agoMerge branch 'ph/tag-force-no-warn-on-creation'
Junio C Hamano [Mon, 25 Mar 2013 21:00:57 +0000 (14:00 -0700)]
Merge branch 'ph/tag-force-no-warn-on-creation'

"git tag -f <tag>" always said "Updated tag '<tag>'" even when
creating a new tag (i.e. not overwriting nor updating).

* ph/tag-force-no-warn-on-creation:
  tag: --force does not have to warn when creating tags

11 years agoMerge branch 'mg/unsigned-time-t'
Junio C Hamano [Mon, 25 Mar 2013 21:00:56 +0000 (14:00 -0700)]
Merge branch 'mg/unsigned-time-t'

A few workarounds for systems with unsigned time_t.

* mg/unsigned-time-t:
  Fix time offset calculation in case of unsigned time_t
  date.c: fix unsigned time_t comparison

11 years agoMerge branch 'jk/suppress-clang-warning'
Junio C Hamano [Mon, 25 Mar 2013 21:00:54 +0000 (14:00 -0700)]
Merge branch 'jk/suppress-clang-warning'

* jk/suppress-clang-warning:
  fix clang -Wtautological-compare with unsigned enum

11 years agoMerge branch 'pw/p4-symlinked-root'
Junio C Hamano [Mon, 25 Mar 2013 21:00:49 +0000 (14:00 -0700)]
Merge branch 'pw/p4-symlinked-root'

"git p4" did not behave well when the path to the root of the P4
client was not its real path.

* pw/p4-symlinked-root:
  git p4: avoid expanding client paths in chdir
  git p4 test: should honor symlink in p4 client root
  git p4 test: make sure P4CONFIG relative path works

11 years agoMerge branch 'jk/empty-archive'
Junio C Hamano [Mon, 25 Mar 2013 21:00:48 +0000 (14:00 -0700)]
Merge branch 'jk/empty-archive'

"git archive" reports a failure when asked to create an archive out
of an empty tree.  It would be more intuitive to give an empty
archive back in such a case.

* jk/empty-archive:
  archive: handle commits with an empty tree
  test-lib: factor out $GIT_UNZIP setup

11 years agoMerge branch 'ks/rfc2047-one-char-at-a-time'
Junio C Hamano [Mon, 25 Mar 2013 21:00:46 +0000 (14:00 -0700)]
Merge branch 'ks/rfc2047-one-char-at-a-time'

When "format-patch" quoted a non-ascii strings on the header files,
it incorrectly applied rfc2047 and chopped a single character in
the middle of it.

* ks/rfc2047-one-char-at-a-time:
  format-patch: RFC 2047 says multi-octet character may not be split

11 years agoMerge branch 'jk/alias-in-bare'
Junio C Hamano [Mon, 25 Mar 2013 21:00:44 +0000 (14:00 -0700)]
Merge branch 'jk/alias-in-bare'

An aliased command spawned from a bare repository that does not say
it is bare with "core.bare = yes" is treated as non-bare by mistake.

* jk/alias-in-bare:
  setup: suppress implicit "." work-tree for bare repos
  environment: add GIT_PREFIX to local_repo_env
  cache.h: drop LOCAL_REPO_ENV_SIZE

11 years agoMerge branch 'jc/push-follow-tag'
Junio C Hamano [Mon, 25 Mar 2013 21:00:40 +0000 (14:00 -0700)]
Merge branch 'jc/push-follow-tag'

The new "--follow-tags" option tells "git push" to push relevant
annotated tags when pushing branches out.

* jc/push-follow-tag:
  push: --follow-tags
  commit.c: use clear_commit_marks_many() in in_merge_bases_many()
  commit.c: add in_merge_bases_many()
  commit.c: add clear_commit_marks_many()

11 years agoMerge branch 'jc/maint-reflog-expire-clean-mark-typofix'
Junio C Hamano [Mon, 25 Mar 2013 21:00:39 +0000 (14:00 -0700)]
Merge branch 'jc/maint-reflog-expire-clean-mark-typofix'

In "git reflog expire", REACHABLE bit was not cleared from the
correct objects.

* jc/maint-reflog-expire-clean-mark-typofix:
  reflog: fix typo in "reflog expire" clean-up codepath

11 years agoMerge branch 'ap/maint-diff-rename-avoid-overlap'
Junio C Hamano [Mon, 25 Mar 2013 21:00:37 +0000 (14:00 -0700)]
Merge branch 'ap/maint-diff-rename-avoid-overlap'

The logic used by "git diff -M --stat" to shorten the names of
files before and after a rename did not work correctly when the
common prefix and suffix between the two filenames overlapped.

* ap/maint-diff-rename-avoid-overlap:
  tests: make sure rename pretty print works
  diff: prevent pprint_rename from underrunning input
  diff: Fix rename pretty-print when suffix and prefix overlap

11 years agoMerge branch 'jl/submodule-deinit'
Junio C Hamano [Mon, 25 Mar 2013 21:00:29 +0000 (14:00 -0700)]
Merge branch 'jl/submodule-deinit'

There was no Porcelain way to say "I no longer am interested in
this submodule", once you express your interest in a submodule with
"submodule init".  "submodule deinit" is the way to do so.

* jl/submodule-deinit:
  submodule: add 'deinit' command

11 years agoMerge branch 'jc/describe'
Junio C Hamano [Mon, 25 Mar 2013 21:00:23 +0000 (14:00 -0700)]
Merge branch 'jc/describe'

The "--match=<pattern>" option of "git describe", when used with
"--all" to allow refs that are not annotated tags to be used as a
base of description, did not restrict the output from the command
to those that match the given pattern.

We may want to have a looser matching that does not restrict to tags,
but that can be done as a follow-up topic; this step is purely a bugfix.

* jc/describe:
  describe: --match=<pattern> must limit the refs even when used with --all

11 years agoMerge branch 'pe/pull-rebase-v-q'
Junio C Hamano [Mon, 25 Mar 2013 20:58:34 +0000 (13:58 -0700)]
Merge branch 'pe/pull-rebase-v-q'

Teach "git pull --rebase" to pass "-v/-q" command line options to
underlying "git rebase".

* pe/pull-rebase-v-q:
  pull: Apply -q and -v options to rebase mode as well

11 years agoMerge branch 'maint'
Junio C Hamano [Mon, 25 Mar 2013 20:52:25 +0000 (13:52 -0700)]
Merge branch 'maint'

* maint:
  Start preparing for 1.8.2.1
  transport.c: help gcc 4.6.3 users by squelching compiler warning

11 years agoStart preparing for 1.8.2.1
Junio C Hamano [Mon, 25 Mar 2013 20:51:13 +0000 (13:51 -0700)]
Start preparing for 1.8.2.1

... at the same time, preparation for 1.8.1.6 also has started ;-)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'jk/graph-c-expose-symbols-for-cgit' into maint
Junio C Hamano [Mon, 25 Mar 2013 20:48:39 +0000 (13:48 -0700)]
Merge branch 'jk/graph-c-expose-symbols-for-cgit' into maint

In the v1.8.0 era, we changed symbols that do not have to be global
to file scope static, but a few functions in graph.c were used by
CGit from sideways bypassing the entry points of the API the
in-tree users use.

* jk/graph-c-expose-symbols-for-cgit:
  Revert "graph.c: mark private file-scope symbols as static"

11 years agoMerge branch 'maint-1.8.1' into maint
Junio C Hamano [Mon, 25 Mar 2013 20:46:42 +0000 (13:46 -0700)]
Merge branch 'maint-1.8.1' into maint

* maint-1.8.1:
  bundle: Add colons to list headings in "verify"
  bundle: Fix "verify" output if history is complete
  Documentation: filter-branch env-filter example
  git-filter-branch.txt: clarify ident variables usage
  git-compat-util.h: Provide missing netdb.h definitions
  describe: Document --match pattern format
  Documentation/githooks: Explain pre-rebase parameters
  update-index: list supported idx versions and their features
  diff-options: unconfuse description of --color
  read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr()
  index-format.txt: mention of v4 is missing in some places

11 years agoMerge branch 'lf/bundle-verify-list-prereqs' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:46:02 +0000 (13:46 -0700)]
Merge branch 'lf/bundle-verify-list-prereqs' into maint-1.8.1

"git bundle verify" did not say "records a complete history" for a
bundle that does not have any prerequisites.

* lf/bundle-verify-list-prereqs:
  bundle: Add colons to list headings in "verify"
  bundle: Fix "verify" output if history is complete

11 years agoMerge branch 'tk/doc-filter-branch' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:45:53 +0000 (13:45 -0700)]
Merge branch 'tk/doc-filter-branch' into maint-1.8.1

Add an example use of "--env-filter" in "filter-branch"
documentation.

* tk/doc-filter-branch:
  Documentation: filter-branch env-filter example
  git-filter-branch.txt: clarify ident variables usage

11 years agoMerge branch 'dm/ni-maxhost-may-be-missing' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:45:42 +0000 (13:45 -0700)]
Merge branch 'dm/ni-maxhost-may-be-missing' into maint-1.8.1

Some sources failed to compile on systems that lack NI_MAXHOST in
their system header.

* dm/ni-maxhost-may-be-missing:
  git-compat-util.h: Provide missing netdb.h definitions

11 years agoMerge branch 'gp/describe-match-uses-glob-pattern' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:45:33 +0000 (13:45 -0700)]
Merge branch 'gp/describe-match-uses-glob-pattern' into maint-1.8.1

The "--match=<pattern>" argument "git describe" takes uses glob
pattern but it wasn't obvious from the documentation.

* gp/describe-match-uses-glob-pattern:
  describe: Document --match pattern format

11 years agoMerge branch 'nd/doc-index-format' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:45:26 +0000 (13:45 -0700)]
Merge branch 'nd/doc-index-format' into maint-1.8.1

The v4 index format was not documented.

* nd/doc-index-format:
  update-index: list supported idx versions and their features
  read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr()
  index-format.txt: mention of v4 is missing in some places

11 years agoMerge branch 'wk/doc-pre-rebase' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:45:14 +0000 (13:45 -0700)]
Merge branch 'wk/doc-pre-rebase' into maint-1.8.1

The arguments given to pre-rebase hook were not documented.

* wk/doc-pre-rebase:
  Documentation/githooks: Explain pre-rebase parameters

11 years agoMerge branch 'jc/color-diff-doc' into maint-1.8.1
Junio C Hamano [Mon, 25 Mar 2013 20:44:53 +0000 (13:44 -0700)]
Merge branch 'jc/color-diff-doc' into maint-1.8.1

The "--color=<when>" argument to the commands in the diff family
was described poorly.

* jc/color-diff-doc:
  diff-options: unconfuse description of --color

11 years agotransport.c: help gcc 4.6.3 users by squelching compiler warning
Junio C Hamano [Mon, 25 Mar 2013 19:51:50 +0000 (12:51 -0700)]
transport.c: help gcc 4.6.3 users by squelching compiler warning

To a human reader, it is quite obvious that cmp is assigned before
it is used, but gcc 4.6.3 that ships with Ubuntu 12.04 is among
those that do not get this right.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoUpdate draft release notes to 1.8.3
Junio C Hamano [Thu, 21 Mar 2013 22:29:42 +0000 (15:29 -0700)]
Update draft release notes to 1.8.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'maint'
Junio C Hamano [Thu, 21 Mar 2013 21:06:55 +0000 (14:06 -0700)]
Merge branch 'maint'

* maint:
  diff.c: diff.renamelimit => diff.renameLimit in message
  wt-status: fix possible use of uninitialized variable
  fast-import: clarify "inline" logic in file_change_m
  run-command: always set failed_errno in start_command
  transport: drop "int cmp = cmp" hack
  drop some obsolete "x = x" compiler warning hacks
  fast-import: use pointer-to-pointer to keep list tail

11 years agodiff.c: diff.renamelimit => diff.renameLimit in message
Max Nanasy [Thu, 21 Mar 2013 19:53:38 +0000 (12:53 -0700)]
diff.c: diff.renamelimit => diff.renameLimit in message

In the warning message printed when rename or unmodified copy
detection was skipped due to too many files, change "diff.renamelimit"
to "diff.renameLimit", in order to make it consistent with git
documentation, which consistently uses "diff.renameLimit".

Signed-off-by: Max Nanasy <max.nanasy@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agowt-status: fix possible use of uninitialized variable
Jeff King [Thu, 21 Mar 2013 11:05:28 +0000 (07:05 -0400)]
wt-status: fix possible use of uninitialized variable

In wt_status_print_change_data, we accept a change_type flag
that is meant to be either WT_STATUS_UPDATED or
WT_STATUS_CHANGED.  We then switch() on this value to set
the local variable "status" for each case, but do not
provide a fallback "default" label to the switch statement.

As a result, the compiler realizes that "status" might be
unset, and complains with a warning. To silence this
warning, we use the "int status = status" trick.  This is
correct with the current code, as all callers provide one of
the two expected change_type flags. However, it's also a
maintenance trap, as there is nothing to prevent future
callers from passing another flag, nor to document this
assumption.

Instead of using the "x = x" hack, let's handle the default
case in the switch() statement with a die("BUG"). That tells
the compiler and any readers of the code exactly what the
function's input assumptions are.

We could also convert the flag to an enum, which would
provide a compile-time check on the function input. However,
since these flags are part of a larger enum, that would make
the code unnecessarily complex (we would have to make a new
enum with just the two flags, and then convert it to the old
enum for passing to sub-functions).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofast-import: clarify "inline" logic in file_change_m
Jeff King [Thu, 21 Mar 2013 15:44:39 +0000 (11:44 -0400)]
fast-import: clarify "inline" logic in file_change_m

When we read a fast-import line like:

  M 100644 :1 foo.c

we point the local object_entry variable "oe" to the object
named by the mark ":1". When the input uses the "inline"
construct, however, we do not have such an object_entry.

The current code is careful not to access "oe" in the inline
case, but we can make the assumption even more obvious (and
catch violations of it) by setting oe to NULL and adding a
comment. As a bonus, this also squelches an over-zealous gcc
-Wuninitialized warning, which means we can drop the "oe =
oe" initialization hack.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agorun-command: always set failed_errno in start_command
Jeff King [Thu, 21 Mar 2013 15:45:00 +0000 (11:45 -0400)]
run-command: always set failed_errno in start_command

When we fail to fork, we set the failed_errno variable to
the value of errno so it is not clobbered by later syscalls.
However, we do so in a conditional, and it is hard to see
later under what conditions the variable has a valid value.

Instead of setting it only when fork fails, let's just
always set it after forking. This is more obvious for human
readers (as we are no longer setting it as a side effect of
a strerror call), and it is more obvious to gcc, which no
longer generates a spurious -Wuninitialized warning. It also
happens to match what the WIN32 half of the #ifdef does.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agotransport: drop "int cmp = cmp" hack
Jeff King [Thu, 21 Mar 2013 11:13:33 +0000 (07:13 -0400)]
transport: drop "int cmp = cmp" hack

According to 47ec794, this initialization is meant to
squelch an erroneous uninitialized variable warning from gcc
4.0.1.  That version is quite old at this point, and gcc 4.1
and up handle it fine, with one exception. There seems to be
a regression in gcc 4.6.3, which produces the warning;
however, gcc versions 4.4.7 and 4.7.2 do not.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agodrop some obsolete "x = x" compiler warning hacks
Jeff King [Thu, 21 Mar 2013 11:10:28 +0000 (07:10 -0400)]
drop some obsolete "x = x" compiler warning hacks

In cases where the setting and access of a variable are
protected by the same conditional flag, older versions of
gcc would generate a "might be used unitialized" warning. We
silence the warning by initializing the variable to itself,
a hack that gcc recognizes.

Modern versions of gcc are smart enough to get this right,
going back to at least version 4.3.5. gcc 4.1 does get it
wrong in both cases, but is sufficiently old that we
probably don't need to care about it anymore.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofast-import: use pointer-to-pointer to keep list tail
Jeff King [Thu, 21 Mar 2013 11:08:17 +0000 (07:08 -0400)]
fast-import: use pointer-to-pointer to keep list tail

This is shorter, idiomatic, and it means the compiler does
not get confused about whether our "e" pointer is valid,
letting us drop the "e = e" hack.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'we/submodule-update-prefix-output'
Junio C Hamano [Thu, 21 Mar 2013 21:03:10 +0000 (14:03 -0700)]
Merge branch 'we/submodule-update-prefix-output'

"git submodule update", when recursed into sub-submodules, did not
acccumulate the prefix paths.

* we/submodule-update-prefix-output:
  submodule update: when using recursion, show full path

11 years agoMerge branch 'jk/mailsplit-maildir-muttsort'
Junio C Hamano [Thu, 21 Mar 2013 21:03:08 +0000 (14:03 -0700)]
Merge branch 'jk/mailsplit-maildir-muttsort'

Sort filenames read from the maildir/ in a way that is more likely
to sort messages in the order the writing MUA meant to, by sorting
numeric segment in numeric order and non-numeric segment in
alphabetical order.

* jk/mailsplit-maildir-muttsort:
  mailsplit: sort maildir filenames more cleverly

11 years agoMerge branch 'rs/zip-compresssed-size-with-export-subst'
Junio C Hamano [Thu, 21 Mar 2013 21:03:04 +0000 (14:03 -0700)]
Merge branch 'rs/zip-compresssed-size-with-export-subst'

When export-subst is used, "zip" output recorded incorrect
size of the file.

* rs/zip-compresssed-size-with-export-subst:
  archive-zip: fix compressed size for stored export-subst files

11 years agoMerge branch 'mn/send-email-works-with-credential'
Junio C Hamano [Thu, 21 Mar 2013 21:03:02 +0000 (14:03 -0700)]
Merge branch 'mn/send-email-works-with-credential'

Hooks the credential system to send-email.

* mn/send-email-works-with-credential:
  git-send-email: use git credential to obtain password
  Git.pm: add interface for git credential command
  Git.pm: allow pipes to be closed prior to calling command_close_bidi_pipe
  Git.pm: refactor command_close_bidi_pipe to use _cmd_close
  Git.pm: fix example in command_close_bidi_pipe documentation
  Git.pm: allow command_close_bidi_pipe to be called as method

11 years agoMerge branch 'tz/credential-authinfo'
Junio C Hamano [Thu, 21 Mar 2013 21:03:00 +0000 (14:03 -0700)]
Merge branch 'tz/credential-authinfo'

A new read-only credential helper (in contrib/) to interact with
the .netrc/.authinfo files.  Hopefully mn/send-email-authinfo topic
can rebuild on top of something like this.

* tz/credential-authinfo:
  Add contrib/credentials/netrc with GPG support

11 years agoMerge branch 'jk/utf-8-can-be-spelled-differently'
Junio C Hamano [Thu, 21 Mar 2013 21:02:58 +0000 (14:02 -0700)]
Merge branch 'jk/utf-8-can-be-spelled-differently'

Some platforms and users spell UTF-8 differently; retry with the
most official "UTF-8" when the system does not understand the
user-supplied encoding name that are the common alternative
spellings of UTF-8.

* jk/utf-8-can-be-spelled-differently:
  utf8: accept alternate spellings of UTF-8

11 years agoMerge branch 'mg/gpg-interface-using-status'
Junio C Hamano [Thu, 21 Mar 2013 21:02:55 +0000 (14:02 -0700)]
Merge branch 'mg/gpg-interface-using-status'

Call "gpg" using the right API when validating the signature on
tags.

* mg/gpg-interface-using-status:
  pretty: make %GK output the signing key for signed commits
  pretty: parse the gpg status lines rather than the output
  gpg_interface: allow to request status return
  log-tree: rely upon the check in the gpg_interface
  gpg-interface: check good signature in a reliable way

11 years agoMerge branch 'rt/commit-cleanup-config'
Junio C Hamano [Thu, 21 Mar 2013 21:02:53 +0000 (14:02 -0700)]
Merge branch 'rt/commit-cleanup-config'

Fix tests that contaminated their environments and affected new
tests introduced later in the sequence by containing their effects
in their own subshells.

* rt/commit-cleanup-config:
  t7502: perform commits using alternate editor in a subshell

11 years agoMerge branch 'nd/branch-error-cases'
Junio C Hamano [Thu, 21 Mar 2013 21:02:51 +0000 (14:02 -0700)]
Merge branch 'nd/branch-error-cases'

"git branch" had more cases where it did not bother to check
nonsense command line parameters.

* nd/branch-error-cases:
  branch: segfault fixes and validation

11 years agoMerge branch 'ap/maint-update-index-h-is-for-help'
Junio C Hamano [Thu, 21 Mar 2013 21:02:48 +0000 (14:02 -0700)]
Merge branch 'ap/maint-update-index-h-is-for-help'

"git update-index -h" did not do the usual "-h(elp)" thing.

* ap/maint-update-index-h-is-for-help:
  update-index: allow "-h" to also display options

11 years agoMerge branch 'jc/perl-cat-blob'
Junio C Hamano [Thu, 21 Mar 2013 21:02:46 +0000 (14:02 -0700)]
Merge branch 'jc/perl-cat-blob'

perl/Git.pm::cat_blob slurped everything in core only to write it
out to a file descriptor, which was not a very smart thing to do.

* jc/perl-cat-blob:
  Git.pm: fix cat_blob crashes on large files

11 years agoMerge branch 'da/difftool-fixes'
Junio C Hamano [Thu, 21 Mar 2013 21:02:43 +0000 (14:02 -0700)]
Merge branch 'da/difftool-fixes'

Minor maintenance updates to difftool, and updates to its tests.

* da/difftool-fixes:
  t7800: "defaults" is no longer a builtin tool name
  t7800: modernize tests
  t7800: update copyright notice
  difftool: silence uninitialized variable warning

11 years agoMerge branch 'ob/imap-send-ssl-verify'
Junio C Hamano [Thu, 21 Mar 2013 21:02:39 +0000 (14:02 -0700)]
Merge branch 'ob/imap-send-ssl-verify'

Correctly connect to SSL/TLS sites that serve multiple hostnames on
a single IP by including Server Name Indication in the client-hello.

* ob/imap-send-ssl-verify:
  imap-send: support Server Name Indication (RFC4366)

11 years agoMerge branch 'bc/commit-complete-lines-given-via-m-option'
Junio C Hamano [Thu, 21 Mar 2013 21:02:37 +0000 (14:02 -0700)]
Merge branch 'bc/commit-complete-lines-given-via-m-option'

'git commit -m "$str"' when $str was already terminated with a LF
now avoids adding an extra LF to the message.

* bc/commit-complete-lines-given-via-m-option:
  Documentation/git-commit.txt: rework the --cleanup section
  git-commit: only append a newline to -m mesg if necessary
  t7502: demonstrate breakage with a commit message with trailing newlines
  t/t7502: compare entire commit message with what was expected

11 years agoMerge branch 'nd/count-garbage'
Junio C Hamano [Thu, 21 Mar 2013 21:02:34 +0000 (14:02 -0700)]
Merge branch 'nd/count-garbage'

"git count-objects -v" did not count leftover temporary packfiles
and other kinds of garbage.

* nd/count-garbage:
  count-objects: report how much disk space taken by garbage files
  count-objects: report garbage files in pack directory too
  sha1_file: reorder code in prepare_packed_git_one()
  git-count-objects.txt: describe each line in -v output

11 years agoMerge branch 'jc/fetch-raw-sha1'
Junio C Hamano [Thu, 21 Mar 2013 21:02:27 +0000 (14:02 -0700)]
Merge branch 'jc/fetch-raw-sha1'

Allows requests to fetch objects at any tip of refs (including
hidden ones).  It seems that there may be use cases even outside
Gerrit (e.g. $gmane/215701).

* jc/fetch-raw-sha1:
  fetch: fetch objects by their exact SHA-1 object names
  upload-pack: optionally allow fetching from the tips of hidden refs
  fetch: use struct ref to represent refs to be fetched
  parse_fetch_refspec(): clarify the codeflow a bit

11 years agoMerge branch 'nd/preallocate-hash'
Junio C Hamano [Thu, 21 Mar 2013 21:02:19 +0000 (14:02 -0700)]
Merge branch 'nd/preallocate-hash'

When we know approximately how many entries we will have in the
hash-table, it makes sense to size the hash table to that number
from the beginning to avoid unnecessary rehashing.

* nd/preallocate-hash:
  Preallocate hash tables when the number of inserts are known in advance

11 years agoMerge branch 'nd/index-pack-l10n-buf-overflow'
Junio C Hamano [Thu, 21 Mar 2013 21:02:16 +0000 (14:02 -0700)]
Merge branch 'nd/index-pack-l10n-buf-overflow'

* nd/index-pack-l10n-buf-overflow:
  index-pack: fix buffer overflow caused by translations

11 years agoMerge branch 'tb/document-status-u-tradeoff'
Junio C Hamano [Thu, 21 Mar 2013 21:02:10 +0000 (14:02 -0700)]
Merge branch 'tb/document-status-u-tradeoff'

Suggest users to look into using--untracked=no option when "git
status" takes too long.

* tb/document-status-u-tradeoff:
  status: advise to consider use of -u when read_directory takes too long
  git status: document trade-offs in choosing parameters to the -u option

11 years agoMerge branch 'jn/shell-disable-interactive'
Junio C Hamano [Thu, 21 Mar 2013 21:01:53 +0000 (14:01 -0700)]
Merge branch 'jn/shell-disable-interactive'

When the interactive access to git-shell is not enabled, we issue a
message meant to help the system admininstrator to enable it. Add
an explicit way to help the end users who connect to the service by
issuing custom messages to refuse such an access.

* jn/shell-disable-interactive:
  shell: new no-interactive-login command to print a custom message
  shell doc: emphasize purpose and security model

11 years agoMerge branch 'jc/maint-push-refspec-default-doc'
Junio C Hamano [Thu, 21 Mar 2013 21:01:47 +0000 (14:01 -0700)]
Merge branch 'jc/maint-push-refspec-default-doc'

Clarify in the documentation "what" gets pushed to "where" when the
command line to "git push" does not say these explicitly.

* jc/maint-push-refspec-default-doc:
  Documentation/git-push: clarify the description of defaults

11 years agoThe first wave of topics for 1.8.3
Junio C Hamano [Tue, 19 Mar 2013 19:30:25 +0000 (12:30 -0700)]
The first wave of topics for 1.8.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'jc/add-2.0-u-A-sans-pathspec' (early part)
Junio C Hamano [Tue, 19 Mar 2013 19:21:27 +0000 (12:21 -0700)]
Merge branch 'jc/add-2.0-u-A-sans-pathspec' (early part)

* 'jc/add-2.0-u-A-sans-pathspec' (early part):
  t2200: check that "add -u" limits itself to subdirectory

11 years agoMerge branch 'lf/bundle-verify-list-prereqs'
Junio C Hamano [Tue, 19 Mar 2013 19:21:09 +0000 (12:21 -0700)]
Merge branch 'lf/bundle-verify-list-prereqs'

* lf/bundle-verify-list-prereqs:
  bundle: Add colons to list headings in "verify"
  bundle: Fix "verify" output if history is complete

11 years agoMerge branch 'jk/graph-c-expose-symbols-for-cgit'
Junio C Hamano [Tue, 19 Mar 2013 19:20:56 +0000 (12:20 -0700)]
Merge branch 'jk/graph-c-expose-symbols-for-cgit'

In the v1.8.0 era, we changed symbols that do not have to be global
to file scope static, but a few functions in graph.c were used by
CGit from sideways bypassing the entry points of the API the
in-tree users use.

* jk/graph-c-expose-symbols-for-cgit:
  Revert "graph.c: mark private file-scope symbols as static"

11 years agoMerge branch 'tk/doc-filter-branch'
Junio C Hamano [Tue, 19 Mar 2013 19:20:50 +0000 (12:20 -0700)]
Merge branch 'tk/doc-filter-branch'

* tk/doc-filter-branch:
  Documentation: filter-branch env-filter example
  git-filter-branch.txt: clarify ident variables usage

11 years agoMerge branch 'wk/user-manual-literal-format'
Junio C Hamano [Tue, 19 Mar 2013 19:20:44 +0000 (12:20 -0700)]
Merge branch 'wk/user-manual-literal-format'

* wk/user-manual-literal-format:
  user-manual: Standardize backtick quoting

11 years agoMerge branch 'rj/msvc-build'
Junio C Hamano [Tue, 19 Mar 2013 19:20:40 +0000 (12:20 -0700)]
Merge branch 'rj/msvc-build'

* rj/msvc-build:
  msvc: avoid collisions between "tags" and "TAGS"
  msvc: test-svn-fe: Fix linker "unresolved external" error
  msvc: Fix build by adding missing symbol defines
  msvc: git-daemon: Fix linker "unresolved external" errors
  msvc: Fix compilation errors caused by poll.h emulation

11 years agoMerge branch 'dm/ni-maxhost-may-be-missing'
Junio C Hamano [Tue, 19 Mar 2013 19:18:21 +0000 (12:18 -0700)]
Merge branch 'dm/ni-maxhost-may-be-missing'

On systems without NI_MAXHOST in their system header files,
connect.c (hence most of the transport) did not compile.

* dm/ni-maxhost-may-be-missing:
  git-compat-util.h: Provide missing netdb.h definitions

11 years agoMerge branch 'gp/describe-match-uses-glob-pattern'
Junio C Hamano [Tue, 19 Mar 2013 19:16:31 +0000 (12:16 -0700)]
Merge branch 'gp/describe-match-uses-glob-pattern'

The syntax of the pattern given to the "--match=<pattern>" argument
to "git describe" was not documented to be a glob.

* gp/describe-match-uses-glob-pattern:
  describe: Document --match pattern format

11 years agoMerge branch 'gp/avoid-explicit-mention-of-dot-git-refs'
Junio C Hamano [Tue, 19 Mar 2013 19:16:22 +0000 (12:16 -0700)]
Merge branch 'gp/avoid-explicit-mention-of-dot-git-refs'

* gp/avoid-explicit-mention-of-dot-git-refs:
  Fix ".git/refs" stragglers

11 years agoMerge branch 'da/downcase-u-in-usage'
Junio C Hamano [Tue, 19 Mar 2013 19:15:54 +0000 (12:15 -0700)]
Merge branch 'da/downcase-u-in-usage'

* da/downcase-u-in-usage:
  contrib/mw-to-git/t/install-wiki.sh: use a lowercase "usage:" string
  contrib/examples/git-remote.perl: use a lowercase "usage:" string
  tests: use a lowercase "usage:" string
  git-svn: use a lowercase "usage:" string
  Documentation/user-manual.txt: use a lowercase "usage:" string
  templates/hooks--update.sample: use a lowercase "usage:" string
  contrib/hooks/setgitperms.perl: use a lowercase "usage:" string
  contrib/examples: use a lowercase "usage:" string
  contrib/fast-import/import-zips.py: use spaces instead of tabs
  contrib/fast-import/import-zips.py: fix broken error message
  contrib/fast-import: use a lowercase "usage:" string
  contrib/credential: use a lowercase "usage:" string
  git-cvsimport: use a lowercase "usage:" string
  git-cvsimport: use a lowercase "usage:" string
  git-cvsexportcommit: use a lowercase "usage:" string
  git-archimport: use a lowercase "usage:" string
  git-merge-one-file: use a lowercase "usage:" string
  git-relink: use a lowercase "usage:" string
  git-svn: use a lowercase "usage:" string
  git-sh-setup: use a lowercase "usage:" string

11 years agoMerge branch 'nd/doc-index-format'
Junio C Hamano [Tue, 19 Mar 2013 19:15:14 +0000 (12:15 -0700)]
Merge branch 'nd/doc-index-format'

Update the index format documentation to mention the v4 format.

* nd/doc-index-format:
  update-index: list supported idx versions and their features
  read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr()
  index-format.txt: mention of v4 is missing in some places

11 years agoMerge branch 'wk/doc-pre-rebase'
Junio C Hamano [Tue, 19 Mar 2013 19:14:05 +0000 (12:14 -0700)]
Merge branch 'wk/doc-pre-rebase'

* wk/doc-pre-rebase:
  Documentation/githooks: Explain pre-rebase parameters

11 years agoMerge branch 'jc/color-diff-doc'
Junio C Hamano [Tue, 19 Mar 2013 19:11:31 +0000 (12:11 -0700)]
Merge branch 'jc/color-diff-doc'

The --color[=<when>] option to the diff family was documented in a
confusing way.

* jc/color-diff-doc:
  diff-options: unconfuse description of --color

11 years agoStart the post 1.8.2 cycle
Junio C Hamano [Mon, 18 Mar 2013 22:01:19 +0000 (15:01 -0700)]
Start the post 1.8.2 cycle

Again, tentatively let's call this cycle 1.8.3.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agopack-refs: add fully-peeled trait
Michael Haggerty [Mon, 18 Mar 2013 11:37:32 +0000 (07:37 -0400)]
pack-refs: add fully-peeled trait

Older versions of pack-refs did not write peel lines for
refs outside of refs/tags. This meant that on reading the
pack-refs file, we might set the REF_KNOWS_PEELED flag for
such a ref, even though we do not know anything about its
peeled value.

The previous commit updated the writer to always peel, no
matter what the ref is. That means that packed-refs files
written by newer versions of git are fine to be read by both
old and new versions of git. However, we still have the
problem of reading packed-refs files written by older
versions of git, or by other implementations which have not
yet learned the same trick.

The simplest fix would be to always unset the
REF_KNOWS_PEELED flag for refs outside of refs/tags that do
not have a peel line (if it has a peel line, we know it is
valid, but we cannot assume a missing peel line means
anything). But that loses an important optimization, as
upload-pack should not need to load the object pointed to by
refs/heads/foo to determine that it is not a tag.

Instead, we add a "fully-peeled" trait to the packed-refs
file. If it is set, we know that we can trust a missing peel
line to mean that a ref cannot be peeled. Otherwise, we fall
back to assuming nothing.

[commit message and tests by Jeff King <peff@peff.net>]

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'maint'
Junio C Hamano [Sun, 17 Mar 2013 22:39:43 +0000 (15:39 -0700)]
Merge branch 'maint'

* maint:
  t1507: Test that branchname@{upstream} is interpreted as branch

11 years agot1507: Test that branchname@{upstream} is interpreted as branch
Kacper Kornet [Sun, 17 Mar 2013 22:17:09 +0000 (23:17 +0100)]
t1507: Test that branchname@{upstream} is interpreted as branch

Syntax branchname@{upstream} should interpret its argument as a name of
a branch. Add the test to check that it doesn't try to interpret it as a
refname if the branch in question does not exist.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofast-export: do not load blob objects twice
Jeff King [Sun, 17 Mar 2013 08:38:57 +0000 (04:38 -0400)]
fast-export: do not load blob objects twice

When fast-export wants to export a blob object, it first
calls parse_object to get a "struct object" and check
whether we have already shown the object.  If we haven't
shown it, we then use read_sha1_file to pull it from disk
and write it out.

That means we load each blob from disk twice: once for
parse_object to find its type and check its sha1, and a
second time when we actually output it. We can drop this to
a single load by using lookup_object to check the SHOWN
flag, and then checking the signature on and outputting a
single buffer.

This provides modest speedups on git.git (best-of-five, "git
fast-export HEAD >/dev/null"):

  [before]                [after]
  real    0m14.347s       real    0m13.780s
  user    0m14.084s       user    0m13.620s
  sys     0m0.208s        sys     0m0.100s

and somewhat more on more blob-heavy repos (this is a
repository full of media files):

  [before]                [after]
  real    0m52.236s       real    0m44.451s
  user    0m50.568s       user    0m43.000s
  sys     0m1.536s        sys     0m1.284s

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofast-export: rename handle_object function
Jeff King [Sun, 17 Mar 2013 08:33:12 +0000 (04:33 -0400)]
fast-export: rename handle_object function

The handle_object function is rather vaguely named; it only
operates on blobs, and its purpose is to export the blob to
the output stream. Let's call it "export_blob" to make it
more clear what it does.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agopack-refs: write peeled entry for non-tags
Jeff King [Sun, 17 Mar 2013 08:23:46 +0000 (04:23 -0400)]
pack-refs: write peeled entry for non-tags

When we pack an annotated tag ref, we write not only the
sha1 of the tag object along with the ref, but also the sha1
obtained by peeling the tag. This lets readers of the
pack-refs file know the peeled value without having to
actually load the object, speeding up upload-pack's ref
advertisement.

The writer marks a packed-refs file with peeled refs using
the "peeled" trait at the top of the file. When the reader
sees this trait, it knows that each ref is either followed
by its peeled value, or it is not an annotated tag.

However, there is a mismatch between the assumptions of the
reader and writer. The writer will only peel refs under
refs/tags, but the reader does not know this; it will assume
a ref without a peeled value must not be a tag object. Thus
an annotated tag object placed outside of the refs/tags
hierarchy will not have its peeled value printed by
upload-pack.

The simplest way to fix this is to start writing peel values
for all refs. This matches what the reader expects for both
new and old versions of git.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agouse parse_object_or_die instead of die("bad object")
Jeff King [Sun, 17 Mar 2013 08:23:31 +0000 (04:23 -0400)]
use parse_object_or_die instead of die("bad object")

Some call-sites do:

  o = parse_object(sha1);
  if (!o)
  die("bad object %s", some_name);

We can now handle that as a one-liner, and get more
consistent output.

In the third case of this patch, it looks like we are losing
information, as the existing message also outputs the sha1
hex; however, parse_object will already have written a more
specific complaint about the sha1, so there is no point in
repeating it here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoavoid segfaults on parse_object failure
Jeff King [Sun, 17 Mar 2013 08:22:36 +0000 (04:22 -0400)]
avoid segfaults on parse_object failure

Many call-sites of parse_object assume that they will get a
non-NULL return value; this is not the case if we encounter
an error while parsing the object.

This patch adds a wrapper function around parse_object that
handles dying automatically, and uses it anywhere we
immediately try to access the return value as a non-NULL
pointer (i.e., anywhere that we would currently segfault).

This wrapper may also be useful in other places. The most
obvious one is code like:

  o = parse_object(sha1);
  if (!o)
  die(...);

However, these should not be mechanically converted to
parse_object_or_die, as the die message is sometimes
customized. Later patches can address these sites on a
case-by-case basis.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'maint'
Junio C Hamano [Sun, 17 Mar 2013 07:11:11 +0000 (00:11 -0700)]
Merge branch 'maint'

* maint:
  rev-parse: clarify documentation of $name@{upstream} syntax
  sha1_name: pass object name length to diagnose_invalid_sha1_path()
  Makefile: keep LIB_H entries together and sorted

11 years agorev-parse: clarify documentation of $name@{upstream} syntax
Kacper Kornet [Sat, 16 Mar 2013 18:51:43 +0000 (19:51 +0100)]
rev-parse: clarify documentation of $name@{upstream} syntax

"git rev-parse" interprets string in string@{upstream} as a name of
a branch not a ref. For example, refs/heads/master@{upstream} looks
for an upstream branch that is merged by git-pull to ref
refs/heads/refs/heads/master not to refs/heads/master.

However the documentation could mislead a user to believe that the
string is interpreted as ref.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agosha1_name: pass object name length to diagnose_invalid_sha1_path()
René Scharfe [Sat, 16 Mar 2013 18:29:31 +0000 (19:29 +0100)]
sha1_name: pass object name length to diagnose_invalid_sha1_path()

The only caller of diagnose_invalid_sha1_path() extracts a substring from
an object name by creating a NUL-terminated copy of the interesting part.
Add a length parameter to the function and thus avoid the need for an
allocation, thereby simplifying the code.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agopull: Apply -q and -v options to rebase mode as well
Peter Eisentraut [Fri, 15 Mar 2013 02:26:08 +0000 (22:26 -0400)]
pull: Apply -q and -v options to rebase mode as well

git pull passed -q and -v only to git merge, but they can be useful for
git rebase as well, so pass them there, too.

In particular, using -q shuts up the "Already up-to-date." message.
Especially, a new test script runs the same "pull --rebase" twice to
make sure both cases are quiet, when it has something to fetch and
when it is already up to date.

Signed-off-by: Peter Eisentraut <peter@eisentraut.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoPreallocate hash tables when the number of inserts are known in advance
Nguyễn Thái Ngọc Duy [Sun, 17 Mar 2013 03:28:06 +0000 (10:28 +0700)]
Preallocate hash tables when the number of inserts are known in advance

This avoids unnecessary re-allocations and reinsertions. On webkit.git
(i.e. about 182k inserts to the name hash table), this reduces about
100ms out of 3s user time.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMakefile: keep LIB_H entries together and sorted
René Scharfe [Sat, 16 Mar 2013 15:58:28 +0000 (16:58 +0100)]
Makefile: keep LIB_H entries together and sorted

As a follow-up to 60d24dd25 (Makefile: fold XDIFF_H and VCSSVN_H into
LIB_H), let the unconditional additions to LIB_H form a single sorted
list.  Also drop the duplicate entry for xdiff/xdiff.h, which was easy
to spot after sorting.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoupload-pack: load non-tip "want" objects from disk
Jeff King [Sat, 16 Mar 2013 10:28:30 +0000 (06:28 -0400)]
upload-pack: load non-tip "want" objects from disk

It is a long-time security feature that upload-pack will not
serve any "want" lines that do not correspond to the tip of
one of our refs. Traditionally, this was enforced by
checking the objects in the in-memory hash; they should have
been loaded and received the OUR_REF flag during the
advertisement.

The stateless-rpc mode, however, has a race condition here:
one process advertises, and another receives the want lines,
so the refs may have changed in the interim.  To address
this, commit 051e400 added a new verification mode; if the
object is not OUR_REF, we set a "has_non_tip" flag, and then
later verify that the requested objects are reachable from
our current tips.

However, we still die immediately when the object is not in
our in-memory hash, and at this point we should only have
loaded our tip objects. So the check_non_tip code path does
not ever actually trigger, as any non-tip objects would
have already caused us to die.

We can fix that by using parse_object instead of
lookup_object, which will load the object from disk if it
has not already been loaded.

We still need to check that parse_object does not return
NULL, though, as it is possible we do not have the object
at all. A more appropriate error message would be "no such
object" rather than "not our ref"; however, we do not want
to leak information about what objects are or are not in
the object database, so we continue to use the same "not
our ref" message that would be produced by an unreachable
object.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>