Commit graph

37074 commits

Author SHA1 Message Date
Jeff King f0e802ca20 t5539: update a flaky test
The test creates some unrelated commits in two separate repositories,
and then fetches from one to the other. Since the commit creation
happens in a subshell, the first commit in each ends up with the
same test_tick value. When fetch-pack looks at the two root commits
"unrelated1" and "new-too", the exact sequence of ACKs is different
depending on which one it pulls out of the queue first.

With the current code, it happens to be "unrelated1" (though this is not
at all guaranteed by the prio_queue data structure, it is deterministic
for this particular sequence of input). We see the ready-ACK, and the
test succeeds.

With the stable queue, we reliably get "new-too" out (since it is our
local tip, it is added to the queue before we even talk to the remote).
We never see a ready-ACK, and the test fails due to the grep on the
TRACE_PACKET output at the end (the fetch itself succeeds as expected).

I'm really not quite clear on what's supposed to be going on in the
test. I can make it pass with this change.
2014-07-15 11:27:08 -07:00
Jeff King 73f43f220f paint_down_to_common: use prio_queue
When we are traversing to find merge bases, we keep our
usual commit_list of commits to process, sorted by their
commit timestamp. As we add each parent to the list, we have
to spend "O(width of history)" to do the insertion, where
the width of history is the number of simultaneous lines of
development.

If we instead use a heap-based priority queue, we can do
these insertions in "O(log width)" time. This provides minor
speedups to merge-base calculations (timings in linux.git,
warm cache, best-of-five):

  [before]
  $ git merge-base HEAD v2.6.12
  real    0m3.251s
  user    0m3.148s
  sys     0m0.104s

  [after]
  $ git merge-base HEAD v2.6.12
  real    0m3.234s
  user    0m3.108s
  sys     0m0.128s

That's only an 0.5% speedup, but it does help protect us
against pathological cases.

While we are munging the "interesting" function, we also
take the opportunity to give it a more descriptive name, and
convert the return value to an int (we returned the first
interesting commit, but nobody ever looked at it).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-15 11:02:56 -07:00
Jeff King e8f91e3df8 prio-queue: make output stable with respect to insertion
If two items are added to a prio_queue and compare equal,
they currently come out in an apparently random order (this
order is deterministic for a particular sequence of
insertions and removals, but does not necessarily match the
insertion order). This makes it unlike using a date-ordered
commit_list, which is one of the main types we would like to
replace with it (because prio_queue does not suffer from
O(n) insertions).

We can make the priority queue stable by keeping an
insertion counter for each element, and using it to break
ties. This does increase the memory usage of the structure
(one int per element), but in practice it does not seem to
affect runtime. A best-of-five "git rev-list --topo-order"
on linux.git showed less than 1% difference (well within the
run-to-run noise).

In an ideal world, we would offer both stable and unstable
priority queues (the latter to try to maximize performance).
However, given the lack of a measurable performance
difference, it is not worth the extra code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-15 11:02:54 -07:00
Jeff King 6d63baa478 prio-queue: factor out compare and swap operations
When manipulating the priority queue's heap, we frequently
have to compare and swap heap entries. As we are storing
only void pointers right now, this is quite easy to do
inline in a few lines. However, when we start using a more
complicated heap entry in a future patch, that will get
longer. Factoring out these operations lets us make future
changes in one place. It also makes the code a little
shorter and more readable.

Note that we actually accept indices into the queue array
instead of pointers. This is slightly less flexible than
passing pointers-to-pointers (we could not swap items from
unrelated arrays, but we would not want to), but will make
further refactoring simpler (and lets us avoid repeating
"queue->array" at each callsite, which led to some long
lines).

And finally, note that we are cleaning up an accidental use
of a "struct commit" pointer to hold a temporary entry
during swap. Even though we currently only use this code for
commits, it is supposed to be type-agnostic. In practice
this didn't matter anyway because we never dereferenced the
commit pointer (and on most systems, the pointer values
themselves are interchangeable between types).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-15 11:02:53 -07:00
Junio C Hamano 66f467c3e6 Merge branch 'maint'
* maint:
  Start preparing for 2.0.2
2014-07-10 11:37:56 -07:00
Junio C Hamano da86971c2a Seventh batch for 2.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-10 11:37:30 -07:00
Junio C Hamano 779c99fd68 Merge branch 'dt/refs-check-refname-component-sse-fix'
Fixes to a topic that is already in 'master'.

* dt/refs-check-refname-component-sse-fix:
  refs: fix valgrind suppression file
  refs.c: handle REFNAME_REFSPEC_PATTERN at end of page
2014-07-10 11:27:55 -07:00
Junio C Hamano df4d7d5646 Merge branch 'rs/simplify-archive-tests'
* rs/simplify-archive-tests:
  t5000, t5003: simplify commit
2014-07-10 11:27:54 -07:00
Junio C Hamano b41a4636ee Merge branch 'rs/fix-alt-odb-path-comparison'
* rs/fix-alt-odb-path-comparison:
  sha1_file: avoid overrunning alternate object base string
2014-07-10 11:27:52 -07:00
Junio C Hamano e7cdec622a Merge branch 'rs/status-code-clean-up'
* rs/status-code-clean-up:
  wt-status: simplify building of summary limit argument
  wt-status: use argv_array for environment
2014-07-10 11:27:50 -07:00
Junio C Hamano 11def366e5 Merge branch 'kb/path-max-must-go'
* kb/path-max-must-go:
  symlinks: remove PATH_MAX limitation
2014-07-10 11:27:47 -07:00
Junio C Hamano 39177c7f18 Merge branch 'mg/verify-commit'
Add 'verify-commit' to be used in a way similar to 'verify-tag' is
used.  Further work on verifying the mergetags might be needed.

* mg/verify-commit:
  t7510: test verify-commit
  t7510: exit for loop with test result
  verify-commit: scriptable commit signature verification
  gpg-interface: provide access to the payload
  gpg-interface: provide clear helper for struct signature_check
2014-07-10 11:27:34 -07:00
Junio C Hamano 3d77f72efe Merge branch 'jc/fix-clone-single-starting-at-a-tag'
"git clone -b brefs/tags/bar" would have mistakenly thought we were
following a single tag, even though it was a name of the branch,
because it incorrectly used strstr().

* jc/fix-clone-single-starting-at-a-tag:
  builtin/clone.c: detect a clone starting at a tag correctly
2014-07-10 11:17:24 -07:00
Junio C Hamano 8693e1cc2f Start preparing for 2.0.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-10 11:15:10 -07:00
Junio C Hamano cbf4e024ad Merge branch 'pb/trim-trailing-spaces' into maint
* pb/trim-trailing-spaces:
  t0008: do not depend on 'echo' handling backslashes specially
  dir.c:trim_trailing_spaces(): fix for " \ " sequence
2014-07-10 11:10:52 -07:00
Junio C Hamano f35392b018 Merge branch 'jk/repack-pack-keep-objects' into maint
* jk/repack-pack-keep-objects:
  repack: s/write_bitmap/&s/ in code
  repack: respect pack.writebitmaps
  repack: do not accidentally pack kept objects by default
2014-07-10 11:10:05 -07:00
Junio C Hamano 3fea9ebdff Merge branch 'mc/doc-submodule-sync-recurse' into maint
* mc/doc-submodule-sync-recurse:
  submodule: document "sync --recursive"
2014-07-10 11:08:31 -07:00
Junio C Hamano 81e776d92b Sixth batch for 2.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-09 11:54:17 -07:00
Junio C Hamano cb9cd515ee Merge branch 'sk/mingw-unicode-spawn-args'
* sk/mingw-unicode-spawn-args:
  Win32: Unicode arguments (incoming)
  Win32: Unicode arguments (outgoing)
  MinGW: disable CRT command line globbing
  Win32: fix potential multi-threading issue
  Win32: simplify internal mingw_spawn* APIs
  Win32: let mingw_execve() return an int
2014-07-09 11:34:28 -07:00
Junio C Hamano b0bae7f0e4 Merge branch 'sk/mingw-dirent'
* sk/mingw-dirent:
  Win32 dirent: improve dirent implementation
  Win32 dirent: clarify #include directives
  Win32 dirent: change FILENAME_MAX to MAX_PATH
  Win32 dirent: remove unused dirent.d_reclen member
  Win32 dirent: remove unused dirent.d_ino member
2014-07-09 11:34:27 -07:00
Junio C Hamano 641830cbe1 Merge branch 'sk/mingw-uni-console'
* sk/mingw-uni-console:
  Win32: reliably detect console pipe handles
  Win32: fix broken pipe detection
  Win32: Thread-safe windows console output
  Win32: add Unicode conversion functions
  Win32: warn if the console font doesn't support Unicode
  Win32: detect console streams more reliably
  Win32: support Unicode console output
2014-07-09 11:34:25 -07:00
Junio C Hamano ba655d15b5 Merge branch 'sk/mingw-main'
* sk/mingw-main:
  mingw: avoid const warning
  Win32: move main macro to a function
2014-07-09 11:34:22 -07:00
Junio C Hamano ce8350f8ea Merge branch 'jk/pretty-G-format-fixes'
* jk/pretty-G-format-fixes:
  move "%G" format test from t7510 to t6006
  pretty: avoid reading past end-of-string with "%G"
  t7510: check %G* pretty-format output
  t7510: test a commit signed by an unknown key
  t7510: use consistent &&-chains in loop
  t7510: stop referring to master in later tests
2014-07-09 11:34:13 -07:00
Junio C Hamano 3b8e8af187 Merge branch 'jk/xstrfmt'
* jk/xstrfmt:
  setup_git_env(): introduce git_path_from_env() helper
  unique_path: fix unlikely heap overflow
  walker_fetch: fix minor memory leak
  merge: use argv_array when spawning merge strategy
  sequencer: use argv_array_pushf
  setup_git_env: use git_pathdup instead of xmalloc + sprintf
  use xstrfmt to replace xmalloc + strcpy/strcat
  use xstrfmt to replace xmalloc + sprintf
  use xstrdup instead of xmalloc + strcpy
  use xstrfmt in favor of manual size calculations
  strbuf: add xstrfmt helper
2014-07-09 11:34:05 -07:00
Junio C Hamano e91ae32a01 Merge branch 'jk/skip-prefix'
* jk/skip-prefix:
  http-push: refactor parsing of remote object names
  imap-send: use skip_prefix instead of using magic numbers
  use skip_prefix to avoid repeated calculations
  git: avoid magic number with skip_prefix
  fetch-pack: refactor parsing in get_ack
  fast-import: refactor parsing of spaces
  stat_opt: check extra strlen call
  daemon: use skip_prefix to avoid magic numbers
  fast-import: use skip_prefix for parsing input
  use skip_prefix to avoid repeating strings
  use skip_prefix to avoid magic numbers
  transport-helper: avoid reading past end-of-string
  fast-import: fix read of uninitialized argv memory
  apply: use skip_prefix instead of raw addition
  refactor skip_prefix to return a boolean
  avoid using skip_prefix as a boolean
  daemon: mark some strings as const
  parse_diff_color_slot: drop ofs parameter
2014-07-09 11:33:28 -07:00
David Turner a8d9fea772 refs: fix valgrind suppression file
Add all of the ways in which check_refname_format violates valgrind's
expectations to the valgrind suppression file; remove an assumption about
the call chain of check_refname_format from same.

Signed-off-by: David Turner <dturner@twitter.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-08 12:56:39 -07:00
René Scharfe 72c779457c line-log: use commit_list_append() instead of duplicating its code
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-08 11:01:53 -07:00
René Scharfe 4602f1a434 diff-tree: call free_commit_list() instead of duplicating its code
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-08 11:01:50 -07:00
René Scharfe 21711ca4b2 t5000, t5003: simplify commit
Add the whole directory of test files at once using git add instead of
calling git update-index on each of them and use git commit instead of
the plumbing commands write-tree, update-ref and commit-tree to build
the commit.  This simplifies the code considerably.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-07 14:10:13 -07:00
Karsten Blees e7c7305300 symlinks: remove PATH_MAX limitation
'git checkout' fails if a directory is longer than PATH_MAX, because the
lstat_cache in symlinks.c checks if the leading directory exists using
PATH_MAX-bounded string operations.

Remove the limitation by using strbuf instead.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-07 11:22:42 -07:00
David Turner 6d17dc1dd3 refs.c: handle REFNAME_REFSPEC_PATTERN at end of page
When a ref crosses a memory page boundary, we restart the parsing
at the beginning with the bytewise code.  Pass the original flags
to that code, rather than the current flags.

Reported-By: Øyvind A. Holm <sunny@sunbase.org>
Signed-off-by: David Turner <dturner@twitter.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-07 11:05:43 -07:00
Junio C Hamano 6f92e5ff3c Merge branch 'dt/refs-check-refname-component-sse'
Further micro-optimization of a leaf-function.

* dt/refs-check-refname-component-sse:
  refs.c: SSE2 optimizations for check_refname_component
2014-07-02 12:53:07 -07:00
Junio C Hamano a02ad882a1 Merge branch 'ye/http-extract-charset'
* ye/http-extract-charset:
  http: fix charset detection of extract_content_type()
2014-07-02 12:53:05 -07:00
Junio C Hamano 6293aea559 Merge branch 'bc/fix-rebase-merge-skip'
"git rebase --skip" did not work well when it stopped due to a
conflict twice in a row.

* bc/fix-rebase-merge-skip:
  rebase--merge: fix --skip with two conflicts in a row
2014-07-02 12:53:04 -07:00
Junio C Hamano 8061ae8b46 Merge branch 'jk/commit-buffer-length'
Move "commit->buffer" out of the in-core commit object and keep
track of their lengths.  Use this to optimize the code paths to
validate GPG signatures in commit objects.

* jk/commit-buffer-length:
  reuse cached commit buffer when parsing signatures
  commit: record buffer length in cache
  commit: convert commit->buffer to a slab
  commit-slab: provide a static initializer
  use get_commit_buffer everywhere
  convert logmsg_reencode to get_commit_buffer
  use get_commit_buffer to avoid duplicate code
  use get_cached_commit_buffer where appropriate
  provide helpers to access the commit buffer
  provide a helper to set the commit buffer
  provide a helper to free commit buffer
  sequencer: use logmsg_reencode in get_message
  logmsg_reencode: return const buffer
  do not create "struct commit" with xcalloc
  commit: push commit_index update into alloc_commit_node
  alloc: include any-object allocations in alloc_report
  replace dangerous uses of strbuf_attach
  commit_tree: take a pointer/len pair rather than a const strbuf
2014-07-02 12:53:02 -07:00
Ronnie Sahlberg 95acfc2479 enums: remove trailing ',' after last item in enum
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-02 12:52:55 -07:00
Junio C Hamano 64d845477b Merge branch 'maint'
* maint:
  t7300: repair filesystem permissions with test_when_finished
  enums: remove trailing ',' after last item in enum
2014-07-02 12:52:46 -07:00
Junio C Hamano c2f7b1026e Merge branch 'maint-1.8.5' into maint
* maint-1.8.5:
  t7300: repair filesystem permissions with test_when_finished
  enums: remove trailing ',' after last item in enum
2014-07-02 12:51:50 -07:00
Jeff King 45067fc973 t7300: repair filesystem permissions with test_when_finished
We create a directory that cannot be removed, confirm that
it cannot be removed, and then fix it like:

  chmod 0 foo &&
  test_must_fail git clean -d -f &&
  chmod 755 foo

If the middle step fails but leaves the directory (e.g., the
bug is that clean does not notice the failure), this
pollutes the test repo with an unremovable directory. Not
only does this cause further tests to fail, but it means
that "rm -rf" fails on the whole trash directory, and the
user has to intervene manually to even re-run the test script.

We can bump the "chmod 755" recovery to a test_when_finished
block to be sure that it always runs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-02 12:51:38 -07:00
Ronnie Sahlberg 782735203c enums: remove trailing ',' after last item in enum
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-02 12:37:05 -07:00
René Scharfe 80b47854ca sha1_file: avoid overrunning alternate object base string
While checking if a new alternate object database is a duplicate make
sure that old and new base paths have the same length before comparing
them with memcmp.  This avoids overrunning the buffer of the existing
entry if the new one is longer and it stops rejecting foobar/ after
foo/ was already added.

Signed-off-by: Rene Scharfe <ls.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-01 13:30:50 -07:00
René Scharfe 10761eb681 wt-status: simplify building of summary limit argument
Use argv_array_pushf for building the number string for the option
--summary-limit directly instead of using an intermediate buffer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-29 23:41:04 -07:00
René Scharfe 85dd6bf491 wt-status: use argv_array for environment
Instead of using a PATH_MAX buffer, use argv_array for constructing the
environment for git submodule summary.  This simplifies the code a bit
and removes the arbitrary length limit.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-29 23:41:02 -07:00
Junio C Hamano 7fe6834801 Merge git://ozlabs.org/~paulus/gitk
* git://ozlabs.org/~paulus/gitk:
  gitk: Add visiblerefs option, which lists always-shown branches
  gitk: Catch mkdtemp errors
  gitk: Use mktemp -d to avoid predictable temporary directories
  gitk: Honor TMPDIR when viewing external diffs
2014-06-27 11:23:03 -07:00
Max Kirillov bde4a0f9f3 gitk: Add visiblerefs option, which lists always-shown branches
When many branches contain a commit, the branches used to be shown in
the form "A, B and many more", where A, B can be master of current
HEAD. But there are more which might be interesting to always know about.
For example, "origin/master".

The new option, visiblerefs, is stored in ~/.gitk. It contains a list
of references which are always shown before "and many more" if they
contain the commit. By default it is `{"master"}', which is compatible
with previous behavior.

Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2014-06-27 16:37:14 +10:00
David Aguilar ac54a4b771 gitk: Catch mkdtemp errors
105b5d3f ("gitk: Use mktemp -d to avoid predictable temporary
directories") introduced a dependency on mkdtemp, which is not
available on Windows.

Use the original temporary directory behavior when mkdtemp fails.
This makes the code use mkdtemp when available and gracefully
fallback to the existing behavior when it is not available.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2014-06-27 16:30:39 +10:00
Junio C Hamano ea0e524ebd Merge early parts from git://ozlabs.org/~paulus/gitk.git
* master~2:
  gitk: Show staged submodules regardless of ignore config
  gitk: Allow displaying time zones from author and commit dates timestamps
  gitk: Switch to patch mode when searching for line origin
  gitk: Replace SHA1 entry field on keyboard paste
  l10n: Init Vietnamese translation
2014-06-26 13:46:09 -07:00
Junio C Hamano ad1c66033e Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui:
  git-gui: tolerate major version changes when comparing the git version
  git-gui: show staged submodules regardless of ignore config
2014-06-26 13:44:11 -07:00
Jeff King 958b2eb26c move "%G" format test from t7510 to t6006
The final test in t7510 checks that "--format" placeholders
that look similar to GPG placeholders (but that we don't
actually understand) are passed through. That test was
placed in t7510, since the other GPG placeholder tests are
there. However, it does not have a GPG prerequisite, because
it is not actually checking any signed commits.

This causes the test to erroneously fail when gpg is not
installed on a system, however. Not because we need signed
commits, but because we need _any_ commit to run "git log".
If we don't have gpg installed, t7510 doesn't create any
commits at all.

We can fix this by moving the test into t6006. This is
arguably a better place anyway, because it is where we test
most of the other placeholders (we do not test GPG
placeholders there because of the infrastructure needed to
make signed commits).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-25 15:01:06 -07:00
Junio C Hamano c47372d3a8 Sync with maint 2014-06-25 12:32:58 -07:00