OSDN Git Service

git-core/git.git
9 years agoMerge git://ozlabs.org/~paulus/gitk
Junio C Hamano [Thu, 30 Oct 2014 17:07:33 +0000 (10:07 -0700)]
Merge git://ozlabs.org/~paulus/gitk

* git://ozlabs.org/~paulus/gitk:
  gitk: Remove boilerplate for configuration variables
  gitk: Show detached HEAD if --all is specified
  gitk: Do not depend on Cygwin's "kill" command on Windows

9 years agogitk: Remove boilerplate for configuration variables
Max Kirillov [Sun, 14 Sep 2014 20:35:57 +0000 (23:35 +0300)]
gitk: Remove boilerplate for configuration variables

Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
9 years agogitk: Show detached HEAD if --all is specified
Max Kirillov [Tue, 9 Sep 2014 07:29:16 +0000 (10:29 +0300)]
gitk: Show detached HEAD if --all is specified

If HEAD is detached, 'gitk --all' does not show it. This is inconvenient
for frontend program, and for example git log does show the detached HEAD.

gitk uses git rev-parse to find a list of branches to show.
Apparently, the command does not include detached HEAD to output if
--all argument is specified. This has been discussed in [1] and stated
as expected behavior. So rev-parse's parameters should be tuned in gitk.

[1] http://thread.gmane.org/gmane.comp.version-control.git/255996

Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
9 years agogitk: Do not depend on Cygwin's "kill" command on Windows
Sebastian Schuberth [Thu, 23 Oct 2014 19:30:54 +0000 (21:30 +0200)]
gitk: Do not depend on Cygwin's "kill" command on Windows

Windows does not necessarily mean Cygwin, it could also be MSYS. The
latter ships with a version of "kill" that does not understand "-f".
In msysgit this was addressed by shipping Cygwin's version of kill.

Properly fix this by using the stock Windows "taskkill" command instead,
which is available since Windows XP Professional.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
9 years agoSync with Git 2.1.3
Junio C Hamano [Wed, 29 Oct 2014 17:49:54 +0000 (10:49 -0700)]
Sync with Git 2.1.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoGit 2.1.3 v2.1.3
Junio C Hamano [Wed, 29 Oct 2014 17:48:38 +0000 (10:48 -0700)]
Git 2.1.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'jk/pack-objects-no-bitmap-when-splitting' into maint
Junio C Hamano [Wed, 29 Oct 2014 17:35:17 +0000 (10:35 -0700)]
Merge branch 'jk/pack-objects-no-bitmap-when-splitting' into maint

* jk/pack-objects-no-bitmap-when-splitting:
  pack-objects: turn off bitmaps when we split packs

9 years agoMerge branch 'da/mergetool-meld' into maint
Junio C Hamano [Wed, 29 Oct 2014 17:35:16 +0000 (10:35 -0700)]
Merge branch 'da/mergetool-meld' into maint

* da/mergetool-meld:
  mergetools/meld: make usage of `--output` configurable and more robust

9 years agoMerge branch 'rm/gitweb-start-form' into maint
Junio C Hamano [Wed, 29 Oct 2014 17:35:16 +0000 (10:35 -0700)]
Merge branch 'rm/gitweb-start-form' into maint

* rm/gitweb-start-form:
  gitweb: use start_form, not startform that was removed in CGI.pm 4.04

9 years agoMerge branch 'bc/asciidoc-pretty-formats-fix' into maint
Junio C Hamano [Wed, 29 Oct 2014 17:35:10 +0000 (10:35 -0700)]
Merge branch 'bc/asciidoc-pretty-formats-fix' into maint

* bc/asciidoc-pretty-formats-fix:
  Documentation: fix misrender of pretty-formats in Asciidoctor

9 years agoMerge branch 'rs/daemon-fixes' into maint
Junio C Hamano [Wed, 29 Oct 2014 17:35:09 +0000 (10:35 -0700)]
Merge branch 'rs/daemon-fixes' into maint

* rs/daemon-fixes:
  daemon: remove write-only variable maxfd
  daemon: fix error message after bind()
  daemon: handle gethostbyname() error

9 years agoUpdate draft release notes to 2.2
Junio C Hamano [Wed, 29 Oct 2014 17:18:31 +0000 (10:18 -0700)]
Update draft release notes to 2.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'da/difftool'
Junio C Hamano [Wed, 29 Oct 2014 17:09:35 +0000 (10:09 -0700)]
Merge branch 'da/difftool'

Allow diff tool backend to stop early by exiting with a non-zero
status.

* da/difftool:
  difftool: add support for --trust-exit-code
  difftool--helper: exit when reading a prompt answer fails

9 years agoMerge branch 'rb/pack-window-memory-config-doc'
Junio C Hamano [Wed, 29 Oct 2014 17:09:31 +0000 (10:09 -0700)]
Merge branch 'rb/pack-window-memory-config-doc'

* rb/pack-window-memory-config-doc:
  config.txt: pack.windowmemory limit applies per-thread

9 years agoMerge branch 'mg/lib-gpg-ro-safety'
Junio C Hamano [Wed, 29 Oct 2014 17:08:15 +0000 (10:08 -0700)]
Merge branch 'mg/lib-gpg-ro-safety'

In a tarball extract whose files are all read-only, running GPG
tests would have failed due to unwritable files.

* mg/lib-gpg-ro-safety:
  t/lib-gpg: make gpghome files writable

9 years agoMerge branch 'dm/port2zos'
Junio C Hamano [Wed, 29 Oct 2014 17:08:06 +0000 (10:08 -0700)]
Merge branch 'dm/port2zos'

z/OS port

* dm/port2zos:
  compat/bswap.h: detect endianness from XL C compiler macros
  Makefile: reorder linker flags in the git executable rule
  git-compat-util.h: support variadic macros with the XL C compiler

9 years agoMerge branch 'oc/mergetools-beyondcompare'
Junio C Hamano [Wed, 29 Oct 2014 17:08:03 +0000 (10:08 -0700)]
Merge branch 'oc/mergetools-beyondcompare'

* oc/mergetools-beyondcompare:
  mergetool: rename bc3 to bc

9 years agoMerge branch 'jk/prune-mtime'
Junio C Hamano [Wed, 29 Oct 2014 17:07:56 +0000 (10:07 -0700)]
Merge branch 'jk/prune-mtime'

Tighten the logic to decide that an unreachable cruft is
sufficiently old by covering corner cases such as an ancient object
becoming reachable and then going unreachable again, in which case
its retention period should be prolonged.

* jk/prune-mtime: (28 commits)
  drop add_object_array_with_mode
  revision: remove definition of unused 'add_object' function
  pack-objects: double-check options before discarding objects
  repack: pack objects mentioned by the index
  pack-objects: use argv_array
  reachable: use revision machinery's --indexed-objects code
  rev-list: add --indexed-objects option
  rev-list: document --reflog option
  t5516: test pushing a tag of an otherwise unreferenced blob
  traverse_commit_list: support pending blobs/trees with paths
  make add_object_array_with_context interface more sane
  write_sha1_file: freshen existing objects
  pack-objects: match prune logic for discarding objects
  pack-objects: refactor unpack-unreachable expiration check
  prune: keep objects reachable from recent objects
  sha1_file: add for_each iterators for loose and packed objects
  count-objects: use for_each_loose_file_in_objdir
  count-objects: do not use xsize_t when counting object size
  prune-packed: use for_each_loose_file_in_objdir
  reachable: mark index blobs as SEEN
  ...

9 years agoMerge branch 'bc/asciidoctor'
Junio C Hamano [Wed, 29 Oct 2014 17:07:39 +0000 (10:07 -0700)]
Merge branch 'bc/asciidoctor'

Add machinery to alternatively use AsciiDoctor to format our
documentation.

* bc/asciidoctor:
  Documentation: remove Asciidoctor linkgit macro
  Documentation: refactor common operations into variables
  Documentation: implement linkgit macro for Asciidoctor
  Documentation: move some AsciiDoc parameters into variables

9 years agodifftool: add support for --trust-exit-code
David Aguilar [Mon, 27 Oct 2014 01:15:42 +0000 (18:15 -0700)]
difftool: add support for --trust-exit-code

Teach difftool to exit when a diff tool returns a non-zero exit
code when either --trust-exit-code is specified or
difftool.trustExitCode is true.

Forward exit codes from invoked diff tools to the caller when
--trust-exit-code is used.

Suggested-by: Adri Farr <14farresa@gmail.com>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoconfig.txt: pack.windowmemory limit applies per-thread
Robert de Bath [Fri, 24 Oct 2014 07:43:27 +0000 (08:43 +0100)]
config.txt: pack.windowmemory limit applies per-thread

It took me a long time to notice the rider on the pack.threads
configuration option that it would multiple the memory consumption
by the number of CPUs in the machine.  Clarify that the limit
applies per-thread.

Signed-off-by: Robert de Bath <rdebath@tvisiontech.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot/lib-gpg: make gpghome files writable
Michael J Gruber [Fri, 24 Oct 2014 15:23:32 +0000 (17:23 +0200)]
t/lib-gpg: make gpghome files writable

t/lib-gpg.sh copies the test environment's gpg home to the trash
directory and makes sure the directoty is writable.

Make sure the copied files are writable, too.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation: remove Asciidoctor linkgit macro
brian m. carlson [Mon, 27 Oct 2014 00:13:43 +0000 (00:13 +0000)]
Documentation: remove Asciidoctor linkgit macro

Asciidoctor provides an extension implementing a backend-independent
macro for dealing with manpage links just like the linkgit macro.  As
this is more likely to be up-to-date with future changes in Asciidoctor,
prefer using it over reimplementing in Git.

This reverts commit 773ee47c2b9c691d9758b2bea6cac10e3f0c4e12.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation: refactor common operations into variables
brian m. carlson [Mon, 27 Oct 2014 00:13:42 +0000 (00:13 +0000)]
Documentation: refactor common operations into variables

The Makefile performs several very similar tasks to convert AsciiDoc
files into either HTML or DocBook.  Move these items into variables to
reduce the duplication.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agocompat/bswap.h: detect endianness from XL C compiler macros
David Michael [Sun, 26 Oct 2014 17:34:26 +0000 (13:34 -0400)]
compat/bswap.h: detect endianness from XL C compiler macros

There is no /usr/include/endian.h equivalent on z/OS, but the
compiler will define macros to indicate endianness on host and
target hardware.  This adds a test for these macros as a last
resort for determining byte order.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMakefile: reorder linker flags in the git executable rule
David Michael [Sun, 26 Oct 2014 17:33:53 +0000 (13:33 -0400)]
Makefile: reorder linker flags in the git executable rule

The XL C compiler can fail due to mixing library path and object
file arguments, for example when linking git while building with
"gmake LDFLAGS=-L$prefix/lib".

Move the ALL_LDFLAGS variable expansion in the git executable rule
to be consistent with all the other linking rules, namely to have
LDFLAGS such as -L$where before the object files *.o being linked
together.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-compat-util.h: support variadic macros with the XL C compiler
David Michael [Sun, 26 Oct 2014 17:33:12 +0000 (13:33 -0400)]
git-compat-util.h: support variadic macros with the XL C compiler

When the XL C compiler is run with an appropriate language level or
suboption, it defines a feature test macro to indicate support for
variadic macros by defining __C99_MACRO_WITH_VA_ARGS C preprocessor
macro.

This was tested on z/OS, but it should also work on AIX according
to IBM documentation.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodifftool--helper: exit when reading a prompt answer fails
Johannes Sixt [Sun, 26 Oct 2014 08:09:20 +0000 (09:09 +0100)]
difftool--helper: exit when reading a prompt answer fails

An attempt to quit difftool by hitting Ctrl-D (EOF) at its prompt does
not quit it, but is treated as if 'yes' was answered to the prompt and
all following prompts, which is contrary to the user's intent. Fix the
error check.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoUpdate draft release notes to 2.2
Junio C Hamano [Fri, 24 Oct 2014 22:02:17 +0000 (15:02 -0700)]
Update draft release notes to 2.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'jc/push-cert'
Junio C Hamano [Fri, 24 Oct 2014 22:01:32 +0000 (15:01 -0700)]
Merge branch 'jc/push-cert'

* jc/push-cert:
  push: heed user.signingkey for signed pushes

9 years agoMerge branch 'sb/plug-transport-leak'
Junio C Hamano [Fri, 24 Oct 2014 22:00:09 +0000 (15:00 -0700)]
Merge branch 'sb/plug-transport-leak'

Code clean-up.

* sb/plug-transport-leak:
  .mailmap: add Stefan Bellers corporate mail address
  transport: free leaking head in transport_print_push_status()

9 years agoMerge branch 'nd/dir-prep-exclude-cleanup'
Junio C Hamano [Fri, 24 Oct 2014 22:00:05 +0000 (15:00 -0700)]
Merge branch 'nd/dir-prep-exclude-cleanup'

Code clean-up.

* nd/dir-prep-exclude-cleanup:
  dir.c: remove the second declaration of "stk" in prep_exclude()

9 years agoMerge branch 'eb/no-pthreads'
Junio C Hamano [Fri, 24 Oct 2014 21:59:10 +0000 (14:59 -0700)]
Merge branch 'eb/no-pthreads'

Allow us build with NO_PTHREADS=NoThanks compilation option.

* eb/no-pthreads:
  Handle atexit list internaly for unthreaded builds
  pack-objects: set number of threads before checking and warning
  index-pack: fix compilation with NO_PTHREADS

9 years agoMerge branch 'wk/t1304-wo-USER'
Junio C Hamano [Fri, 24 Oct 2014 21:59:02 +0000 (14:59 -0700)]
Merge branch 'wk/t1304-wo-USER'

* wk/t1304-wo-USER:
  t1304: Set LOGNAME even if USER is unset or null

9 years agoMerge branch 'tb/core-filemode-doc'
Junio C Hamano [Fri, 24 Oct 2014 21:57:57 +0000 (14:57 -0700)]
Merge branch 'tb/core-filemode-doc'

Doc update.

* tb/core-filemode-doc:
  core.filemode may need manual action

9 years agoMerge branch 'rs/run-command-env-array'
Junio C Hamano [Fri, 24 Oct 2014 21:57:53 +0000 (14:57 -0700)]
Merge branch 'rs/run-command-env-array'

Add managed "env" array to child_process to clarify the lifetime
rules.

* rs/run-command-env-array:
  use env_array member of struct child_process
  run-command: add env_array, an optional argv_array for env

9 years agoMerge branch 'po/doc-status-markup'
Junio C Hamano [Fri, 24 Oct 2014 21:57:51 +0000 (14:57 -0700)]
Merge branch 'po/doc-status-markup'

Update documentation mark-up.

* po/doc-status-markup:
  doc: fix 'git status --help' character quoting

9 years agoMerge branch 'jk/pack-objects-no-bitmap-when-splitting'
Junio C Hamano [Fri, 24 Oct 2014 21:56:10 +0000 (14:56 -0700)]
Merge branch 'jk/pack-objects-no-bitmap-when-splitting'

Splitting pack-objects output into multiple packs is incompatible
with the use of reachability bitmap.

* jk/pack-objects-no-bitmap-when-splitting:
  pack-objects: turn off bitmaps when we split packs

9 years agopush: heed user.signingkey for signed pushes
Michael J Gruber [Wed, 22 Oct 2014 14:57:49 +0000 (16:57 +0200)]
push: heed user.signingkey for signed pushes

push --signed promises to take user.signingkey as the signing key but
fails to read the config.

Make it do so.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoUpdate draft release notes to 2.2
Junio C Hamano [Tue, 21 Oct 2014 20:35:44 +0000 (13:35 -0700)]
Update draft release notes to 2.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'js/completion-hide-not-a-repo'
Junio C Hamano [Tue, 21 Oct 2014 20:28:50 +0000 (13:28 -0700)]
Merge branch 'js/completion-hide-not-a-repo'

Some internal error messages leaked out of the bash completion when
typing "git cmd <TAB>" and the machinery tried to complete
refnames.

* js/completion-hide-not-a-repo:
  completion: silence "fatal: Not a git repository" error

9 years agoMerge branch 'da/mergetool-meld'
Junio C Hamano [Tue, 21 Oct 2014 20:28:47 +0000 (13:28 -0700)]
Merge branch 'da/mergetool-meld'

Newer versions of 'meld' breaks the auto-detection we use to see if
they are new enough to support the `--output` option.

* da/mergetool-meld:
  mergetools/meld: make usage of `--output` configurable and more robust

9 years agoMerge branch 'da/mergetool-temporary-directory'
Junio C Hamano [Tue, 21 Oct 2014 20:28:42 +0000 (13:28 -0700)]
Merge branch 'da/mergetool-temporary-directory'

Allow a temporary directory specified to be used while running "git
mergetool" backend.

* da/mergetool-temporary-directory:
  t7610-mergetool: add test cases for mergetool.writeToTemp
  mergetool: add an option for writing to a temporary directory

9 years agoMerge branch 'da/mergetool-tool-help'
Junio C Hamano [Tue, 21 Oct 2014 20:28:37 +0000 (13:28 -0700)]
Merge branch 'da/mergetool-tool-help'

Allow "git mergetool --help" to run outside a Git repository.

* da/mergetool-tool-help:
  difftool: don't assume that default sh is sane
  mergetool: don't require a work tree for --tool-help
  git-sh-setup: move GIT_DIR initialization into a function
  mergetool: use more conservative temporary filenames
  test-lib-functions: adjust style to match CodingGuidelines
  t7610-mergetool: prefer test_config over git config

9 years agoMerge branch 'da/mergetool-temporary-filename'
Junio C Hamano [Tue, 21 Oct 2014 20:28:19 +0000 (13:28 -0700)]
Merge branch 'da/mergetool-temporary-filename'

Tweak the names of the three throw-away files "git mergetool" comes
up with to feed the merge tool backend, so that a file with a
single dot in its name in the original (e.g. "hello.c") will have
only one dot in these variants (e.g. "hello_BASE_4321.c").

* da/mergetool-temporary-filename:
  mergetool: use more conservative temporary filenames

9 years agoMerge branch 'da/mergetool-tests'
Junio C Hamano [Tue, 21 Oct 2014 20:28:14 +0000 (13:28 -0700)]
Merge branch 'da/mergetool-tests'

The clean-up of this test script was long overdue and is a very
welcome change.

* da/mergetool-tests:
  test-lib-functions: adjust style to match CodingGuidelines
  t7610-mergetool: use test_config to isolate tests
  t7610-mergetool: add missing && and remove commented-out code
  t7610-mergetool: use tabs instead of a mix of tabs and spaces

9 years agoMerge branch 'rs/ref-transaction'
Junio C Hamano [Tue, 21 Oct 2014 20:28:10 +0000 (13:28 -0700)]
Merge branch 'rs/ref-transaction'

The API to update refs have been restructured to allow introducing
a true transactional updates later.  We would even allow storing
refs in backends other than the traditional filesystem-based one.

* rs/ref-transaction: (25 commits)
  ref_transaction_commit: bail out on failure to remove a ref
  lockfile: remove unable_to_lock_error
  refs.c: do not permit err == NULL
  remote rm/prune: print a message when writing packed-refs fails
  for-each-ref: skip and warn about broken ref names
  refs.c: allow listing and deleting badly named refs
  test: put tests for handling of bad ref names in one place
  packed-ref cache: forbid dot-components in refnames
  branch -d: simplify by using RESOLVE_REF_READING
  branch -d: avoid repeated symref resolution
  reflog test: test interaction with detached HEAD
  refs.c: change resolve_ref_unsafe reading argument to be a flags field
  refs.c: make write_ref_sha1 static
  fetch.c: change s_update_ref to use a ref transaction
  refs.c: ref_transaction_commit: distinguish name conflicts from other errors
  refs.c: pass a list of names to skip to is_refname_available
  refs.c: call lock_ref_sha1_basic directly from commit
  refs.c: refuse to lock badly named refs in lock_ref_sha1_basic
  rename_ref: don't ask read_ref_full where the ref came from
  refs.c: pass the ref log message to _create/delete/update instead of _commit
  ...

9 years agomergetool: rename bc3 to bc
Junio C Hamano [Mon, 20 Oct 2014 22:49:36 +0000 (15:49 -0700)]
mergetool: rename bc3 to bc

Beyond Compare version 4 works the same way as version 3, so rename
the existing "bc3" adaptor to just "bc", while keeping "bc3" as a
backward compatible wrapper.

Noticed-by: Olivier Croquette <ocroquette@free.fr>
Helped-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodir.c: remove the second declaration of "stk" in prep_exclude()
Nguyễn Thái Ngọc Duy [Tue, 21 Oct 2014 11:38:06 +0000 (18:38 +0700)]
dir.c: remove the second declaration of "stk" in prep_exclude()

This "stk" shadows the first declaration at the top. There's currently
no bad effect. But let's avoid it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years ago.mailmap: add Stefan Bellers corporate mail address
Stefan Beller [Tue, 21 Oct 2014 01:50:45 +0000 (18:50 -0700)]
.mailmap: add Stefan Bellers corporate mail address

Note that despite the private address being first and primary,
Google owns the copyright on this patch as any other patch I'll be
sending signed off by the sbeller@google.com address.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotransport: free leaking head in transport_print_push_status()
Stefan Beller [Tue, 21 Oct 2014 01:50:44 +0000 (18:50 -0700)]
transport: free leaking head in transport_print_push_status()

Found by scan.coverity.com (ID: 1248110)

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoUpdate draft release notes to 2.2
Junio C Hamano [Mon, 20 Oct 2014 20:07:32 +0000 (13:07 -0700)]
Update draft release notes to 2.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'cc/interpret-trailers'
Junio C Hamano [Mon, 20 Oct 2014 19:25:30 +0000 (12:25 -0700)]
Merge branch 'cc/interpret-trailers'

A new filter to programatically edit the tail end of the commit log
messages.

* cc/interpret-trailers:
  Documentation: add documentation for 'git interpret-trailers'
  trailer: add tests for commands in config file
  trailer: execute command from 'trailer.<name>.command'
  trailer: add tests for "git interpret-trailers"
  trailer: add interpret-trailers command
  trailer: put all the processing together and print
  trailer: parse trailers from file or stdin
  trailer: process command line trailer arguments
  trailer: read and process config information
  trailer: process trailers from input message and arguments
  trailer: add data structures and basic functions

9 years agoMerge branch 'rm/gitweb-start-form'
Junio C Hamano [Mon, 20 Oct 2014 19:25:27 +0000 (12:25 -0700)]
Merge branch 'rm/gitweb-start-form'

* rm/gitweb-start-form:
  gitweb: use start_form, not startform that was removed in CGI.pm 4.04

9 years agoMerge branch 'ss/contrib-subtree-contacts'
Junio C Hamano [Mon, 20 Oct 2014 19:25:15 +0000 (12:25 -0700)]
Merge branch 'ss/contrib-subtree-contacts'

* ss/contrib-subtree-contacts:
  contacts: add a Makefile to generate docs and install
  subtree: add an install-html target

9 years agoMerge branch 'jn/parse-config-slot'
Junio C Hamano [Mon, 20 Oct 2014 19:23:48 +0000 (12:23 -0700)]
Merge branch 'jn/parse-config-slot'

Code cleanup.

* jn/parse-config-slot:
  color_parse: do not mention variable name in error message
  pass config slots as pointers instead of offsets

9 years agoMerge branch 'rs/receive-pack-argv-leak-fix'
Junio C Hamano [Mon, 20 Oct 2014 19:23:45 +0000 (12:23 -0700)]
Merge branch 'rs/receive-pack-argv-leak-fix'

* rs/receive-pack-argv-leak-fix:
  receive-pack: plug minor memory leak in unpack()

9 years agoMerge branch 'ta/config-set'
Junio C Hamano [Mon, 20 Oct 2014 19:23:42 +0000 (12:23 -0700)]
Merge branch 'ta/config-set'

* ta/config-set:
  t1308: fix broken here document in test script

9 years agoMerge branch 'jk/test-shell-trace'
Junio C Hamano [Mon, 20 Oct 2014 19:23:40 +0000 (12:23 -0700)]
Merge branch 'jk/test-shell-trace'

Test scripts were taught to notice "-x" option to show shell trace,
as if the tests were run under "sh -x".

* jk/test-shell-trace:
  test-lib.sh: support -x option for shell-tracing
  t5304: use helper to report failure of "test foo = bar"
  t5304: use test_path_is_* instead of "test -f"

9 years agoMerge branch 'bc/asciidoc'
Junio C Hamano [Mon, 20 Oct 2014 19:23:29 +0000 (12:23 -0700)]
Merge branch 'bc/asciidoc'

Formatting nitpicks to help a (pickier) reimplementation of
AsciiDoc to grok our documentation.

* bc/asciidoc:
  Documentation: fix mismatched delimiters in git-imap-send
  Documentation: adjust document title underlining

9 years agoRevert "archive: honor tar.umask even for pax headers"
Junio C Hamano [Mon, 20 Oct 2014 19:04:46 +0000 (12:04 -0700)]
Revert "archive: honor tar.umask even for pax headers"

This reverts commit 10f343ea814f5c18a0913997904ee11cd9b7da24, whose
output is no longer bit-for-bit equivalent from the older versions
of Git, which the infrastructure to (pretend to) upload tarballs
kernel.org uses depends on.

9 years agocore.filemode may need manual action
Torsten Bögershausen [Fri, 17 Oct 2014 21:40:23 +0000 (23:40 +0200)]
core.filemode may need manual action

core.filemode is set automatically when a repo is created.
But when a repo is exported via CIFS or cygwin is mixed with Git for Windows
or Eclipse core.filemode may better be set manually to false.
Update and improve the documentation

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodoc: fix 'git status --help' character quoting
Philip Oakley [Sun, 19 Oct 2014 14:17:15 +0000 (15:17 +0100)]
doc: fix 'git status --help' character quoting

Correct backtick quoting for some of the modification states to give
consistent web rendering.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot1304: Set LOGNAME even if USER is unset or null
W. Trevor King [Fri, 17 Oct 2014 21:39:00 +0000 (14:39 -0700)]
t1304: Set LOGNAME even if USER is unset or null

Avoid:

  # ./t1304-default-acl.sh
  ok 1 - checking for a working acl setup
  ok 2 - Setup test repo
  not ok 3 - Objects creation does not break ACLs with restrictive umask
  #
  #               # SHA1 for empty blob
  #               check_perms_and_acl .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
  #
  not ok 4 - git gc does not break ACLs with restrictive umask
  #
  #               git gc &&
  #               check_perms_and_acl .git/objects/pack/*.pack
  #
  # failed 2 among 4 test(s)
  1..4

on systems where USER isn't set.  It's usually set by the login
process, but it isn't set when launching some Docker images.  For
example:

  $ docker run --rm debian env
  HOME=/
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=b2dfdfe797ed

'id -u -n' has been in POSIX from Issue 2 through 2013 [1], so I don't
expect compatibility issues.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/id.html

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoHandle atexit list internaly for unthreaded builds
Etienne Buira [Sat, 18 Oct 2014 12:31:15 +0000 (14:31 +0200)]
Handle atexit list internaly for unthreaded builds

Wrap atexit()s calls on unthreaded builds to handle callback list
internally.

This is needed because on unthreaded builds, asyncs inherits parent's
atexit() list, that gets run as soon as the async exit()s (and again at
the end of async's parent process). That led to remove temporary files
too early.

Also remove a by-atexit-callback guard against this kind of issue in
clone.c, as this patch makes it redundant.

Fixes test 5537 (temporary shallow file vanished before unpack-objects
could open it)

BTW remove an unused variable in shallow.c.

Helped-by: Duy Nguyen <pclouds@gmail.com>
Helped-by: Andreas Schwab <schwab@linux-m68k.org>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Etienne Buira <etienne.buira@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodrop add_object_array_with_mode
Jeff King [Sun, 19 Oct 2014 02:03:19 +0000 (22:03 -0400)]
drop add_object_array_with_mode

This is a thin compatibility wrapper around
add_pending_object_with_path. But the only caller is
add_object_array, which is itself just a thin compatibility
wrapper. There are no external callers, so we can just
remove this middle wrapper.

Noticed-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorevision: remove definition of unused 'add_object' function
Ramsay Jones [Sat, 18 Oct 2014 21:36:12 +0000 (22:36 +0100)]
revision: remove definition of unused 'add_object' function

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agouse env_array member of struct child_process
René Scharfe [Sun, 19 Oct 2014 11:14:20 +0000 (13:14 +0200)]
use env_array member of struct child_process

Convert users of struct child_process to using the managed env_array for
specifying environment variables instead of supplying an array on the
stack or bringing their own argv_array.  This shortens and simplifies
the code and ensures automatically that the allocated memory is freed
after use.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorun-command: add env_array, an optional argv_array for env
René Scharfe [Sun, 19 Oct 2014 11:13:55 +0000 (13:13 +0200)]
run-command: add env_array, an optional argv_array for env

Similar to args, add a struct argv_array member to struct child_process
that simplifies specifying the environment for children.  It is freed
automatically by finish_command() or if start_command() encounters an
error.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopack-objects: turn off bitmaps when we split packs
Jeff King [Fri, 17 Oct 2014 01:11:43 +0000 (21:11 -0400)]
pack-objects: turn off bitmaps when we split packs

If a pack.packSizeLimit is set, we may split the pack data
across multiple packfiles. This means we cannot generate
.bitmap files, as they require that all of the reachable
objects are in the same pack. We check that condition when
we are generating the list of objects to pack (and disable
bitmaps if we are not packing everything), but we forgot to
update it when we notice that we needed to split (which
doesn't happen until the actual write phase).

The resulting bitmaps are quite bogus (they mention entries
that do not exist in the pack!) and can cause a fetch or
push to send insufficient objects.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopack-objects: double-check options before discarding objects
Jeff King [Fri, 17 Oct 2014 00:44:54 +0000 (20:44 -0400)]
pack-objects: double-check options before discarding objects

When we are given an expiration time like
--unpack-unreachable=2.weeks.ago, we avoid writing out old,
unreachable loose objects entirely, under the assumption
that running "prune" would simply delete them immediately
anyway. However, this is only valid if we computed the same
set of reachable objects as prune would.

In practice, this is the case, because only git-repack uses
the --unpack-unreachable option with an expiration, and it
always feeds as many objects into the pack as possible. But
we can double-check at runtime just to be sure.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorepack: pack objects mentioned by the index
Jeff King [Fri, 17 Oct 2014 00:44:49 +0000 (20:44 -0400)]
repack: pack objects mentioned by the index

When we pack all objects, we use only the objects reachable
from references and reflogs. This misses any objects which
are reachable from the index, but not yet referenced.

By itself this isn't a big deal; the objects can remain
loose until they are actually used in a commit. However, it
does create a problem when we drop packed but unreachable
objects. We try to optimize out the writing of objects that
we will immediately prune, which means we must follow the
same rules as prune in determining what is reachable. And
prune uses the index for this purpose.

This is rather uncommon in practice, as objects in the index
would not usually have been packed in the first place. But
it could happen in a sequence like:

  1. You make a commit on a branch that references blob X.

  2. You repack, moving X into the pack.

  3. You delete the branch (and its reflog), so that X is
     unreferenced.

  4. You "git add" blob X so that it is now referenced only
     by the index.

  5. You repack again with git-gc. The pack-objects we
     invoke will see that X is neither referenced nor
     recent and not bother loosening it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopack-objects: use argv_array
Jeff King [Fri, 17 Oct 2014 00:44:35 +0000 (20:44 -0400)]
pack-objects: use argv_array

This saves us from having to bump the rp_av count when we
add new traversal options.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoreachable: use revision machinery's --indexed-objects code
Jeff King [Fri, 17 Oct 2014 00:44:30 +0000 (20:44 -0400)]
reachable: use revision machinery's --indexed-objects code

This does the same thing as our custom code, so let's not
repeat ourselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorev-list: add --indexed-objects option
Jeff King [Fri, 17 Oct 2014 00:44:23 +0000 (20:44 -0400)]
rev-list: add --indexed-objects option

There is currently no easy way to ask the revision traversal
machinery to include objects reachable from the index (e.g.,
blobs and trees that have not yet been committed). This
patch adds an option to do so.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorev-list: document --reflog option
Jeff King [Wed, 15 Oct 2014 22:43:28 +0000 (18:43 -0400)]
rev-list: document --reflog option

This is mostly used internally, but it does not hurt to
explain it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot5516: test pushing a tag of an otherwise unreferenced blob
Jeff King [Fri, 17 Oct 2014 00:03:41 +0000 (20:03 -0400)]
t5516: test pushing a tag of an otherwise unreferenced blob

It's not unreasonable to have a tag that points to a blob
that is not part of the normal history. We do this in
git.git to distribute gpg keys. However, we never explicitly
checked in our test suite that this actually works (i.e.,
that pack-objects actually sends the blob because of the tag
mentioning it).

It does in fact work fine, but a recent patch under
discussion broke this, and the test suite didn't notice.
Let's make the test suite more complete.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotraverse_commit_list: support pending blobs/trees with paths
Jeff King [Wed, 15 Oct 2014 22:43:19 +0000 (18:43 -0400)]
traverse_commit_list: support pending blobs/trees with paths

When we call traverse_commit_list, we may have trees and
blobs in the pending array. As we process these, we pass the
"name" field from the pending entry as the path of the
object within the tree (which then becomes the root path if
we recurse into subtrees).

When we set up the traversal in prepare_revision_walk,
though, the "name" field of any pending trees and blobs is
likely to be the ref at which we found the object. We would
not want to make this part of the path (e.g., doing so would
make "git rev-list --objects v2.6.11-tree" in linux.git show
paths like "v2.6.11-tree/Makefile", which is nonsensical).
Therefore prepare_revision_walk sets the name field of each
pending tree and blobs to the empty string.

However, this leaves no room for a caller who does know the
correct path of a pending object to propagate that
information to the revision walker. We can fix this by
making two related changes:

  1. Use the "path" field as the path instead of the "name"
     field in traverse_commit_list. If the path is not set,
     default to "" (which is what we always ended up with in
     the current code, because of prepare_revision_walk).

  2. In prepare_revision_walk, make a complete copy of the
     entry. This makes the path field available to the
     walker (if there is one), solving our problem.
     Leaving the name field intact is now OK, as we do not
     use it as a path due to point (1) above (and we can use
     it to make more meaningful error messages if we want).
     We also make the original "mode" field available to the
     walker, though it does not actually use it.

Note that we still re-add the pending objects and free the
old ones (so we may strdup the path and name only to free
the old ones). This could be made more efficient by simply
copying the object_array entries that we are keeping.
However, that would require more restructuring of the code,
and is not done here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'jc/completion-no-chdir'
Junio C Hamano [Thu, 16 Oct 2014 21:16:49 +0000 (14:16 -0700)]
Merge branch 'jc/completion-no-chdir'

* jc/completion-no-chdir:
  completion: use "git -C $there" instead of (cd $there && git ...)

9 years agoMerge branch 'bw/trace-no-inline-getnanotime'
Junio C Hamano [Thu, 16 Oct 2014 21:16:45 +0000 (14:16 -0700)]
Merge branch 'bw/trace-no-inline-getnanotime'

No file-scope static variables in an inlined function, please.

* bw/trace-no-inline-getnanotime:
  trace.c: do not mark getnanotime() as "inline"

9 years agoMerge branch 'po/everyday-doc'
Junio C Hamano [Thu, 16 Oct 2014 21:16:42 +0000 (14:16 -0700)]
Merge branch 'po/everyday-doc'

"git help everyday" to show the Everyday Git document.

* po/everyday-doc:
  doc: add 'everyday' to 'git help'
  doc: Makefile regularise OBSOLETE_HTML list building
  doc: modernise everyday.txt wording and format in man page style

9 years agogitweb: use start_form, not startform that was removed in CGI.pm 4.04
Roland Mas [Thu, 16 Oct 2014 06:54:47 +0000 (08:54 +0200)]
gitweb: use start_form, not startform that was removed in CGI.pm 4.04

CGI.pm 4.04 removed the startform method, which had previously been
deprecated in favour of start_form.  Changes file for CGI.pm says:

    4.04 2014-09-04
     [ REMOVED / DEPRECATIONS ]
- startform and endform methods removed (previously deprecated,
  you should be using the start_form and end_form methods)

Signed-off-by: Roland Mas <lolando@debian.org>
Reviewed-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot7610-mergetool: add test cases for mergetool.writeToTemp
David Aguilar [Wed, 15 Oct 2014 08:35:19 +0000 (01:35 -0700)]
t7610-mergetool: add test cases for mergetool.writeToTemp

Add tests to ensure that filenames start with "./" when
mergetool.writeToTemp is false and do not start with "./" when
mergetool.writeToTemp is true.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomergetool: add an option for writing to a temporary directory
David Aguilar [Sat, 11 Oct 2014 17:04:45 +0000 (10:04 -0700)]
mergetool: add an option for writing to a temporary directory

Teach mergetool to write files in a temporary directory when
'mergetool.writeToTemp' is true.

This is helpful for tools such as Eclipse which cannot cope with
multiple copies of the same file in the worktree.

Suggested-by: Charles Bailey <charles@hashpling.org>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomergetool: use more conservative temporary filenames
David Aguilar [Fri, 10 Oct 2014 08:19:47 +0000 (01:19 -0700)]
mergetool: use more conservative temporary filenames

Avoid filenames with multiple dots so that overly-picky tools do
not misinterpret their extension.

Previously, foo/bar.ext in the worktree would result in e.g.

./foo/bar.ext.BASE.1234.ext

This can be improved by having only a single .ext and using
underscore instead of dot so that the extension cannot be
misinterpreted.  The resulting path becomes:

./foo/bar_BASE_1234.ext

Suggested-by: Sergio Ferrero <sferrero@ensoftcorp.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotest-lib-functions: adjust style to match CodingGuidelines
David Aguilar [Wed, 15 Oct 2014 08:35:21 +0000 (01:35 -0700)]
test-lib-functions: adjust style to match CodingGuidelines

Prefer "test" over "[ ]" for conditionals.
Prefer "$()" over backticks for command substitutions.
Avoid control structures on a single line with semicolons.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot7610-mergetool: use test_config to isolate tests
David Aguilar [Thu, 16 Oct 2014 05:30:04 +0000 (22:30 -0700)]
t7610-mergetool: use test_config to isolate tests

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomergetools/meld: make usage of `--output` configurable and more robust
David Aguilar [Thu, 16 Oct 2014 04:45:14 +0000 (21:45 -0700)]
mergetools/meld: make usage of `--output` configurable and more robust

Older versions of meld listed --output in `meld --help`.
Newer versions only mention `meld [OPTIONS...]`.
Improve the checks to catch these newer versions.

Add a `mergetool.meld.hasOutput` configuration to allow
overriding the heuristic.

Reported-by: Andrey Novoseltsev <novoselt@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomake add_object_array_with_context interface more sane
Jeff King [Wed, 15 Oct 2014 22:42:57 +0000 (18:42 -0400)]
make add_object_array_with_context interface more sane

When you resolve a sha1, you can optionally keep any context
found during the resolution, including the path and mode of
a tree entry (e.g., when looking up "HEAD:subdir/file.c").

The add_object_array_with_context function lets you then
attach that context to an entry in a list. Unfortunately,
the interface for doing so is horrible. The object_context
structure is large and most object_array users do not use
it. Therefore we keep a pointer to the structure to avoid
burdening other users too much. But that means when we do
use it that we must allocate the struct ourselves. And the
struct contains a fixed PATH_MAX-sized buffer, which makes
this wholly unsuitable for any large arrays.

We can observe that there is only a single user of the
"with_context" variant: builtin/grep.c. And in that use
case, the only element we care about is the path. We can
therefore store only the path as a pointer (the context's
mode field was redundant with the object_array_entry itself,
and nobody actually cared about the surrounding tree). This
still requires a strdup of the pathname, but at least we are
only consuming the minimum amount of memory for each string.

We can also handle the copying ourselves in
add_object_array_*, and free it as appropriate in
object_array_release_entry.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agowrite_sha1_file: freshen existing objects
Jeff King [Wed, 15 Oct 2014 22:42:22 +0000 (18:42 -0400)]
write_sha1_file: freshen existing objects

When we try to write a loose object file, we first check
whether that object already exists. If so, we skip the
write as an optimization. However, this can interfere with
prune's strategy of using mtimes to mark files in progress.

For example, if a branch contains a particular tree object
and is deleted, that tree object may become unreachable, and
have an old mtime. If a new operation then tries to write
the same tree, this ends up as a noop; we notice we
already have the object and do nothing. A prune running
simultaneously with this operation will see the object as
old, and may delete it.

We can solve this by "freshening" objects that we avoid
writing by updating their mtime. The algorithm for doing so
is essentially the same as that of has_sha1_file. Therefore
we provide a new (static) interface "check_and_freshen",
which finds and optionally freshens the object. It's trivial
to implement freshening and simple checking by tweaking a
single parameter.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopack-objects: match prune logic for discarding objects
Jeff King [Wed, 15 Oct 2014 22:42:09 +0000 (18:42 -0400)]
pack-objects: match prune logic for discarding objects

A recent commit taught git-prune to keep non-recent objects
that are reachable from recent ones. However, pack-objects,
when loosening unreachable objects, tries to optimize out
the write in the case that the object will be immediately
pruned. It now gets this wrong, since its rule does not
reflect the new prune code (and this can be seen by running
t6501 with a strategically placed repack).

Let's teach pack-objects similar logic.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopack-objects: refactor unpack-unreachable expiration check
Jeff King [Wed, 15 Oct 2014 22:41:53 +0000 (18:41 -0400)]
pack-objects: refactor unpack-unreachable expiration check

When we are loosening unreachable packed objects, we do not
bother to process objects that would simply be pruned
immediately anyway. The "would be pruned" check is a simple
comparison, but is about to get more complicated. Let's pull
it out into a separate function.

Note that this is slightly less efficient than the original,
which avoided even opening old packs, since no object in
them could pass the current check, which cares only about
the pack mtime.  But the new rules will depend on the exact
object, so we need to perform the check even for old packs.

Note also that we fix a minor buglet when the pack mtime is
exactly the same as the expiration time. The prune code
considers that worth pruning, whereas our check here
considered it worth keeping. This wasn't a big deal. Besides
being unlikely to happen, the result was simply that the
object was loosened and then pruned, missing the
optimization. Still, we can easily fix it while we are here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoprune: keep objects reachable from recent objects
Jeff King [Wed, 15 Oct 2014 22:41:35 +0000 (18:41 -0400)]
prune: keep objects reachable from recent objects

Our current strategy with prune is that an object falls into
one of three categories:

  1. Reachable (from ref tips, reflogs, index, etc).

  2. Not reachable, but recent (based on the --expire time).

  3. Not reachable and not recent.

We keep objects from (1) and (2), but prune objects in (3).
The point of (2) is that these objects may be part of an
in-progress operation that has not yet updated any refs.

However, it is not always the case that objects for an
in-progress operation will have a recent mtime. For example,
the object database may have an old copy of a blob (from an
abandoned operation, a branch that was deleted, etc). If we
create a new tree that points to it, a simultaneous prune
will leave our tree, but delete the blob. Referencing that
tree with a commit will then work (we check that the tree is
in the object database, but not that all of its referred
objects are), as will mentioning the commit in a ref. But
the resulting repo is corrupt; we are missing the blob
reachable from a ref.

One way to solve this is to be more thorough when
referencing a sha1: make sure that not only do we have that
sha1, but that we have objects it refers to, and so forth
recursively. The problem is that this is very expensive.
Creating a parent link would require traversing the entire
object graph!

Instead, this patch pushes the extra work onto prune, which
runs less frequently (and has to look at the whole object
graph anyway). It creates a new category of objects: objects
which are not recent, but which are reachable from a recent
object. We do not prune these objects, just like the
reachable and recent ones.

This lets us avoid the recursive check above, because if we
have an object, even if it is unreachable, we should have
its referent. We can make a simple inductive argument that
with this patch, this property holds (that there are no
objects with missing referents in the repository):

  0. When we have no objects, we have nothing to refer or be
     referred to, so the property holds.

  1. If we add objects to the repository, their direct
     referents must generally exist (e.g., if you create a
     tree, the blobs it references must exist; if you create
     a commit to point at the tree, the tree must exist).
     This is already the case before this patch. And it is
     not 100% foolproof (you can make bogus objects using
     `git hash-object`, for example), but it should be the
     case for normal usage.

     Therefore for any sequence of object additions, the
     property will continue to hold.

  2. If we remove objects from the repository, then we will
     not remove a child object (like a blob) if an object
     that refers to it is being kept. That is the part
     implemented by this patch.

     Note, however, that our reachability check and the
     actual pruning are not atomic. So it _is_ still
     possible to violate the property (e.g., an object
     becomes referenced just as we are deleting it). This
     patch is shooting for eliminating problems where the
     mtimes of dependent objects differ by hours or days,
     and one is dropped without the other. It does nothing
     to help with short races.

Naively, the simplest way to implement this would be to add
all recent objects as tips to the reachability traversal.
However, this does not perform well. In a recently-packed
repository, all reachable objects will also be recent, and
therefore we have to look at each object twice. This patch
instead performs the reachability traversal, then follows up
with a second traversal for recent objects, skipping any
that have already been marked.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1_file: add for_each iterators for loose and packed objects
Jeff King [Wed, 15 Oct 2014 22:41:21 +0000 (18:41 -0400)]
sha1_file: add for_each iterators for loose and packed objects

We typically iterate over the reachable objects in a
repository by starting at the tips and walking the graph.
There's no easy way to iterate over all of the objects,
including unreachable ones. Let's provide a way of doing so.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agocount-objects: use for_each_loose_file_in_objdir
Jeff King [Wed, 15 Oct 2014 22:41:11 +0000 (18:41 -0400)]
count-objects: use for_each_loose_file_in_objdir

This drops our line count considerably, and should make
things more readable by keeping the counting logic separate
from the traversal.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agocount-objects: do not use xsize_t when counting object size
Jeff King [Wed, 15 Oct 2014 22:40:58 +0000 (18:40 -0400)]
count-objects: do not use xsize_t when counting object size

The point of xsize_t is to safely cast an off_t into a size_t
(because we are about to mmap). But in count-objects, we are
summing the sizes in an off_t. Using xsize_t means that
count-objects could fail on a 32-bit system with a 4G
object (not likely, as other parts of git would fail, but
we should at least be correct here).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoprune-packed: use for_each_loose_file_in_objdir
Jeff King [Wed, 15 Oct 2014 22:40:53 +0000 (18:40 -0400)]
prune-packed: use for_each_loose_file_in_objdir

This saves us from manually traversing the directory
structure ourselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoreachable: mark index blobs as SEEN
Jeff King [Wed, 15 Oct 2014 22:40:37 +0000 (18:40 -0400)]
reachable: mark index blobs as SEEN

When we mark all reachable objects for pruning, that
includes blobs mentioned by the index. However, we do not
mark these with the SEEN flag, as we do for objects that we
find by traversing (we also do not add them to the pending
list, but that is because there is nothing further to
traverse with them).

This doesn't cause any problems with prune, because it
checks only that the object exists in the global object
hash, and not its flags. However, let's mark these objects
to be consistent and avoid any later surprises.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoprune: factor out loose-object directory traversal
Jeff King [Wed, 15 Oct 2014 22:38:55 +0000 (18:38 -0400)]
prune: factor out loose-object directory traversal

Prune has to walk $GIT_DIR/objects/?? in order to find the
set of loose objects to prune. Other parts of the code
(e.g., count-objects) want to do the same. Let's factor it
out into a reusable for_each-style function.

Note that this is not quite a straight code movement. The
original code had strange behavior when it found a file of
the form "[0-9a-f]{2}/.{38}" that did _not_ contain all hex
digits. It executed a "break" from the loop, meaning that we
stopped pruning in that directory (but still pruned other
directories!). This was probably a bug; we do not want to
process the file as an object, but we should keep going
otherwise (and that is how the new code handles it).

We are also a little more careful with loose object
directories which fail to open. The original code silently
ignored any failures, but the new code will complain about
any problems besides ENOENT.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoreachable: reuse revision.c "add all reflogs" code
Jeff King [Wed, 15 Oct 2014 22:38:31 +0000 (18:38 -0400)]
reachable: reuse revision.c "add all reflogs" code

We want to add all reflog entries as tips for finding
reachable objects. The revision machinery can already do
this (to support "rev-list --reflog"); we can reuse that
code.

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