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()
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
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"
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
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.
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 ...)
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"
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
Junio C Hamano [Tue, 14 Oct 2014 17:59:04 +0000 (10:59 -0700)]
Update draft release notes to 2.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Tue, 14 Oct 2014 17:50:14 +0000 (10:50 -0700)]
Merge branch 'bc/asciidoc-pretty-formats-fix'
* bc/asciidoc-pretty-formats-fix:
Documentation: fix misrender of pretty-formats in Asciidoctor
Junio C Hamano [Tue, 14 Oct 2014 17:50:09 +0000 (10:50 -0700)]
Merge branch 'rs/plug-leak-in-bundle'
* rs/plug-leak-in-bundle:
bundle: plug minor memory leak in is_tag_in_date_range()
Junio C Hamano [Tue, 14 Oct 2014 17:50:07 +0000 (10:50 -0700)]
Merge branch 'rs/more-uses-of-skip-prefix'
* rs/more-uses-of-skip-prefix:
use skip_prefix() to avoid more magic numbers
Junio C Hamano [Tue, 14 Oct 2014 17:50:00 +0000 (10:50 -0700)]
Merge branch 'rs/mailsplit'
* rs/mailsplit:
mailsplit: remove unnecessary unlink(2) call
Junio C Hamano [Tue, 14 Oct 2014 17:49:56 +0000 (10:49 -0700)]
Merge branch 'rs/sha1-array-test'
* rs/sha1-array-test:
sha1-lookup: handle duplicates in sha1_pos()
sha1-array: add test-sha1-array and basic tests
Junio C Hamano [Tue, 14 Oct 2014 17:49:51 +0000 (10:49 -0700)]
Merge branch 'mh/lockfile-stdio'
* mh/lockfile-stdio:
commit_packed_refs(): reimplement using fdopen_lock_file()
dump_marks(): reimplement using fdopen_lock_file()
fdopen_lock_file(): access a lockfile using stdio
Junio C Hamano [Tue, 14 Oct 2014 17:49:45 +0000 (10:49 -0700)]
Merge branch 'mh/lockfile'
The lockfile API and its users have been cleaned up.
* mh/lockfile: (38 commits)
lockfile.h: extract new header file for the functions in lockfile.c
hold_locked_index(): move from lockfile.c to read-cache.c
hold_lock_file_for_append(): restore errno before returning
get_locked_file_path(): new function
lockfile.c: rename static functions
lockfile: rename LOCK_NODEREF to LOCK_NO_DEREF
commit_lock_file_to(): refactor a helper out of commit_lock_file()
trim_last_path_component(): replace last_path_elm()
resolve_symlink(): take a strbuf parameter
resolve_symlink(): use a strbuf for internal scratch space
lockfile: change lock_file::filename into a strbuf
commit_lock_file(): use a strbuf to manage temporary space
try_merge_strategy(): use a statically-allocated lock_file object
try_merge_strategy(): remove redundant lock_file allocation
struct lock_file: declare some fields volatile
lockfile: avoid transitory invalid states
git_config_set_multivar_in_file(): avoid call to rollback_lock_file()
dump_marks(): remove a redundant call to rollback_lock_file()
api-lockfile: document edge cases
commit_lock_file(): rollback lock file on failure to rename
...
Junio C Hamano [Tue, 14 Oct 2014 17:49:41 +0000 (10:49 -0700)]
Merge branch 'sk/tag-contains-wo-recursion'
* sk/tag-contains-wo-recursion:
t7004: give the test a bit more stack space
Junio C Hamano [Tue, 14 Oct 2014 17:49:35 +0000 (10:49 -0700)]
Merge branch 'da/completion-show-signature'
* da/completion-show-signature:
completion: add --show-signature for log and show
Junio C Hamano [Tue, 14 Oct 2014 17:49:22 +0000 (10:49 -0700)]
Merge branch 'rs/daemon-fixes'
"git daemon" (with NO_IPV6 build configuration) used to incorrectly
use the hostname even when gethostbyname() reported that the given
hostname is not found.
* rs/daemon-fixes:
daemon: remove write-only variable maxfd
daemon: fix error message after bind()
daemon: handle gethostbyname() error
Junio C Hamano [Tue, 14 Oct 2014 17:49:11 +0000 (10:49 -0700)]
Merge branch 'dt/cache-tree-repair'
This fixes a topic that has graduated to 'master'.
* dt/cache-tree-repair:
t0090: avoid passing empty string to printf %d
Junio C Hamano [Tue, 14 Oct 2014 17:49:06 +0000 (10:49 -0700)]
Merge branch 'so/rebase-doc-fork-point'
* so/rebase-doc-fork-point:
Documentation/git-rebase.txt: document when --fork-point is auto-enabled
Junio C Hamano [Tue, 14 Oct 2014 17:49:00 +0000 (10:49 -0700)]
Merge branch 'da/include-compat-util-first-in-c'
Code clean-up.
* da/include-compat-util-first-in-c:
cleanups: ensure that git-compat-util.h is included first
Jeff King [Fri, 10 Oct 2014 06:47:27 +0000 (02:47 -0400)]
test-lib.sh: support -x option for shell-tracing
Usually running a test under "-v" makes it clear which
command is failing. However, sometimes it can be useful to
also see a complete trace of the shell commands being run in
the test. You can do so without any support from the test
suite by running "sh -x tXXXX-foo.sh". However, this
produces quite a large bit of output, as we see a trace of
the entire test suite.
This patch instead introduces a "-x" option to the test
scripts (i.e., "./tXXXX-foo.sh -x"). When enabled, this
turns on "set -x" only for the tests themselves. This can
still be a bit verbose, but should keep things to a more
manageable level. You can even use "--verbose-only" to see
the trace only for a specific test.
The implementation is a little invasive. We turn on the "set
-x" inside the "eval" of the test code. This lets the eval
itself avoid being reported in the trace (which would be
long, and redundant with the verbose listing we already
showed). And then after the eval runs, we do some trickery
with stderr to avoid showing the "set +x" to the user.
We also show traces for test_cleanup functions (since they
can impact the test outcome, too). However, we do avoid
running the noop ":" cleanup (the default if the test does
not use test_cleanup at all), as it creates unnecessary
noise in the "set -x" output.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Mon, 13 Oct 2014 22:25:38 +0000 (15:25 -0700)]
t1308: fix broken here document in test script
Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson [Sat, 11 Oct 2014 23:37:34 +0000 (23:37 +0000)]
Documentation: fix mismatched delimiters in git-imap-send
The documentation for git-imap-send uses block delimiters with
mismatched lengths, which Asciidoctor doesn't support. As a result, the
page is misrendered. Adjust the delimiters so that they are of the same
length.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson [Sat, 11 Oct 2014 23:37:33 +0000 (23:37 +0000)]
Documentation: adjust document title underlining
AsciiDoc specification states that in two-line titles, the title
underline has to be the same length as the title text, plus or minus two
characters. Asciidoctor, however, requires that this must be plus or
minus one character. Adjust the underlines to be the same length as the
title text to improve compatibility.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Sat, 11 Oct 2014 11:00:16 +0000 (13:00 +0200)]
receive-pack: plug minor memory leak in unpack()
The argv_array used in unpack() is never freed. Instead of adding
explicit calls to argv_array_clear() use the args member of struct
child_process and let run_command() and friends clean up for us.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King [Fri, 10 Oct 2014 06:11:14 +0000 (02:11 -0400)]
t5304: use helper to report failure of "test foo = bar"
For small outputs, we sometimes use:
test "$(some_cmd)" = "something we expect"
instead of a full test_cmp. The downside of this is that
when it fails, there is no output at all from the script.
Let's introduce a small helper to make tests easier to
debug.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King [Fri, 10 Oct 2014 06:07:00 +0000 (02:07 -0400)]
t5304: use test_path_is_* instead of "test -f"
This is slightly more robust (checking "! test -f" would not
notice a directory of the same name, though that is not
likely to happen here). It also makes debugging easier, as
the test script will output a message on failure.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Philip Oakley [Fri, 10 Oct 2014 21:25:37 +0000 (22:25 +0100)]
doc: add 'everyday' to 'git help'
The "Everyday GIT With 20 Commands Or So" is not accessible via the
Git help system. Move everyday.txt to giteveryday.txt so that "git
help everyday" works, and create a new placeholder file everyday.html
to refer people who follow existing URLs to the updated location.
giteveryday.txt now formats well with AsciiDoc as a man page and
refreshed content to a more command modern style.
Add 'everyday' to the help --guides list and update git(1) and 5
other links to giteveryday.
Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Philip Oakley [Fri, 10 Oct 2014 21:25:36 +0000 (22:25 +0100)]
doc: Makefile regularise OBSOLETE_HTML list building
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Philip Oakley [Fri, 10 Oct 2014 21:25:35 +0000 (22:25 +0100)]
doc: modernise everyday.txt wording and format in man page style
Refresh the contents of everyday.txt contents to a more modern
command style. Also update the mark-up so that it can be formatted
as a man page with AsciiDoc ready for transfer to the Git guides.
The transfer is in subsequent commits.
Guidance on modernising the command style provided by Junio at [1],
[2] and [3].
[1] Individual Developer, both Standalone and Participant
http://article.gmane.org/gmane.comp.version-control.git/254269
[2] Integrator
http://article.gmane.org/gmane.comp.version-control.git/254502
[3] Administrator
http://article.gmane.org/gmane.comp.version-control.git/254824
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Thu, 9 Oct 2014 20:45:21 +0000 (13:45 -0700)]
completion: use "git -C $there" instead of (cd $there && git ...)
We have had "git -C $there" to first go to a different directory
and run a Git command without changing the arguments for quite some
time. Use it instead of (cd $there && git ...) in the completion
script.
This allows us to lose the work-around for misfeatures of modern
interactive-minded shells that make "cd" unusable in scripts (e.g.
end users' $CDPATH taking us to unexpected places in any POSIX
shell, and chpwd functions spewing unwanted output in zsh).
Based on Øystein Walle's idea, which was raised during the
discussion on the solution by Brandon Turner for a problem zsh users
had with RVM which mucks with chpwd_functions in users' environments
(https://github.com/wayneeseguin/rvm/issues/3076).
As $root variable, which is used to direct where to chdir to, is set
to "." based on if $2 to __git_index_files is set (not if it is empty),
the only caller of the function is fixed not to pass the optional $2
when it does not want us to switch to a different directory. Otherwise
we would end up doing "git -C '' command...", which would not work.
Maybe we would want "git -C '' command..." to mean "do not chdir
anywhere", but that is a spearate topic.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson [Wed, 8 Oct 2014 20:46:10 +0000 (20:46 +0000)]
Documentation: fix misrender of pretty-formats in Asciidoctor
Neither the AsciiDoc nor the Asciidoctor documentation specify whether
the same number of delimiter characters must be used to end a block as
to begin it, although both sets of documentation show exactly matching
pairs. AsciiDoc allows mismatches, but AsciiDoctor apparently does not.
Adjust the pretty formats documentation to use matching pairs to prevent
a misrendering where the remainder of the document was rendered as a
listing block.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Wed, 8 Oct 2014 20:08:55 +0000 (13:08 -0700)]
Update draft release notes to 2.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Wed, 8 Oct 2014 20:05:32 +0000 (13:05 -0700)]
Merge branch 'sp/stream-clean-filter'
When running a required clean filter, we do not have to mmap the
original before feeding the filter. Instead, stream the file
contents directly to the filter and process its output.
* sp/stream-clean-filter:
sha1_file: don't convert off_t to size_t too early to avoid potential die()
convert: stream from fd to required clean filter to reduce used address space
copy_fd(): do not close the input file descriptor
mmap_limit: introduce GIT_MMAP_LIMIT to allow testing expected mmap size
memory_limit: use git_env_ulong() to parse GIT_ALLOC_LIMIT
config.c: add git_env_ulong() to parse environment variable
convert: drop arguments other than 'path' from would_convert_to_git()
Junio C Hamano [Wed, 8 Oct 2014 20:05:29 +0000 (13:05 -0700)]
Merge branch 'bw/use-write-script-in-tests'
* bw/use-write-script-in-tests:
t/lib-credential: use write_script
Junio C Hamano [Wed, 8 Oct 2014 20:05:25 +0000 (13:05 -0700)]
Merge branch 'nd/archive-pathspec'
"git archive" learned to filter what gets archived with pathspec.
* nd/archive-pathspec:
archive: support filtering paths with glob
Junio C Hamano [Wed, 8 Oct 2014 20:05:15 +0000 (13:05 -0700)]
Merge branch 'jc/push-cert'
Allow "git push" request to be signed, so that it can be verified and
audited, using the GPG signature of the person who pushed, that the
tips of branches at a public repository really point the commits
the pusher wanted to, without having to "trust" the server.
* jc/push-cert: (24 commits)
receive-pack::hmac_sha1(): copy the entire SHA-1 hash out
signed push: allow stale nonce in stateless mode
signed push: teach smart-HTTP to pass "git push --signed" around
signed push: fortify against replay attacks
signed push: add "pushee" header to push certificate
signed push: remove duplicated protocol info
send-pack: send feature request on push-cert packet
receive-pack: GPG-validate push certificates
push: the beginning of "git push --signed"
pack-protocol doc: typofix for PKT-LINE
gpg-interface: move parse_signature() to where it should be
gpg-interface: move parse_gpg_output() to where it should be
send-pack: clarify that cmds_sent is a boolean
send-pack: refactor inspecting and resetting status and sending commands
send-pack: rename "new_refs" to "need_pack_data"
receive-pack: factor out capability string generation
send-pack: factor out capability string generation
send-pack: always send capabilities
send-pack: refactor decision to send update per ref
send-pack: move REF_STATUS_REJECT_NODELETE logic a bit higher
...
Junio C Hamano [Tue, 7 Oct 2014 20:41:03 +0000 (13:41 -0700)]
Sync with maint
* maint:
git-tag.txt: Add a missing hyphen to `-s`
Junio C Hamano [Tue, 7 Oct 2014 20:40:51 +0000 (13:40 -0700)]
Merge branch 'maint-2.0' into maint
* maint-2.0:
git-tag.txt: Add a missing hyphen to `-s`
Junio C Hamano [Tue, 7 Oct 2014 20:40:39 +0000 (13:40 -0700)]
Merge branch 'maint-1.9' into maint-2.0
* maint-1.9:
git-tag.txt: Add a missing hyphen to `-s`
Junio C Hamano [Tue, 7 Oct 2014 20:40:19 +0000 (13:40 -0700)]
Merge branch 'maint-1.8.5' into maint-1.9
* maint-1.8.5:
git-tag.txt: Add a missing hyphen to `-s`
Junio C Hamano [Tue, 7 Oct 2014 20:39:24 +0000 (13:39 -0700)]
Merge branch 'jk/mbox-from-line' into maint
Some MUAs mangled a line in a message that begins with "From " to
">From " when writing to a mailbox file and feeding such an input to
"git am" used to lose such a line.
* jk/mbox-from-line:
mailinfo: work around -Wstring-plus-int warning
mailinfo: make ">From" in-body header check more robust
David Aguilar [Sat, 4 Oct 2014 23:20:38 +0000 (16:20 -0700)]
completion: add --show-signature for log and show
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Sat, 4 Oct 2014 18:54:50 +0000 (20:54 +0200)]
use skip_prefix() to avoid more magic numbers
Continue where
ae021d87 (use skip_prefix to avoid magic numbers) left off
and use skip_prefix() in more places for determining the lengths of prefix
strings to avoid using dependent constants and other indirect methods.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Wieland Hoffmann [Sat, 4 Oct 2014 16:27:16 +0000 (18:27 +0200)]
git-tag.txt: Add a missing hyphen to `-s`
Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Sat, 4 Oct 2014 08:41:13 +0000 (10:41 +0200)]
mailsplit: remove unnecessary unlink(2) call
The output file hasn't been created at this point, yet, so there is no
need to delete it when exiting early.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Fri, 3 Oct 2014 22:40:24 +0000 (00:40 +0200)]
bundle: plug minor memory leak in is_tag_in_date_range()
Free the buffer returned by read_sha1_file() even if no valid tagger
line is found.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 11:14:49 +0000 (13:14 +0200)]
commit_packed_refs(): reimplement using fdopen_lock_file()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 11:14:48 +0000 (13:14 +0200)]
dump_marks(): reimplement using fdopen_lock_file()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 11:14:47 +0000 (13:14 +0200)]
fdopen_lock_file(): access a lockfile using stdio
Add a new function, fdopen_lock_file(), which returns a FILE pointer
open to the lockfile. If a stream is open on a lock_file object, it is
closed using fclose() on commit, rollback, or close_lock_file().
This change will allow callers to use stdio to write to a lockfile
without having to muck around in the internal representation of the
lock_file object (callers will be rewritten in upcoming commits).
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:42 +0000 (12:28 +0200)]
lockfile.h: extract new header file for the functions in lockfile.c
Move the interface declaration for the functions in lockfile.c from
cache.h to a new file, lockfile.h. Add #includes where necessary (and
remove some redundant includes of cache.h by files that already
include builtin.h).
Move the documentation of the lock_file state diagram from lockfile.c
to the new header file.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:41 +0000 (12:28 +0200)]
hold_locked_index(): move from lockfile.c to read-cache.c
lockfile.c contains the general API for locking any file. Code
specifically about the index file doesn't belong here.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:40 +0000 (12:28 +0200)]
hold_lock_file_for_append(): restore errno before returning
Callers who don't pass LOCK_DIE_ON_ERROR might want to examine errno
to see what went wrong, so restore errno before returning.
In fact this function only has one caller, add_to_alternates_file(),
and it *does* use LOCK_DIE_ON_ERROR, but, you know, think of future
generations.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:39 +0000 (12:28 +0200)]
get_locked_file_path(): new function
Add a function to return the path of the file that is locked by a
lock_file object. This reduces the knowledge that callers have to have
about the lock_file layout.
Suggested-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:38 +0000 (12:28 +0200)]
lockfile.c: rename static functions
* remove_lock_file() -> remove_lock_files()
* remove_lock_file_on_signal() -> remove_lock_files_on_signal()
Suggested-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:37 +0000 (12:28 +0200)]
lockfile: rename LOCK_NODEREF to LOCK_NO_DEREF
This makes it harder to misread the name as LOCK_NODE_REF.
Suggested-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:36 +0000 (12:28 +0200)]
commit_lock_file_to(): refactor a helper out of commit_lock_file()
commit_locked_index(), when writing to an alternate index file,
duplicates (poorly) the code in commit_lock_file(). And anyway, it
shouldn't have to know so much about the internal workings of lockfile
objects. So extract a new function commit_lock_file_to() that does the
work common to the two functions, and call it from both
commit_lock_file() and commit_locked_index().
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:35 +0000 (12:28 +0200)]
trim_last_path_component(): replace last_path_elm()
Rewrite last_path_elm() to take a strbuf parameter and to trim off the
last path name element in place rather than returning a pointer to the
beginning of the last path name element. This simplifies the function
a bit and makes it integrate better with its caller, which is now also
strbuf-based. Rename the function accordingly and a bit less tersely.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:34 +0000 (12:28 +0200)]
resolve_symlink(): take a strbuf parameter
Change resolve_symlink() to take a strbuf rather than a string as
parameter. This simplifies the code and removes an arbitrary pathname
length restriction. It also means that lock_file's filename field no
longer needs to be initialized to a large size.
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:33 +0000 (12:28 +0200)]
resolve_symlink(): use a strbuf for internal scratch space
Aside from shortening and simplifying the code, this removes another
place where the path name length is arbitrarily limited.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:32 +0000 (12:28 +0200)]
lockfile: change lock_file::filename into a strbuf
For now, we still make sure to allocate at least PATH_MAX characters
for the strbuf because resolve_symlink() doesn't know how to expand
the space for its return value. (That will be fixed in a moment.)
Another alternative would be to just use a strbuf as scratch space in
lock_file() but then store a pointer to the naked string in struct
lock_file. But lock_file objects are often reused. By reusing the
same strbuf, we can avoid having to reallocate the string most times
when a lock_file object is reused.
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:31 +0000 (12:28 +0200)]
commit_lock_file(): use a strbuf to manage temporary space
Avoid relying on the filename length restrictions that are currently
checked by lock_file().
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:30 +0000 (12:28 +0200)]
try_merge_strategy(): use a statically-allocated lock_file object
Even the one lockfile object needn't be allocated each time the
function is called. Instead, define one statically-allocated
lock_file object and reuse it for every call.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:29 +0000 (12:28 +0200)]
try_merge_strategy(): remove redundant lock_file allocation
By the time the "if" block is entered, the lock_file instance from the
main function block is no longer in use, so re-use that one instead of
allocating a second one.
Note that the "lock" variable in the "if" block shadowed the "lock"
variable at function scope, so the only change needed is to remove the
inner definition.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:28 +0000 (12:28 +0200)]
struct lock_file: declare some fields volatile
The function remove_lock_file_on_signal() is used as a signal handler.
It is not realistic to make the signal handler conform strictly to the
C standard, which is very restrictive about what a signal handler is
allowed to do. But let's increase the likelihood that it will work:
The lock_file_list global variable and several fields from struct
lock_file are used by the signal handler. Declare those values
"volatile" to (1) force the main process to write the values to RAM
promptly, and (2) prevent updates to these fields from being reordered
in a way that leaves an opportunity for a jump to the signal handler
while the object is in an inconsistent state.
We don't mark the filename field volatile because that would prevent
the use of strcpy(), and it is anyway unlikely that a compiler
re-orders a strcpy() call across other expressions. So in practice it
should be possible to get away without "volatile" in the "filename"
case.
Suggested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:27 +0000 (12:28 +0200)]
lockfile: avoid transitory invalid states
Because remove_lock_file() can be called any time by the signal
handler, it is important that any lock_file objects that are in the
lock_file_list are always in a valid state. And since lock_file
objects are often reused (but are never removed from lock_file_list),
that means we have to be careful whenever mutating a lock_file object
to always keep it in a well-defined state.
This was formerly not the case, because part of the state was encoded
by setting lk->filename to the empty string vs. a valid filename. It
is wrong to assume that this string can be updated atomically; for
example, even
strcpy(lk->filename, value)
is unsafe. But the old code was even more reckless; for example,
strcpy(lk->filename, path);
if (!(flags & LOCK_NODEREF))
resolve_symlink(lk->filename, max_path_len);
strcat(lk->filename, ".lock");
During the call to resolve_symlink(), lk->filename contained the name
of the file that was being locked, not the name of the lockfile. If a
signal were raised during that interval, then the signal handler would
have deleted the valuable file!
We could probably continue to use the filename field to encode the
state by being careful to write characters 1..N-1 of the filename
first, and then overwrite the NUL at filename[0] with the first
character of the filename, but that would be awkward and error-prone.
So, instead of using the filename field to determine whether the
lock_file object is active, add a new field "lock_file::active" for
this purpose. Be careful to set this field only when filename really
contains the name of a file that should be deleted on cleanup.
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:26 +0000 (12:28 +0200)]
git_config_set_multivar_in_file(): avoid call to rollback_lock_file()
After commit_lock_file() is called, then the lock_file object is
necessarily either committed or rolled back. So there is no need to
call rollback_lock_file() again in either of these cases.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:25 +0000 (12:28 +0200)]
dump_marks(): remove a redundant call to rollback_lock_file()
When commit_lock_file() fails, it now always calls
rollback_lock_file() internally, so there is no need to call that
function here.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:24 +0000 (12:28 +0200)]
api-lockfile: document edge cases
* Document the behavior of commit_lock_file() when it fails, namely
that it rolls back the lock_file object and sets errno
appropriately.
* Document the behavior of rollback_lock_file() when called for a
lock_file object that has already been committed or rolled back,
namely that it is a NOOP.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:23 +0000 (12:28 +0200)]
commit_lock_file(): rollback lock file on failure to rename
If rename() fails, call rollback_lock_file() to delete the lock file
(in case it is still present) and reset the filename field to the
empty string so that the lockfile object is left in a valid state.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:22 +0000 (12:28 +0200)]
close_lock_file(): if close fails, roll back
If closing an open lockfile fails, then we cannot be sure of the
contents of the lockfile, so there is nothing sensible to do but
delete it. This change also insures that the lock_file object is left
in a defined state in this error path (namely, unlocked).
The only caller that is ultimately affected by this change is
try_merge_strategy() -> write_locked_index(), which can call
close_lock_file() via various execution paths. This caller uses a
static lock_file object which previously could have been reused after
a failed close_lock_file() even though it was still in locked state.
This change causes the lock_file object to be unlocked on failure,
thus fixing this error-handling path.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:21 +0000 (12:28 +0200)]
commit_lock_file(): die() if called for unlocked lockfile object
It was previously a bug to call commit_lock_file() with a lock_file
object that was not active (an illegal access would happen within the
function). It was presumably never done, but this would be an easy
programming error to overlook. So before continuing, do a consistency
check that the lock_file object really is locked.
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:20 +0000 (12:28 +0200)]
commit_lock_file(): inline temporary variable
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:19 +0000 (12:28 +0200)]
remove_lock_file(): call rollback_lock_file()
It does just what we need.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:18 +0000 (12:28 +0200)]
lock_file(): exit early if lockfile cannot be opened
This is a bit easier to read than the old version, which nested part
of the non-error code in an "if" block.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:17 +0000 (12:28 +0200)]
prepare_index(): declare return value to be (const char *)
Declare the return value to be const to make it clear that we aren't
giving callers permission to write over the string that it points at.
(The return value is the filename field of a struct lock_file, which
can be used by a signal handler at any time and therefore shouldn't be
tampered with.)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:16 +0000 (12:28 +0200)]
delete_ref_loose(): don't muck around in the lock_file's filename
It's bad manners. Especially since there could be a signal during the
call to unlink_or_warn(), in which case the signal handler will see
the wrong filename and delete the reference file, leaving the lockfile
behind.
So make our own copy to work with.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:15 +0000 (12:28 +0200)]
cache.h: define constants LOCK_SUFFIX and LOCK_SUFFIX_LEN
There are a few places that use these values, so define constants for
them.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:14 +0000 (12:28 +0200)]
lockfile.c: document the various states of lock_file objects
Document the valid states of lock_file objects, how they get into each
state, and how the state is encoded in the object's fields.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:13 +0000 (12:28 +0200)]
lock_file(): always initialize and register lock_file object
The purpose of this change is to make the state diagram for
lock_file objects simpler and deterministic.
If locking fails, lock_file() sometimes leaves the lock_file object
partly initialized, but sometimes not. It sometimes registers the
object in lock_file_list, but sometimes not. This makes the state
diagram for lock_file objects effectively indeterministic and hard
to reason about. A future patch will also change the filename field
into a strbuf, which needs more involved initialization, so it will
become even more important that the state of a lock_file object is
well-defined after a failed attempt to lock.
The ambiguity doesn't currently have any ill effects, because
lock_file objects cannot be removed from the lock_file_list anyway.
But to make it easier to document and reason about the code, make
this behavior consistent: *always* initialize the lock_file object
and *always* register it in lock_file_list the first time it is
used, regardless of whether an error occurs.
While we're at it, make sure that all of the lock_file fields are
initialized to values appropriate for an unlocked object; the caller
is only responsible for making sure that on_list is set to zero before
the first time it is used.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:12 +0000 (12:28 +0200)]
hold_lock_file_for_append(): release lock on errors
If there is an error copying the old contents to the lockfile, roll
back the lockfile before exiting so that the lockfile is not held
until process cleanup.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:11 +0000 (12:28 +0200)]
lockfile: unlock file if lockfile permissions cannot be adjusted
If the call to adjust_shared_perm() fails, lock_file returns -1, which
to the caller looks like any other failure to lock the file. So in
this case, roll back the lockfile before returning so that the lock
file is deleted immediately and the lockfile object is left in a
predictable state (namely, unlocked). Previously, the lockfile was
retained until process cleanup in this situation.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:10 +0000 (12:28 +0200)]
rollback_lock_file(): set fd to -1
When rolling back the lockfile, call close_lock_file() so that the
lock_file's fd field gets set back to -1. This keeps the lock_file
object in a valid state, which is important because these objects are
allowed to be reused. It also makes it unnecessary to check whether
the file has already been closed, because close_lock_file() takes care
of that.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:09 +0000 (12:28 +0200)]
rollback_lock_file(): exit early if lock is not active
Eliminate a layer of nesting.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:08 +0000 (12:28 +0200)]
rollback_lock_file(): do not clear filename redundantly
It is only necessary to clear the lock_file's filename field if it was
not already clear.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:07 +0000 (12:28 +0200)]
close_lock_file(): exit (successfully) if file is already closed
Suggested-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:06 +0000 (12:28 +0200)]
api-lockfile: revise and expand the documentation
Document a couple more functions and the flags argument as used by
hold_lock_file_for_update() and hold_lock_file_for_append().
Reorganize the document to make it more accessible.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Helped-by: Junio Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty [Wed, 1 Oct 2014 10:28:05 +0000 (12:28 +0200)]
unable_to_lock_die(): rename function from unable_to_lock_index_die()
This function is used for other things besides the index, so rename it
accordingly.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Wed, 1 Oct 2014 10:21:57 +0000 (12:21 +0200)]
daemon: remove write-only variable maxfd
It became unused when
6573faff (NO_IPV6 support for git daemon) replaced
select() with poll().
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Wed, 1 Oct 2014 10:18:15 +0000 (12:18 +0200)]
daemon: fix error message after bind()
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Wed, 1 Oct 2014 10:16:17 +0000 (12:16 +0200)]
daemon: handle gethostbyname() error
If the user-supplied hostname can't be found then we should not use it.
We already avoid doing that in the non-NO_IPV6 case by checking if the
return value of getaddrinfo() is zero (success). Do the same in the
NO_IPV6 case and make sure the return value of gethostbyname() isn't
NULL before dereferencing this pointer.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Wed, 1 Oct 2014 15:02:37 +0000 (17:02 +0200)]
sha1-lookup: handle duplicates in sha1_pos()
If the first 18 bytes of the SHA1's of all entries are the same then
sha1_pos() dies and reports that the lower and upper limits of the
binary search were the same that this wasn't supposed to happen. This
is wrong because the remaining two bytes could still differ.
Furthermore: It wouldn't be a problem if they actually were the same,
i.e. if all entries have the same SHA1. The code already handles
duplicates just fine. Simply remove the erroneous check.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Wed, 1 Oct 2014 15:00:33 +0000 (17:00 +0200)]
sha1-array: add test-sha1-array and basic tests
Helped-by: Jeff King <peff@peff.net>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe [Tue, 30 Sep 2014 17:42:03 +0000 (19:42 +0200)]
t0090: avoid passing empty string to printf %d
FreeBSD's printf(1) doesn't accept empty strings for numerical format
specifiers:
$ printf "%d\n" "" >/dev/null; echo $?
printf: : expected numeric value
1
Initialize the AWK variable c to make sure the shell variable
subtree_count always contains a numerical value, in order to keep the
subsequently called printf happy.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Tue, 30 Sep 2014 05:17:57 +0000 (22:17 -0700)]
Sync with 2.1.2
* maint:
Git 2.1.2
Junio C Hamano [Tue, 30 Sep 2014 05:17:23 +0000 (22:17 -0700)]
Merge branch 'jt/itimer-autoconf'
setitmer(2) and related API elements can be configured from
Makefile but autoconf did not know about it.
* jt/itimer-autoconf:
autoconf: check for setitimer()
autoconf: check for struct itimerval
git-compat-util.h: add missing semicolon after struct itimerval
Junio C Hamano [Tue, 30 Sep 2014 05:17:22 +0000 (22:17 -0700)]
Merge branch 'jc/test-lazy-prereq'
Test-script clean-up.
* jc/test-lazy-prereq:
tests: drop GIT_*_TIMING_TESTS environment variable support
Junio C Hamano [Tue, 30 Sep 2014 05:17:21 +0000 (22:17 -0700)]
Merge branch 'sb/merge-recursive-copy-paste-fix'
"git merge-recursive" had a small bug that could have made it
mishandle "one side deleted, the other side did not touch it" in a
rare corner case, where the other side actually did touch to cause
the blob object names to be different but both blobs before and
after the change normalize to the same (e.g. correcting mistake to
check in a blob with CRLF line endings by replacing it with another
blob that records the same contents with LF line endings).
* sb/merge-recursive-copy-paste-fix:
merge-recursive: remove stale commented debugging code
merge-recursive: fix copy-paste mistake