remote: write correct fetch spec when renaming remote 'remote'

When renaming a remote whose name is contained in a configured fetch
refspec for that remote, we currently replace the first occurrence of
the remote name in the refspec. This is correct in most cases, but
breaks if the remote name occurs in the fetch refspec before the
expected place. For example, we currently change

[remote "remote"]
	url = git://git.kernel.org/pub/scm/git/git.git
	fetch = +refs/heads/*:refs/remotes/remote/*

into

[remote "origin"]
	url = git://git.kernel.org/pub/scm/git/git.git
	fetch = +refs/heads/*:refs/origins/remote/*

Reduce the risk of changing incorrect sections of the refspec by
matching the entire ":refs/remotes/<name>/" instead of just "<name>".

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote: "rename o foo" should not rename ref "origin/bar"

When renaming a remote called 'o' using 'git remote rename o foo', git
should also rename any remote-tracking branches for the remote. This
does happen, but any remote-tracking branches starting with
'refs/remotes/o', such as 'refs/remotes/origin/bar', will also be
renamed (to 'refs/remotes/foorigin/bar' in this case).

Fix it by simply matching one more character, up to the slash
following the remote name.

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote rename: warn when refspec was not updated

When renaming a remote, we also try to update the fetch refspec
accordingly, but only if it has the default format. For others, such
as refs/heads/master:refs/heads/origin, we are conservative and leave
it untouched. Let's give the user a warning about refspecs that are
not updated, so he can manually update the config if necessary.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote: only update remote-tracking branch if updating refspec

'git remote rename' will only update the remote's fetch refspec if it
looks like a default one. If the remote has no default fetch refspec,
as in

[remote "origin"]
    url = git://git.kernel.org/pub/scm/git/git.git
    fetch = +refs/heads/*:refs/remotes/upstream/*

we would not update the fetch refspec and even if there is a ref
called "refs/remotes/origin/master", we should not rename it, since it
was not created by fetching from the remote.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
date.c: Support iso8601 timezone formats

Timezone designators in the following formats are all valid according to
ISO8601:2004, section 4.3.2:

    [+-]hh, [+-]hhmm, [+-]hh:mm

but we have ignored the ones with colon so far.

Signed-off-by: Haitao Li <lihaitao@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation: basic configuration of notes.rewriteRef

Users had problems finding a working setting for notes.rewriteRef.
Document how to enable rewriting for notes/commits, which should be a
safe setting.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-update-index: refer to 'ls-files'

'ls-files' refers to 'update-index' to show how the 'assume unchanged'
bit can be seen. This makes the connection 'bi-directional'.

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9159-*.sh: skip for mergeinfo test for svn <= 1.4

t9159 relies on the command-line syntax of svn >= 1.5.  Given the
declining install base of older svn versions, it is not worth our time to
support older svn syntax.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees: print "Aborting" to stderr

display_error_msgs() prints all the errors to stderr already (if any),
followed by "Aborting" (if any) to stdout. Make the latter go to stderr
instead.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-read-tree.txt: language and typography fixes

Fix a few missing articles and such, and mark-up 'commands' and `files`
appropriately.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-read-tree.txt: correct sparse-checkout and skip-worktree description

The description of .git/info/sparse-checkout and
skip-worktree is exactly the opposite of what is true, which is:

If a file matches a pattern in sparse-checkout, then (it is to be
checked out and therefore) skip-worktree is unset for that file;
otherwise, it is set (so that it is not checked out).

Currently, the opposite is documented, and (consistently) read-tree's
behavior with respect to bit flips is descibed incorrectly.

Fix it.

In hindsight, it would have been much better to have a "sparse-ignore"
or "sparse-skip" file so that an empty file would mean a full checkout,
and the file logic would be analogous to that of .gitignore, excludes
and skip-worktree.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool: Use args as pathspec to unmerged files

Mergetool now treats its path arguments as a pathspec (like other git
subcommands), restricting action to the given files and directories.
Files matching the pathspec are filtered so mergetool only acts on
unmerged paths; previously it would assume each path argument was in an
unresolved state, and get confused when it couldn't check out their
other stages.

Running "git mergetool subdir" will prompt to resolve all conflicted
blobs under subdir.

Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Acked-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool: no longer need to save standard input

Earlier code wanted to run merge_file and prompt_after_failed_merge
both of which wanted to read from the standard input of the entire
script inside a while loop, which read from a pipe, and in order to
do so, it redirected the original standard input to another file
descriptor. We no longer need to do so after the previous change.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-read-tree.txt: update sparse checkout examples

The negation example uses '*' to match everything. This used to work
before 9037026 (unpack-trees: fix sparse checkout's "unable to match
directories") because back then, the list of paths is used to match
sparse patterns, so with the patterns

    *
    !subdir/

subdir/ always matches any path that start with subdir/ and "*" has no
chance to get tested. The result is subdir is excluded.

After the said commit, a tree structure is dynamically created and
sparse pattern matching now follows closely how read_directory()
applies .gitignore. This solves one problem, but reveals another one.

With this new strategy, "!subdir/" rule will be only tested once when
"subdir" directory is examined. Entries inside subdir, when examined,
will match "*" and are (correctly) re-added again because any rules
without a slash will match at every directory level. In the end, "*"
can revert every negation rules.

In order to correctly exclude subdir, we must use

    /*
    !subdir

to limit "match all" rule at top level only.

"*" rule has no actual use in sparse checkout and can be confusing to
users. While we can automatically turn "*" to "/*", this violates
.gitignore definition. Instead, discourage "*" in favor of "/*" (in
the second example).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb: Fix links to lines in blobs when javascript-actions are enabled

The fixLinks() function adds 'js=1' to each link that does not already
have 'js' query parameter specified. This is used to signal to gitweb
that the browser can actually do javascript when these links are used.

There are two problems with the existing code:

  1. URIs with fragment and 'js' query parameter, like e.g.

        ...foo?js=0#l199

     were not recognized as having 'js' query parameter already.

  2. The 'js' query parameter, in the form of either '?js=1' or ';js=1'
     was appended at the end of URI, even if it included a fragment
     (had a hash part).  This lead to the incorrect links like this

        ...foo#l199?js=1

     instead of adding query parameter as last part of query, but
     before the fragment part, i.e.

        ...foo?js=1#l199

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes_merge_commit(): do not pass temporary buffer to other function

It is unsafe to pass a temporary buffer as an argument to
read_directory().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reindent closing bracket using tab instead of spaces

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
make the sample pre-commit hook script reject names with newlines, too

The sample pre-commit hook script would fail to reject a file name like
"a\nb" because of the way newlines are handled in "$(...)".  Adjust the
test to count filtered bytes and require there be 0.  Also print all
diagnostics to standard error, not stdout, so they will actually be seen.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'sn/doc-update-index-assume-unchanged' into maint-1.7.3

* sn/doc-update-index-assume-unchanged:
  Documentation/git-update-index: refer to 'ls-files'
Merge branch 'maint-1.7.3' into maint-1.7.4

* maint-1.7.3:
  make the sample pre-commit hook script reject names with newlines, too
  Reindent closing bracket using tab instead of spaces
  Documentation/git-update-index: refer to 'ls-files'