git
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 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 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 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 agocontacts: add a Makefile to generate docs and install
Sebastian Schuberth [Wed, 15 Oct 2014 18:50:18 +0000 (20:50 +0200)] 
contacts: add a Makefile to generate docs and install

Also add a gitignore file for generated files.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubtree: add an install-html target
Sebastian Schuberth [Wed, 15 Oct 2014 18:49:28 +0000 (20:49 +0200)] 
subtree: add an install-html target

Also adjust ignore rules accordingly.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot7610-mergetool: add missing && and remove commented-out code
David Aguilar [Wed, 15 Oct 2014 08:35:18 +0000 (01:35 -0700)] 
t7610-mergetool: add missing && and remove commented-out code

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot7610-mergetool: use tabs instead of a mix of tabs and spaces
David Aguilar [Wed, 15 Oct 2014 08:35:17 +0000 (01:35 -0700)] 
t7610-mergetool: use tabs instead of a mix of tabs and spaces

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoref_transaction_commit: bail out on failure to remove a ref
Jonathan Nieder [Fri, 29 Aug 2014 00:01:35 +0000 (17:01 -0700)] 
ref_transaction_commit: bail out on failure to remove a ref

When removal of a loose or packed ref fails, bail out instead of
trying to finish the transaction.  This way, a single error message
can be printed (instead of multiple messages being concatenated by
mistake) and the operator can try to solve the underlying problem
before there is a chance to muck things up even more.

In particular, when git fails to remove a ref, git goes on to try to
delete the reflog.  Exiting early lets us keep the reflog.

When git succeeds in deleting a ref A and fails to remove a ref B, it
goes on to try to delete both reflogs.  It would be better to just
remove the reflog for A, but that would be a more invasive change.
Failing early means we keep both reflogs, which puts the operator in a
good position to understand the problem and recover.

A long term goal is to avoid these problems altogether and roll back
the transaction on failure.  That kind of transactionality will have
to wait for a later series (the plan for which is to make all
destructive work happen in a single update of the packed-refs file).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agolockfile: remove unable_to_lock_error
Jonathan Nieder [Thu, 28 Aug 2014 23:41:34 +0000 (16:41 -0700)] 
lockfile: remove unable_to_lock_error

The former caller uses unable_to_lock_message now.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: do not permit err == NULL
Jonathan Nieder [Thu, 28 Aug 2014 23:42:37 +0000 (16:42 -0700)] 
refs.c: do not permit err == NULL

Some functions that take a strbuf argument to append an error treat
!err as an indication that the message should be suppressed (e.g.,
ref_update_reject_duplicates).  Others write the message to stderr on
!err (e.g., repack_without_refs).  Others crash (e.g.,
ref_transaction_update).

Some of these behaviors are for historical reasons and others were
accidents.  Luckily no callers pass err == NULL any more.  Simplify
by consistently requiring the strbuf argument.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoremote rm/prune: print a message when writing packed-refs fails
Ronnie Sahlberg [Thu, 11 Sep 2014 15:42:57 +0000 (08:42 -0700)] 
remote rm/prune: print a message when writing packed-refs fails

Until v2.1.0-rc0~22^2~11 (refs.c: add an err argument to
repack_without_refs, 2014-06-20), repack_without_refs forgot to
provide an error message when commit_packed_refs fails.  Even today,
it only provides a message for callers that pass a non-NULL err
parameter.  Internal callers in refs.c pass non-NULL err but
"git remote" does not.

That means that "git remote rm" and "git remote prune" can fail
without printing a message about why.  Fix them by passing in a
non-NULL err parameter and printing the returned message.

This is the last caller to a ref handling function passing err ==
NULL.  A later patch can drop support for err == NULL, avoiding such
problems in the future.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofor-each-ref: skip and warn about broken ref names
Ronnie Sahlberg [Fri, 5 Sep 2014 21:35:17 +0000 (14:35 -0700)] 
for-each-ref: skip and warn about broken ref names

Print a warning message for any bad ref names we find in the repo and
skip them so callers don't have to deal with parsing them.

It might be useful in the future to have a flag where we would not
skip these refs for those callers that want to and are prepared (for
example by using a --format argument with %0 as a delimiter after the
ref name).

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: allow listing and deleting badly named refs
Ronnie Sahlberg [Wed, 3 Sep 2014 18:45:43 +0000 (11:45 -0700)] 
refs.c: allow listing and deleting badly named refs

We currently do not handle badly named refs well:

  $ cp .git/refs/heads/master .git/refs/heads/master.....@\*@\\.
  $ git branch
    fatal: Reference has invalid format: 'refs/heads/master.....@*@\.'
  $ git branch -D master.....@\*@\\.
    error: branch 'master.....@*@\.' not found.

Users cannot recover from a badly named ref without manually finding
and deleting the loose ref file or appropriate line in packed-refs.
Making that easier will make it easier to tweak the ref naming rules
in the future, for example to forbid shell metacharacters like '`'
and '"', without putting people in a state that is hard to get out of.

So allow "branch --list" to show these refs and allow "branch -d/-D"
and "update-ref -d" to delete them.  Other commands (for example to
rename refs) will continue to not handle these refs but can be changed
in later patches.

Details:

In resolving functions, refuse to resolve refs that don't pass the
git-check-ref-format(1) check unless the new RESOLVE_REF_ALLOW_BAD_NAME
flag is passed.  Even with RESOLVE_REF_ALLOW_BAD_NAME, refuse to
resolve refs that escape the refs/ directory and do not match the
pattern [A-Z_]* (think "HEAD" and "MERGE_HEAD").

In locking functions, refuse to act on badly named refs unless they
are being deleted and either are in the refs/ directory or match [A-Z_]*.

Just like other invalid refs, flag resolved, badly named refs with the
REF_ISBROKEN flag, treat them as resolving to null_sha1, and skip them
in all iteration functions except for for_each_rawref.

Flag badly named refs (but not symrefs pointing to badly named refs)
with a REF_BAD_NAME flag to make it easier for future callers to
notice and handle them specially.  For example, in a later patch
for-each-ref will use this flag to detect refs whose names can confuse
callers parsing for-each-ref output.

In the transaction API, refuse to create or update badly named refs,
but allow deleting them (unless they try to escape refs/ and don't match
[A-Z_]*).

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotest: put tests for handling of bad ref names in one place
Ronnie Sahlberg [Thu, 25 Sep 2014 22:02:39 +0000 (15:02 -0700)] 
test: put tests for handling of bad ref names in one place

There's no straightforward way to grep for all tests dealing with
invalid refs.  Put them in a single test script so it is easy to see
what functionality has not been exercised with bad ref names yet.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopacked-ref cache: forbid dot-components in refnames
Jonathan Nieder [Fri, 26 Sep 2014 19:22:22 +0000 (12:22 -0700)] 
packed-ref cache: forbid dot-components in refnames

Since v1.7.9-rc1~10^2 (write_head_info(): handle "extra refs" locally,
2012-01-06), this trick to keep track of ".have" refs that are only
valid on the wire and not on the filesystem is not needed any more.

Simplify by removing support for the REFNAME_DOT_COMPONENT flag.

This means we'll be slightly stricter with invalid refs found in a
packed-refs file or during clone.  read_loose_refs() already checks
for and skips refnames with .components so it is not affected.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobranch -d: simplify by using RESOLVE_REF_READING
Ronnie Sahlberg [Thu, 11 Sep 2014 17:34:36 +0000 (10:34 -0700)] 
branch -d: simplify by using RESOLVE_REF_READING

When "git branch -d" reads the branch it is about to delete, it used
to avoid passing the RESOLVE_REF_READING ('treat missing ref as
error') flag because a symref pointing to a nonexistent ref would show
up as missing instead of as something that could be deleted.  To check
if a ref is actually missing, we then check

 - is it a symref?
 - if not, did it resolve to null_sha1?

Now we pass RESOLVE_REF_NO_RECURSE and the correct information is
returned for a symref even when it points to a missing ref.  Simplify
by relying on RESOLVE_REF_READING.

No functional change intended.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobranch -d: avoid repeated symref resolution
Jonathan Nieder [Thu, 11 Sep 2014 01:22:48 +0000 (18:22 -0700)] 
branch -d: avoid repeated symref resolution

If a repository gets in a broken state with too much symref nesting,
it cannot be repaired with "git branch -d":

 $ git symbolic-ref refs/heads/nonsense refs/heads/nonsense
 $ git branch -d nonsense
 error: branch 'nonsense' not found.

Worse, "git update-ref --no-deref -d" doesn't work for such repairs
either:

 $ git update-ref -d refs/heads/nonsense
 error: unable to resolve reference refs/heads/nonsense: Too many levels of symbolic links

Fix both by teaching resolve_ref_unsafe a new RESOLVE_REF_NO_RECURSE
flag and passing it when appropriate.

Callers can still read the value of a symref (for example to print a
message about it) with that flag set --- resolve_ref_unsafe will
resolve one level of symrefs and stop there.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoreflog test: test interaction with detached HEAD
Junio C Hamano [Sat, 13 Sep 2014 17:52:25 +0000 (10:52 -0700)] 
reflog test: test interaction with detached HEAD

A proposed patch produced broken HEAD reflog entries when checking out
anything other than a branch.  The testsuite still passed, so it took
a few days for the bug to be noticed.

Add tests checking the content of the reflog after detaching and
reattaching HEAD so we don't have to rely on manual testing to catch
such problems in the future.

[jn: using 'log -g --format=%H' instead of parsing --oneline output,
 resetting state in each test so they can be safely reordered or
 skipped]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: change resolve_ref_unsafe reading argument to be a flags field
Ronnie Sahlberg [Tue, 15 Jul 2014 19:59:36 +0000 (12:59 -0700)] 
refs.c: change resolve_ref_unsafe reading argument to be a flags field

resolve_ref_unsafe takes a boolean argument for reading (a nonexistent ref
resolves successfully for writing but not for reading).  Change this to be
a flags field instead, and pass the new constant RESOLVE_REF_READING when
we want this behaviour.

While at it, swap two of the arguments in the function to put output
arguments at the end.  As a nice side effect, this ensures that we can
catch callers that were unaware of the new API so they can be audited.

Give the wrapper functions resolve_refdup and read_ref_full the same
treatment for consistency.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: make write_ref_sha1 static
Ronnie Sahlberg [Mon, 28 Apr 2014 22:36:58 +0000 (15:36 -0700)] 
refs.c: make write_ref_sha1 static

No external users call write_ref_sha1 any more so let's declare it static.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofetch.c: change s_update_ref to use a ref transaction
Ronnie Sahlberg [Mon, 28 Apr 2014 20:49:07 +0000 (13:49 -0700)] 
fetch.c: change s_update_ref to use a ref transaction

Change s_update_ref to use a ref transaction for the ref update.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: ref_transaction_commit: distinguish name conflicts from other errors
Ronnie Sahlberg [Fri, 16 May 2014 21:14:38 +0000 (14:14 -0700)] 
refs.c: ref_transaction_commit: distinguish name conflicts from other errors

In _commit, ENOTDIR can happen in the call to lock_ref_sha1_basic, either
when we lstat the new refname or if the name checking function reports that
the same type of conflict happened.  In both cases, it means that we can not
create the new ref due to a name conflict.

Start defining specific return codes for _commit.  TRANSACTION_NAME_CONFLICT
refers to a failure to create a ref due to a name conflict with another ref.
TRANSACTION_GENERIC_ERROR is for all other errors.

When "git fetch" is creating refs, name conflicts differ from other errors in
that they are likely to be resolved by running "git remote prune <remote>".
"git fetch" currently inspects errno to decide whether to give that advice.
Once it switches to the transaction API, it can check for
TRANSACTION_NAME_CONFLICT instead.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: pass a list of names to skip to is_refname_available
Ronnie Sahlberg [Thu, 1 May 2014 18:16:07 +0000 (11:16 -0700)] 
refs.c: pass a list of names to skip to is_refname_available

Change is_refname_available to take a list of strings to exclude when
checking for conflicts instead of just one single name. We can already
exclude a single name for the sake of renames. This generalizes that support.

ref_transaction_commit already tracks a set of refs that are being deleted
in an array.  This array is then used to exclude refs from being written to
the packed-refs file.  At some stage we will want to change this array to a
struct string_list and then we can pass it to is_refname_available via the
call to lock_ref_sha1_basic.  That will allow us to perform transactions
that perform multiple renames as long as there are no conflicts within the
starting or ending state.

For example, that would allow a single transaction that contains two
renames that are both individually conflicting:

   m -> n/n
   n -> m/m

No functional change intended yet.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: call lock_ref_sha1_basic directly from commit
Ronnie Sahlberg [Thu, 1 May 2014 17:43:39 +0000 (10:43 -0700)] 
refs.c: call lock_ref_sha1_basic directly from commit

Skip using the lock_any_ref_for_update wrapper and call lock_ref_sha1_basic
directly from the commit function.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: refuse to lock badly named refs in lock_ref_sha1_basic
Ronnie Sahlberg [Thu, 1 May 2014 17:40:10 +0000 (10:40 -0700)] 
refs.c: refuse to lock badly named refs in lock_ref_sha1_basic

Move the check for check_refname_format from lock_any_ref_for_update to
lock_ref_sha1_basic.  At some later stage we will get rid of
lock_any_ref_for_update completely.  This has no visible impact to callers
except for the inability to lock badly named refs, which is not possible
today already for other reasons.(*)

Keep lock_any_ref_for_update as a no-op wrapper.  It is the public facing
version of this interface and keeping it as a separate function will make
it easier to experiment with the internal lock_ref_sha1_basic signature.

(*) For example, if lock_ref_sha1_basic checks the refname format and
refuses to lock badly named refs, it will not be possible to delete
such refs because the first step of deletion is to lock the ref.  We
currently already fail in that case because these refs are not recognized
to exist:

 $ cp .git/refs/heads/master .git/refs/heads/echo...\*\*
 $ git branch -D .git/refs/heads/echo...\*\*
 error: branch '.git/refs/heads/echo...**' not found.

This has been broken for a while.  Later patches in the series will start
repairing the handling of badly named refs.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorename_ref: don't ask read_ref_full where the ref came from
Ronnie Sahlberg [Wed, 30 Apr 2014 19:41:04 +0000 (12:41 -0700)] 
rename_ref: don't ask read_ref_full where the ref came from

We call read_ref_full with a pointer to flags from rename_ref but since
we never actually use the returned flags we can just pass NULL here instead.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: pass the ref log message to _create/delete/update instead of _commit
Ronnie Sahlberg [Wed, 30 Apr 2014 19:22:42 +0000 (12:22 -0700)] 
refs.c: pass the ref log message to _create/delete/update instead of _commit

Change the ref transaction API so that we pass the reflog message to the
create/delete/update functions instead of to ref_transaction_commit.
This allows different reflog messages for each ref update in a multi-ref
transaction.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: add an err argument to delete_ref_loose
Ronnie Sahlberg [Thu, 15 May 2014 15:25:23 +0000 (08:25 -0700)] 
refs.c: add an err argument to delete_ref_loose

Add an err argument to delete_ref_loose so that we can pass a descriptive
error string back to the caller. Pass the err argument from transaction
commit to this function so that transaction users will have a nice error
string if the transaction failed due to delete_ref_loose.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agowrapper.c: add a new function unlink_or_msg
Ronnie Sahlberg [Wed, 16 Jul 2014 18:20:36 +0000 (11:20 -0700)] 
wrapper.c: add a new function unlink_or_msg

This behaves like unlink_or_warn except that on failure it writes the message
to its 'err' argument, which the caller can display in an appropriate way or
ignore.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agorefs.c: lock_ref_sha1_basic is used for all refs
Ronnie Sahlberg [Thu, 2 Oct 2014 14:59:02 +0000 (07:59 -0700)] 
refs.c: lock_ref_sha1_basic is used for all refs

lock_ref_sha1_basic is used to lock refs that sit directly in the .git
dir such as HEAD and MERGE_HEAD in addition to the more ordinary refs
under "refs/".  Remove the note claiming otherwise.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agowrapper.c: remove/unlink_or_warn: simplify, treat ENOENT as success
Ronnie Sahlberg [Wed, 16 Jul 2014 18:01:18 +0000 (11:01 -0700)] 
wrapper.c: remove/unlink_or_warn: simplify, treat ENOENT as success

Simplify the function warn_if_unremovable slightly. Additionally, change
behaviour slightly. If we failed to remove the object because the object
does not exist, we can still return success back to the caller since none of
the callers depend on "fail if the file did not exist".

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomv test: recreate mod/ directory instead of relying on stale copy
Jonathan Nieder [Wed, 10 Sep 2014 21:01:46 +0000 (14:01 -0700)] 
mv test: recreate mod/ directory instead of relying on stale copy

The tests for 'git mv moves a submodule' functionality often run
commands like

git mv sub mod/sub

to move a submodule into a subdirectory.  Just like plain /bin/mv,
this is supposed to succeed if the mod/ parent directory exists
and fail if it doesn't exist.

Usually these tests mkdir the parent directory beforehand, but some
instead rely on it being left behind by previous tests.

More precisely, when 'git reset --hard' tries to move to a state where
mod/sub is not present any more, it would perform the following
operations:

rmdir("mod/sub")
rmdir("mod")

The first fails with ENOENT because the test script removed mod/sub
with "rm -rf" already, so 'reset --hard' doesn't bother to move on to
the second, and the mod/ directory is kept around.

Better to explicitly remove and re-create the mod/ directory so later
tests don't have to depend on the directory left behind by the earlier
ones at all (making it easier to rearrange or skip some tests in the
file or to tweak 'reset --hard' behavior without breaking unrelated
tests).

Noticed while testing a patch that fixes the reset --hard behavior
described above.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agocolor_parse: do not mention variable name in error message
Jeff King [Tue, 7 Oct 2014 19:33:09 +0000 (15:33 -0400)] 
color_parse: do not mention variable name in error message

Originally the color-parsing function was used only for
config variables. It made sense to pass the variable name so
that the die() message could be something like:

  $ git -c color.branch.plain=bogus branch
  fatal: bad color value 'bogus' for variable 'color.branch.plain'

These days we call it in other contexts, and the resulting
error messages are a little confusing:

  $ git log --pretty='%C(bogus)'
  fatal: bad color value 'bogus' for variable '--pretty format'

  $ git config --get-color foo.bar bogus
  fatal: bad color value 'bogus' for variable 'command line'

This patch teaches color_parse to complain only about the
value, and then return an error code. Config callers can
then propagate that up to the config parser, which mentions
the variable name. Other callers can provide a custom
message. After this patch these three cases now look like:

  $ git -c color.branch.plain=bogus branch
  error: invalid color value: bogus
  fatal: unable to parse 'color.branch.plain' from command-line config

  $ git log --pretty='%C(bogus)'
  error: invalid color value: bogus
  fatal: unable to parse --pretty format

  $ git config --get-color foo.bar bogus
  error: invalid color value: bogus
  fatal: unable to parse default color value

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopass config slots as pointers instead of offsets
Jonathan Nieder [Tue, 7 Oct 2014 19:16:57 +0000 (15:16 -0400)] 
pass config slots as pointers instead of offsets

Many config-parsing helpers, like parse_branch_color_slot,
take the name of a config variable and an offset to the
"slot" name (e.g., "color.branch.plain" is passed along with
"13" to effectively pass "plain"). This is leftover from the
time that these functions would die() on error, and would
want the full variable name for error reporting.

These days they do not use the full variable name at all.
Passing a single pointer to the slot name is more natural,
and lets us more easily adjust the callers to use skip_prefix
to avoid manually writing offset numbers.

This is effectively a continuation of 9e1a5eb, which did the
same for parse_diff_color_slot. This patch covers all of the
remaining similar constructs.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoUpdate draft release notes to 2.2
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>
9 years agoMerge branch 'bc/asciidoc-pretty-formats-fix'
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

9 years agoMerge branch 'rs/plug-leak-in-bundle'
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()

9 years agoMerge branch 'rs/more-uses-of-skip-prefix'
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

9 years agoMerge branch 'rs/mailsplit'
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

9 years agoMerge branch 'rs/sha1-array-test'
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

9 years agoMerge branch 'mh/lockfile-stdio'
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

9 years agoMerge branch 'mh/lockfile'
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
  ...

9 years agoMerge branch 'sk/tag-contains-wo-recursion'
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

9 years agoMerge branch 'da/completion-show-signature'
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

9 years agoMerge branch 'rs/daemon-fixes'
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

9 years agoMerge branch 'dt/cache-tree-repair'
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

9 years agoMerge branch 'so/rebase-doc-fork-point'
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

9 years agoMerge branch 'da/include-compat-util-first-in-c'
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

9 years agotest-lib.sh: support -x option for shell-tracing
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>
9 years agot1308: fix broken here document in test script
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>
9 years agoDocumentation: add documentation for 'git interpret-trailers'
Christian Couder [Mon, 13 Oct 2014 18:16:33 +0000 (20:16 +0200)] 
Documentation: add documentation for 'git interpret-trailers'

While at it add git-interpret-trailers to "command-list.txt".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: add tests for commands in config file
Christian Couder [Mon, 13 Oct 2014 18:16:32 +0000 (20:16 +0200)] 
trailer: add tests for commands in config file

And add a few other tests for some special cases.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: execute command from 'trailer.<name>.command'
Christian Couder [Mon, 13 Oct 2014 18:16:31 +0000 (20:16 +0200)] 
trailer: execute command from 'trailer.<name>.command'

Let the user specify a command that will give on its standard output
the value to use for the specified trailer.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: add tests for "git interpret-trailers"
Christian Couder [Mon, 13 Oct 2014 18:16:30 +0000 (20:16 +0200)] 
trailer: add tests for "git interpret-trailers"

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: add interpret-trailers command
Christian Couder [Mon, 13 Oct 2014 18:16:29 +0000 (20:16 +0200)] 
trailer: add interpret-trailers command

This patch adds the "git interpret-trailers" command.
This command uses the previously added process_trailers()
function in trailer.c.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: put all the processing together and print
Christian Couder [Mon, 13 Oct 2014 18:16:28 +0000 (20:16 +0200)] 
trailer: put all the processing together and print

This patch adds the process_trailers() function that
calls all the previously added processing functions
and then prints the results on the standard output.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: parse trailers from file or stdin
Christian Couder [Mon, 13 Oct 2014 18:16:27 +0000 (20:16 +0200)] 
trailer: parse trailers from file or stdin

Read trailers from a file or from stdin, parse the trailers and then
put the result into a doubly linked list.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: process command line trailer arguments
Christian Couder [Mon, 13 Oct 2014 18:16:26 +0000 (20:16 +0200)] 
trailer: process command line trailer arguments

Parse the trailer command line arguments and put
the result into an arg_tok doubly linked list.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: read and process config information
Christian Couder [Mon, 13 Oct 2014 18:16:25 +0000 (20:16 +0200)] 
trailer: read and process config information

Read the configuration to get trailer information, and then process
it and store it in a doubly linked list.

The config information is stored in the list whose first item is
pointed to by:

static struct trailer_item *first_conf_item;

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: process trailers from input message and arguments
Christian Couder [Mon, 13 Oct 2014 18:16:24 +0000 (20:16 +0200)] 
trailer: process trailers from input message and arguments

Implement the logic to process trailers from the input message
and from arguments.

At the beginning trailers from the input message are in their
own "in_tok" doubly linked list, and trailers from arguments
are in their own "arg_tok" doubly linked list.

The lists are traversed and when an "arg_tok" should be "applied",
it is removed from its list and inserted into the "in_tok" list.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotrailer: add data structures and basic functions
Christian Couder [Mon, 13 Oct 2014 18:16:23 +0000 (20:16 +0200)] 
trailer: add data structures and basic functions

We will use a doubly linked list to store all information
about trailers and their configuration.

This way we can easily remove or add trailers to or from
trailer lists while traversing the lists in either direction.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation: fix mismatched delimiters in git-imap-send
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>
9 years agoDocumentation: adjust document title underlining
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>
9 years agoreceive-pack: plug minor memory leak in unpack()
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>
9 years agot5304: use helper to report failure of "test foo = bar"
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>
9 years agot5304: use test_path_is_* instead of "test -f"
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>
9 years agodoc: add 'everyday' to 'git help'
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>
9 years agodoc: Makefile regularise OBSOLETE_HTML list building
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>
9 years agodoc: modernise everyday.txt wording and format in man page style
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>
9 years agocompletion: use "git -C $there" instead of (cd $there && git ...)
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>
9 years agoDocumentation: fix misrender of pretty-formats in Asciidoctor
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>
9 years agoUpdate draft release notes to 2.2
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>
9 years agoMerge branch 'sp/stream-clean-filter'
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()

9 years agoMerge branch 'bw/use-write-script-in-tests'
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

9 years agoMerge branch 'nd/archive-pathspec'
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

9 years agoMerge branch 'jc/push-cert'
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
  ...

9 years agoSync with maint
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`

9 years agoMerge branch 'maint-2.0' into maint
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`

9 years agoMerge branch 'maint-1.9' into maint-2.0
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`

9 years agoMerge branch 'maint-1.8.5' into maint-1.9
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`

9 years agoMerge branch 'jk/mbox-from-line' into maint
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

9 years agocompletion: add --show-signature for log and show
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>
9 years agouse skip_prefix() to avoid more magic numbers
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>
9 years agogit-tag.txt: Add a missing hyphen to `-s`
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>
9 years agomailsplit: remove unnecessary unlink(2) call
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>