gitweb.git
pull: update unborn branch tip after indexJeff King Thu, 20 Jun 2013 22:36:31 +0000 (18:36 -0400)

pull: update unborn branch tip after index

When commit d09e79c taught git to pull into an unborn
branch, it first updated the unborn branch to point at the
pulled commit, and then used read-tree to update the index
and working tree. That ordering made sense, since any
failure of the latter step would be due to filesystem
errors, and one could then recover with "git reset --hard".

Later, commit 4b3ffe5 added extra safety for existing files
in the working tree by asking read-tree to bail out when it
would overwrite such a file. This error mode is much less
"your pull failed due to random errors" and more like "we
reject this pull because it would lose data". In that case,
it makes sense not to update the HEAD ref, just as a regular
rejected merge would do.

This patch reverses the order of the update-ref and
read-tree calls, so that we do not touch the HEAD ref at all if a
merge is rejected. This also means that we would not update
HEAD in case of a transient filesystem error, but those are
presumably less rare (and one can still recover by repeating
the pull, or by accessing FETCH_HEAD directly).

While we're reorganizing the code, we can drop the "exit 1"
from the end of our command chain. We exit immediately
either way, and just calling exit without an argument will
use the exit code from the last command.

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

for_each_ref: load all loose refs before packed refsJeff King Thu, 20 Jun 2013 08:37:53 +0000 (10:37 +0200)

for_each_ref: load all loose refs before packed refs

If we are iterating through the refs using for_each_ref (or
any of its sister functions), we can get into a race
condition with a simultaneous "pack-refs --prune" that looks
like this:

0. We have a large number of loose refs, and a few packed
refs. refs/heads/z/foo is loose, with no matching entry
in the packed-refs file.

1. Process A starts iterating through the refs. It loads
the packed-refs file from disk, then starts lazily
traversing through the loose ref directories.

2. Process B, running "pack-refs --prune", writes out the
new packed-refs file. It then deletes the newly packed
refs, including refs/heads/z/foo.

3. Meanwhile, process A has finally gotten to
refs/heads/z (it traverses alphabetically). It
descends, but finds nothing there. It checks its
cached view of the packed-refs file, but it does not
mention anything in "refs/heads/z/" at all (it predates
the new file written by B in step 2).

The traversal completes successfully without mentioning
refs/heads/z/foo at all (the name, of course, isn't
important; but the more refs you have and the farther down
the alphabetical list a ref is, the more likely it is to hit
the race). If refs/heads/z/foo did exist in the packed refs
file at state 0, we would see an entry for it, but it would
show whatever sha1 the ref had the last time it was packed
(which could be an arbitrarily long time ago).

This can be especially dangerous when process A is "git
prune", as it means our set of reachable tips will be
incomplete, and we may erroneously prune objects reachable
from that tip (the same thing can happen if "repack -ad" is
used, as it simply drops unreachable objects that are
packed).

This patch solves it by loading all of the loose refs for
our traversal into our in-memory cache, and then refreshing
the packed-refs cache. Because a pack-refs writer will
always put the new packed-refs file into place before
starting the prune, we know that any loose refs we fail to
see will either truly be missing, or will have already been
put in the packed-refs file by the time we refresh.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

get_packed_ref_cache: reload packed-refs file when... Jeff King Thu, 20 Jun 2013 08:37:52 +0000 (10:37 +0200)

get_packed_ref_cache: reload packed-refs file when it changes

Once we read the packed-refs file into memory, we cache it
to save work on future ref lookups. However, our cache may
be out of date with respect to what is on disk if another
process is simultaneously packing the refs. Normally it
is acceptable for us to be a little out of date, since there
is no guarantee whether we read the file before or after the
simultaneous update. However, there is an important special
case: our packed-refs file must be up to date with respect
to any loose refs we read. Otherwise, we risk the following
race condition:

0. There exists a loose ref refs/heads/master.

1. Process A starts and looks up the ref "master". It
first checks $GIT_DIR/master, which does not exist. It
then loads (and caches) the packed-refs file to see if
"master" exists in it, which it does not.

2. Meanwhile, process B runs "pack-refs --all --prune". It
creates a new packed-refs file which contains
refs/heads/master, and removes the loose copy at
$GIT_DIR/refs/heads/master.

3. Process A continues its lookup, and eventually tries
$GIT_DIR/refs/heads/master. It sees that the loose ref
is missing, and falls back to the packed-refs file. But
it examines its cached version, which does not have
refs/heads/master. After trying a few other prefixes,
it reports master as a non-existent ref.

There are many variants (e.g., step 1 may involve process A
looking up another ref entirely, so even a fully qualified
refname can fail). One of the most interesting ones is if
"refs/heads/master" is already packed. In that case process
A will not see it as missing, but rather will report
whatever value happened to be in the packed-refs file before
process B repacked (which might be an arbitrarily old
value).

We can fix this by making sure we reload the packed-refs
file from disk after looking at any loose refs. That's
unacceptably slow, so we can check its stat()-validity as a
proxy, and read it only when it appears to have changed.

Reading the packed-refs file after performing any loose-ref
system calls is sufficient because we know the ordering of
the pack-refs process: it always makes sure the newly
written packed-refs file is installed into place before
pruning any loose refs. As long as those operations by B
appear in their executed order to process A, by the time A
sees the missing loose ref, the new packed-refs file must be
in place.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

add a stat_validity structMichael Haggerty Thu, 20 Jun 2013 08:37:51 +0000 (10:37 +0200)

add a stat_validity struct

It can sometimes be useful to know whether a path in the
filesystem has been updated without going to the work of
opening and re-reading its content. We trust the stat()
information on disk already to handle index updates, and we
can use the same trick here.

This patch introduces a "stat_validity" struct which
encapsulates the concept of checking the stat-freshness of a
file. It is implemented on top of "struct stat_data" to
reuse the logic about which stat entries to trust for a
particular platform, but hides the complexity behind two
simple functions: check and update.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Extract a struct stat_data from cache_entryMichael Haggerty Thu, 20 Jun 2013 08:37:50 +0000 (10:37 +0200)

Extract a struct stat_data from cache_entry

Add public functions fill_stat_data() and match_stat_data() to work
with it. This infrastructure will later be used to check the validity
of other types of file.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

packed_ref_cache: increment refcount when lockedMichael Haggerty Thu, 20 Jun 2013 08:37:49 +0000 (10:37 +0200)

packed_ref_cache: increment refcount when locked

Increment the packed_ref_cache reference count while it is locked to
prevent its being freed.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

do_for_each_entry(): increment the packed refs cache... Michael Haggerty Thu, 20 Jun 2013 08:37:48 +0000 (10:37 +0200)

do_for_each_entry(): increment the packed refs cache refcount

This function calls a user-supplied callback function which could do
something that causes the packed refs cache to be invalidated. So
acquire a reference count on the data structure to prevent our copy
from being freed while we are iterating over it.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: manage lifetime of packed refs cache via referenc... Michael Haggerty Thu, 20 Jun 2013 08:37:47 +0000 (10:37 +0200)

refs: manage lifetime of packed refs cache via reference counting

In struct packed_ref_cache, keep a count of the number of users of the
data structure. Only free the packed ref cache when the reference
count goes to zero rather than when the packed ref cache is cleared.
This mechanism will be used to prevent the cache data structure from
being freed while it is being iterated over.

So far, only the reference in struct ref_cache::packed is counted;
other users will be adjusted in separate commits.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: implement simple transactions for the packed... Michael Haggerty Thu, 20 Jun 2013 08:37:46 +0000 (10:37 +0200)

refs: implement simple transactions for the packed-refs file

Handle simple transactions for the packed-refs file at the
packed_ref_cache level via new functions lock_packed_refs(),
commit_packed_refs(), and rollback_packed_refs().

Only allow the packed ref cache to be modified (via add_packed_ref())
while the packed refs file is locked.

Change clone to add the new references within a transaction.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: wrap the packed refs cache in a level of indirectionMichael Haggerty Thu, 20 Jun 2013 08:37:45 +0000 (10:37 +0200)

refs: wrap the packed refs cache in a level of indirection

As we know, we can solve any problem in this manner. In this case,
the problem is to avoid freeing a packed refs cache while somebody is
using it. So add a level of indirection as a prelude to
reference-counting the packed refs cache.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack_refs(): split creation of packed refs and entry... Michael Haggerty Thu, 20 Jun 2013 08:37:44 +0000 (10:37 +0200)

pack_refs(): split creation of packed refs and entry writing

Split pack_refs() into multiple passes:

* Iterate over loose refs. For each one that can be turned into a
packed ref, create a corresponding entry in the packed refs cache.

* Write the packed refs to the packed-refs file.

This change isolates the mutation of the packed-refs file to a single
place.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repack_without_ref(): split list curation and entry... Michael Haggerty Thu, 20 Jun 2013 08:37:43 +0000 (10:37 +0200)

repack_without_ref(): split list curation and entry writing

The repack_without_ref() function first removes the deleted ref from
the internal packed-refs list, then writes the packed-refs list to
disk, omitting any broken or stale entries. This patch splits that
second step into multiple passes:

* collect the list of refnames that should be deleted from packed_refs

* delete those refnames from the cache

* write the remainder to the packed-refs file

The purpose of this change is to make the "write the remainder" part
reusable.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7400: test of UTF-8 submodule names pass under Mac OSTorsten Bögershausen Thu, 20 Jun 2013 14:58:48 +0000 (16:58 +0200)

t7400: test of UTF-8 submodule names pass under Mac OS

submodules with names using UTF-8 need core.precomposeunicode true
under Mac OS X, set it in the test case.

Improve the portability:

- Not all shells on all OS may understand literal UTF-8 strings.
- Use a help variable filled by printf, as we do it in e.g. t0050.

"strange names" can be called UTF-8, rephrase the heading.

While at it, unbreak &&-chain in the test, and use test_config.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: sanitize author when writing From lineMichael S. Tsirkin Tue, 18 Jun 2013 12:49:26 +0000 (15:49 +0300)

send-email: sanitize author when writing From line

sender is now sanitized, but we didn't sanitize author when checking
whether From: line is needed in the message body.

As a result git started writing duplicate From: lines when author
matched sender and has utf8 characters.

Reported-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: add test for duplicate utf8 nameMichael S. Tsirkin Tue, 18 Jun 2013 12:49:29 +0000 (15:49 +0300)

send-email: add test for duplicate utf8 name

Verify that author name is not duplicated if it matches sender, even
if it is in utf8 (the test expects a failure that will be fixed in
the next patch).

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: add --ignore-blank-lines optionAntoine Pelisse Wed, 19 Jun 2013 18:46:07 +0000 (20:46 +0200)

diff: add --ignore-blank-lines option

The goal of the patch is to introduce the GNU diff
-B/--ignore-blank-lines as closely as possible. The short option is not
available because it's already used for "break-rewrites".

When this option is used, git-diff will not create hunks that simply
add or remove empty lines, but will still show empty lines
addition/suppression if they are close enough to "valuable" changes.

There are two differences between this option and GNU diff -B option:
- GNU diff doesn't have "--inter-hunk-context", so this must be handled
- The following sequence looks like a bug (context is displayed twice):

$ seq 5 >file1
$ cat <<EOF >file2
change
1
2

3
4
5
change
EOF
$ diff -u -B file1 file2
--- file1 2013-06-08 22:13:04.471517834 +0200
+++ file2 2013-06-08 22:13:23.275517855 +0200
@@ -1,5 +1,7 @@
+change
1
2
+
3
4
5
@@ -3,3 +5,4 @@
3
4
5
+change

So here is a more thorough description of the option:
- real changes are interesting
- blank lines that are close enough (less than context size) to
interesting changes are considered interesting (recursive definition)
- "context" lines are used around each hunk of interesting changes
- If two hunks are separated by less than "inter-hunk-context", they
will be merged into one.

The implementation does the "interesting changes selection" in a single
pass.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

random typofixes (committed missing a 't', successful... Veres Lajos Wed, 19 Jun 2013 05:37:24 +0000 (07:37 +0200)

random typofixes (committed missing a 't', successful missing an 's')

Signed-off-by: Veres Lajos <vlajos@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer: write useful reflog message for fast-forwardRamkumar Ramachandra Wed, 19 Jun 2013 07:37:09 +0000 (13:07 +0530)

sequencer: write useful reflog message for fast-forward

The following command

$ git cherry-pick --ff b8bb3f

writes the following uninformative message to the reflog

cherry-pick

Improve it to

cherry-pick: fast-forward

Avoid hard-coding "cherry-pick" in fast_forward_to(), so the sequencer
is generic enough to support future actions.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

resolve_ref_unsafe(): close race condition reading... Michael Haggerty Wed, 19 Jun 2013 06:36:28 +0000 (08:36 +0200)

resolve_ref_unsafe(): close race condition reading loose refs

We read loose references in two steps. The code is roughly:

lstat()
if error ENOENT:
loose ref is missing; look for corresponding packed ref
else if S_ISLNK:
readlink()
if error:
report failure
else if S_ISDIR:
report failure
else
open()
if error:
report failure
read()

The problem is that the first filesystem call, to lstat(), is not
atomic with the second filesystem call, to readlink() or open().
Therefore it is possible for another process to change the file
between our two calls, for example:

* If the other process deletes the file, our second call will fail
with ENOENT, which we *should* interpret as "loose ref is missing;
look for corresponding packed ref". This can arise if the other
process is pack-refs; it might have just written a new packed-refs
file containing the old contents of the reference then deleted the
loose ref.

* If the other process changes a symlink into a plain file, our call
to readlink() will fail with EINVAL, which we *should* respond to by
trying to open() and read() the file.

The old code treats the reference as missing in both of these cases,
which is incorrect.

So instead, handle errors more selectively: if the result of
readline()/open() is a failure that is inconsistent with the result of
the previous lstat(), then something is fishy. In this case jump back
and start over again with a fresh call to lstat().

One race is still possible and undetected: another process could
change the file from a regular file into a symlink between the call to
lstat and the call to open(). The open() call would silently follow
the symlink and not know that something is wrong. This situation
could be detected in two ways:

* On systems that support O_NOFOLLOW, pass that option to the open().

* On other systems, call fstat() on the fd returned by open() and make
sure that it agrees with the stat info from the original lstat().

However, we don't use symlinks anymore, so this situation is unlikely.
Moreover, it doesn't appear that treating a symlink as a regular file
would have grave consequences; after all, this is exactly how the code
handles non-relative symlinks. So this commit leaves that race
unaddressed.

Note that this solves only the part of the race within
resolve_ref_unsafe. In the situation described above, we may still be
depending on a cached view of the packed-refs file; that race will be
dealt with in a future patch.

This problem was reported and diagnosed by Jeff King <peff@peff.net>,
and this solution is derived from his patch.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

resolve_ref_unsafe(): handle the case of an SHA-1 withi... Michael Haggerty Wed, 19 Jun 2013 06:36:27 +0000 (08:36 +0200)

resolve_ref_unsafe(): handle the case of an SHA-1 within loop

There is only one "break" statement within the loop, which jumps to
the code after the loop that handles the case of a file that holds a
SHA-1. So move that code from below the loop into the if statement
where the break was previously located. This makes the logic flow
more local.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

resolve_ref_unsafe(): extract function handle_missing_l... Michael Haggerty Wed, 19 Jun 2013 06:36:26 +0000 (08:36 +0200)

resolve_ref_unsafe(): extract function handle_missing_loose_ref()

The nesting was getting a bit out of hand, and it's about to get
worse.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http.c: don't rewrite the user:passwd string multiple... Brandon Casey Wed, 19 Jun 2013 02:43:49 +0000 (19:43 -0700)

http.c: don't rewrite the user:passwd string multiple times

Curl older than 7.17 (RHEL 4.X provides 7.12 and RHEL 5.X provides
7.15) requires that we manage any strings that we pass to it as
pointers. So, we really shouldn't be modifying this strbuf after we
have passed it to curl.

Our interaction with curl is currently safe (before or after this
patch) since the pointer that is passed to curl is never invalidated;
it is repeatedly rewritten with the same sequence of characters but
the strbuf functions never need to allocate a larger string, so the
same memory buffer is reused.

This "guarantee" of safety is somewhat subtle and could be overlooked
by someone who may want to add a more complex handling of the username
and password. So, let's stop modifying this strbuf after we have
passed it to curl, but also leave a note to describe the assumptions
that have been made about username/password lifetime and to draw
attention to the code.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

name-rev: allow to specify a subpath for --refs optionNamhyung Kim Tue, 18 Jun 2013 12:35:31 +0000 (21:35 +0900)

name-rev: allow to specify a subpath for --refs option

When an user wants to filter specific ref using the --refs option,
the pattern needs to match the full ref, e.g. --refs=refs/tags/v1.*.

It'd be convenient to specify a subpath of ref pattern. For
example, --refs=origin/* can find refs/remotes/origin/master by
searching the pattern against its substrings in turn:

refs/remotes/origin/master
remotes/origin/master
origin/master

If it finds a match in a subpath, unambigous part of the ref path will
be removed in the output.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fix "builtin-*" references to be "builtin/*"Phil Hord Tue, 18 Jun 2013 17:44:58 +0000 (13:44 -0400)

fix "builtin-*" references to be "builtin/*"

Documentation and some comments still refer to files in builtin/
as 'builtin-*.[cho]'. Update these to show the correct location.

Signed-off-by: Phil Hord <hordp@cisco.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Assisted-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: Move "git diff <blob> <blob>"Kevin Bracey Tue, 18 Jun 2013 14:58:50 +0000 (17:58 +0300)

Documentation: Move "git diff <blob> <blob>"

The section describing "git diff <blob> <blob>" had been placed in a
position that disrupted the statement "This is synonymous to the
previous form".

Reorder to place this form after all the <commit>-using forms, and the
note applying to them. Also mention this form in the initial description
paragraph.

Signed-off-by: Kevin Bracey <kevin@bracey.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-merge.txt: weaken warning about uncom... Matthieu Moy Tue, 18 Jun 2013 08:42:55 +0000 (10:42 +0200)

Documentation/git-merge.txt: weaken warning about uncommited changes

Commit 35d2fffd introduced 'git merge --abort' as a synonym to 'git reset
--merge', and added some failing tests in t7611-merge-abort.sh (search
'###' in this file) showing that 'git merge --abort' could not always
recover the pre-merge state.

Still, in many cases, 'git merge --abort' just works, and it is usually
considered that the ability to start a merge with uncommited changes is
an important property of Git.

Weaken the warning by discouraging only merge with /non-trivial/
uncommited changes.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t9802: explicitly name the upstream branch to use... Brandon Casey Tue, 18 Jun 2013 01:40:50 +0000 (18:40 -0700)

t/t9802: explicitly name the upstream branch to use as a base

Prior to commit fa83a33b, the 'git checkout' DWIMery would create a
new local branch if the specified branch name did not exist and it
matched exactly one ref in the "remotes" namespace. It searched
the "remotes" namespace for matching refs using a simple comparison
of the trailing portion of the remote ref names. This approach
could sometimes produce false positives or negatives.

Since fa83a33b, the DWIMery more strictly excludes the remote name
from the ref comparison by iterating through the remotes that are
configured in the .gitconfig file. This has the side-effect that
any refs that exist in the "remotes" namespace, but do not match
the destination side of any remote refspec, will not be used by
the DWIMery.

This change in behavior breaks the tests in t9802 which relied on
the old behavior of searching all refs in the remotes namespace,
since the git-p4 script does not configure any remotes in the
.gitconfig. Let's work around this in these tests by explicitly
naming the upstream branch to base the new local branch on when
calling 'git checkout'.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Acked-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase topology tests: fix commit names on case-insensi... Johannes Sixt Tue, 18 Jun 2013 07:28:07 +0000 (09:28 +0200)

rebase topology tests: fix commit names on case-insensitive file systems

The recently introduced tests used uppercase letters to denote
cherry-picks of commits having the corresponding lowercase letter names.
The helper functions also set up tags with the names of the commits.

But this constellation fails on case-insensitive file systems because
there cannot be distinct tags with names that differ only in case.

Use a less subtle convention for the names of cherry-picked commits.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-push.txt: explain better cases where... Matthieu Moy Mon, 17 Jun 2013 17:52:41 +0000 (19:52 +0200)

Documentation/git-push.txt: explain better cases where --force is dangerous

The behavior of "git push --force" is rather clear when it updates only
one remote ref, but running it when pushing several branches can really
be dangerous. Warn the users a bit more and give them the alternative to
push only one branch.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/checkout.c: don't leak memory in check_tracking... Brandon Casey Tue, 18 Jun 2013 01:40:49 +0000 (18:40 -0700)

builtin/checkout.c: don't leak memory in check_tracking_name

remote_find_tracking() populates the query struct with an allocated
string in the dst member. So, we do not need to xstrdup() the string,
since we can transfer ownership from the query struct (which will go
out of scope at the end of this function) to our callback struct, but
we must free the string if it will not be used so we will not leak
memory.

Let's do so.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: drop the top-level requirementJohn Keeping Sun, 16 Jun 2013 14:18:18 +0000 (15:18 +0100)

submodule: drop the top-level requirement

Use the new rev-parse --prefix option to process all paths given to the
submodule command, dropping the requirement that it be run from the
top-level of the repository.

Since the interpretation of a relative submodule URL depends on whether
or not "remote.origin.url" is configured, explicitly block relative URLs
in "git submodule add" when not at the top level of the working tree.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rev-parse: add --prefix optionJohn Keeping Sun, 16 Jun 2013 14:18:17 +0000 (15:18 +0100)

rev-parse: add --prefix option

This makes 'git rev-parse' behave as if it were invoked from the
specified subdirectory of a repository, with the difference that any
file paths which it prints are prefixed with the full path from the top
of the working tree.

This is useful for shell scripts where we may want to cd to the top of
the working tree but need to handle relative paths given by the user on
the command line.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: show full path in error messageJohn Keeping Sun, 16 Jun 2013 14:18:16 +0000 (15:18 +0100)

submodule: show full path in error message

When --recursive was added to "submodule foreach" in commit 15fc56a (git
submodule foreach: Add --recursive to recurse into nested submodules,
2009-08-19), the error message when the script returns a non-zero status
was not updated to contain $prefix to show the full path. Fix this.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7403: add missing && chainingJohn Keeping Sun, 16 Jun 2013 14:18:15 +0000 (15:18 +0100)

t7403: add missing && chaining

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7403: modernize styleJohn Keeping Sun, 16 Jun 2013 14:18:14 +0000 (15:18 +0100)

t7403: modernize style

Change the indentation to use tabs consistently and start content on the
line after the paren opening a subshell.

Also don't put a space in ">file" and remove ":" from ": >file" to be
consistent with the majority of tests elsewhere.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7401: make indentation consistentJohn Keeping Sun, 16 Jun 2013 14:18:13 +0000 (15:18 +0100)

t7401: make indentation consistent

Only leading whitespace is changed in this patch.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: Add description of --local optionNamhyung Kim Mon, 17 Jun 2013 13:31:31 +0000 (22:31 +0900)

config: Add description of --local option

It was missed in the option list while mentioned from the general
description. Add it for completeness.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-submodule.sh: remove duplicate call to set_rev_nameFredrik Gustafsson Mon, 17 Jun 2013 09:55:36 +0000 (11:55 +0200)

git-submodule.sh: remove duplicate call to set_rev_name

set_rev_name is a possiblly expensive operation. If a submodule has
changes in it, set_rev_name was called twice.

Move call to set_rev_name so it's only called once, no matter which
codepath is taken.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wt-status: give better advice when cherry-pick is in... Ralf Thielow Mon, 17 Jun 2013 04:28:26 +0000 (06:28 +0200)

wt-status: give better advice when cherry-pick is in progress

When cherry-pick is in progress, 'git status' gives the advice to
run "git commit" to finish the cherry-pick.

However, this won't continue the sequencer, when picking a range of
commits.

Advise users to run "git cherry-pick --continue/--abort"; they work
when picking a single commit as well.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mergetool--lib: refactor {diff,merge}_cmd logicJohn Keeping Sun, 16 Jun 2013 17:51:22 +0000 (18:51 +0100)

mergetool--lib: refactor {diff,merge}_cmd logic

Instead of needing a wrapper to call the diff/merge command, simply
provide the diff_cmd and merge_cmd functions for user-specified tools in
the same way as we do for built-in tools.

Signed-off-by: John Keeping <john@keeping.me.uk>
Acked-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/Makefile: move infodir to be with other... John Keeping Sun, 16 Jun 2013 17:13:01 +0000 (18:13 +0100)

Documentation/Makefile: move infodir to be with other '*dir's

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/Makefile: fix spaces around assignmentsJohn Keeping Sun, 16 Jun 2013 17:13:00 +0000 (18:13 +0100)

Documentation/Makefile: fix spaces around assignments

A simple style fix; no functional change.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

GIT-VERSION-GEN: support non-standard $GIT_DIR pathDennis Kaarsemaker Sat, 15 Jun 2013 23:01:11 +0000 (01:01 +0200)

GIT-VERSION-GEN: support non-standard $GIT_DIR path

make and make test both work when $GIT_DIR isn't .git, but make dist
included a bogus GIT-VERSION-FILE.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tests: allow sha1's as part of the pathDennis Kaarsemaker Sat, 15 Jun 2013 21:35:02 +0000 (23:35 +0200)

tests: allow sha1's as part of the path

When running 'make test' from a path such as
.../daily-build/master@bdff0e3a374617dce784f801b97500d9ba2e4705, the
logic in fuzz.sed as generated by t5105-request-pull.sh was backwards,
replacing object names before replacing urls, making the test fail.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: use 'git stash store' to simplify logicRamkumar Ramachandra Sat, 15 Jun 2013 13:13:26 +0000 (18:43 +0530)

rebase: use 'git stash store' to simplify logic

rebase has no reason to know about the implementation of the stash. In
the case when applying the autostash results in conflicts, replace the
relevant code in finish_rebase () to simply call 'git stash store'.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: introduce 'git stash store'Ramkumar Ramachandra Sat, 15 Jun 2013 13:13:25 +0000 (18:43 +0530)

stash: introduce 'git stash store'

save_stash() contains the logic for doing two potentially independent
operations; the first is preparing the stash merge commit, and the
second is updating the stash ref/ reflog accordingly. While the first
operation is abstracted out into a create_stash() for callers to access
via 'git stash create', the second one is not. Fix this by factoring
out the logic for storing the stash into a store_stash() that callers
can access via 'git stash store'.

Like create, store is not intended for end user interactive use, but for
callers in other scripts. We can simplify the logic in the
rebase.autostash feature using this new subcommand.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

unpack-trees: don't shift conflicts left and rightRené Scharfe Sat, 15 Jun 2013 23:44:43 +0000 (01:44 +0200)

unpack-trees: don't shift conflicts left and right

If o->merge is set, the struct traverse_info member conflicts is shifted
left in unpack_callback, then passed through traverse_trees_recursive
to unpack_nondirectories, where it is shifted right before use. Stop
the shifting and just pass the conflict bit mask as is. Rename the
member to df_conflicts to prove that it isn't used anywhere else.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: simplify option parser for createRamkumar Ramachandra Sat, 15 Jun 2013 13:13:24 +0000 (18:43 +0530)

stash: simplify option parser for create

The option parser for create unnecessarily checks "$1" inside a case
statement that matches "$1" in the first place.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash doc: document short form -p in synopsisRamkumar Ramachandra Sat, 15 Jun 2013 13:13:23 +0000 (18:43 +0530)

stash doc: document short form -p in synopsis

'git stash save' can take -p, the short form of --patch, as an option.
Document this.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash doc: add a warning about using createRamkumar Ramachandra Sat, 15 Jun 2013 13:13:22 +0000 (18:43 +0530)

stash doc: add a warning about using create

Add a note saying that the user probably wants "save" in the create
description. While at it, document that it can optionally take a
message in the synopsis.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/am: use test_path_is_missing() where appropriateRamkumar Ramachandra Sat, 15 Jun 2013 12:43:12 +0000 (18:13 +0530)

t/am: use test_path_is_missing() where appropriate

Replace instances of ! test -d with test_path_is_missing.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am: handle stray $dotest directoryRamkumar Ramachandra Sat, 15 Jun 2013 12:43:11 +0000 (18:13 +0530)

am: handle stray $dotest directory

The following bug has been observed:

$ git am # no input file
^C
$ git am --abort
Resolve operation not in progress, we are not resuming.

This happens because the following test fails:

test -d "$dotest" && test -f "$dotest/last" && test -f "$dotest/next"

and the codepath for an "am in-progress" is not executed. It falls back
to the codepath that treats this as a "fresh execution". Before
rr/rebase-autostash, this condition was

test -d "$dotest"

It would incorrectly execute the "normal" am --abort codepath:

git read-tree --reset -u HEAD ORIG_HEAD
git reset ORIG_HEAD

by incorrectly assuming that an am is "in progress" (i.e. ORIG_HEAD
etc. was written during the previous execution).

Notice that

$ git am
^C

executes nothing of significance, is equivalent to

$ mkdir .git/rebase-apply

Therefore, the correct solution is to treat .git/rebase-apply as a
"stray directory" and remove it on --abort in the fresh-execution
codepath. Also ensure that we're not called with --rebasing from
git-rebase--am.sh; in that case, it is the responsibility of the caller
to handle and stray directories.

While at it, tell the user to run "git am --abort" to get rid of the
stray $dotest directory, if she attempts anything else.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge tag 'gitgui-0.18.0' of git://repo.or.cz/git-guiJunio C Hamano Mon, 17 Jun 2013 03:06:55 +0000 (20:06 -0700)

Merge tag 'gitgui-0.18.0' of git://repo.or.cz/git-gui

git-gui 0.18.0

* tag 'gitgui-0.18.0' of git://repo.or.cz/git-gui:
git-gui 0.18
git-gui: avoid an error message when removing the last remote
git-gui: fix file name handling with non-empty prefix
git-gui: bring wish process to front on Mac
git-gui: change dialog button positions for Windows to suit platform.
git-gui: allow "\ No newline at end of file" for linewise staging
git-gui: fix the mergetool launcher for the Beyond Compare tool.
Makefile: replace "echo 1>..." with "echo >..."
French translation: copy -> copie.
git-gui: Fix parsing of <rev> <path-which-not-present-in-worktree>

status: introduce status.branch to enable --branch... Jorge Juan Garcia Garcia Tue, 11 Jun 2013 13:34:05 +0000 (15:34 +0200)

status: introduce status.branch to enable --branch by default

Some people often run 'git status -b'.
The config variable status.branch allows to set it by default.

Signed-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>
Signed-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>
Reviewed-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Update draft release notes to 1.8.4Junio C Hamano Sun, 16 Jun 2013 05:12:52 +0000 (22:12 -0700)

Update draft release notes to 1.8.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-gui 0.18 gitgui-0.18.0Pat Thoyts Sat, 15 Jun 2013 22:53:34 +0000 (23:53 +0100)

git-gui 0.18

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

git-gui: avoid an error message when removing the last... Pat Thoyts Sat, 15 Jun 2013 22:36:27 +0000 (23:36 +0100)

git-gui: avoid an error message when removing the last remote

When the last remote is removed on a system that has tearoff menu items
the code that adjusts the fetch and prune menus may raise an error when
probing the menu entry for a non-existing -label option.
Check the entry type to avoid this fault.

Reported-by: Vedran Miletić <rivanvx@gmail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

unpack_entry: do not die when we fail to apply a deltaJeff King Fri, 14 Jun 2013 21:53:34 +0000 (17:53 -0400)

unpack_entry: do not die when we fail to apply a delta

When we try to load an object from disk and fail, our
general strategy is to see if we can get it from somewhere
else (e.g., a loose object). That lets users fix corruption
problems by copying known-good versions of objects into the
object database.

We already handle the case where we were not able to read
the delta from disk. However, when we find that the delta we
read does not apply, we simply die. This case is harder to
trigger, as corruption in the delta data itself would
trigger a crc error from zlib. However, a corruption that
pointed us at the wrong delta base might cause it.

We can do the same "fail and try to find the object
elsewhere" trick instead of dying. This not only gives us a
chance to recover, but also puts us on code paths that will
alert the user to the problem (with the current message,
they do not even know which sha1 caused the problem).

Note that unlike some other pack corruptions, we do not
recover automatically from this case when doing a repack.
There is nothing apparently wrong with the delta, as it
points to a valid, accessible object, and we realize the
error only when the resulting size does not match up. And in
theory, one could even have a case where the corrupted size
is the same, and the problem would only be noticed by
recomputing the sha1.

We can get around this by recomputing the deltas with
--no-reuse-delta, which our test does (and this is probably
good advice for anyone recovering from pack corruption).

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

t5303: drop "count=1" from corruption ddJeff King Fri, 14 Jun 2013 21:51:01 +0000 (17:51 -0400)

t5303: drop "count=1" from corruption dd

This test corrupts pack objects by using "dd" with a seek
command. It passes "count=1 bs=1" to munge just a single
byte. However, the test added in commit b3118bdc wants to
munge two bytes, and the second byte of corruption is
silently ignored.

This turned out not to impact the test, however. The idea
was to reduce the "size of this entry" part of the header so
that zlib runs out of input bytes while inflating the entry.
That header is two bytes long, and the test reduced the
value of both bytes; since we experience the problem if we
are off by even 1 byte, it is sufficient to munge only the
first one.

Even though the test would have worked with only a single
byte munged, and we could simply tweak the test to use a
single byte, it makes sense to lift this 1-byte restriction
from do_corrupt_object. It will allow future tests that do
need to change multiple bytes to do so.

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

git-remote-mediawiki: remove hardcoded version number... Benoit Person Fri, 14 Jun 2013 10:19:11 +0000 (12:19 +0200)

git-remote-mediawiki: remove hardcoded version number in the test suite

Updates the code to make it more easy to switch mediawiki version when
testing. Before that, the version number was partly hardcoded, partly
in a var.

Signed-off-by: Benoit Person <benoit.person@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/lib-httpd/apache.conf: configure an MPM module for... Jeff King Sun, 9 Jun 2013 08:09:32 +0000 (04:09 -0400)

t/lib-httpd/apache.conf: configure an MPM module for apache 2.4

Versions of Apache before 2.4 always had a "MultiProcessing
Module" (MPM) statically built in, which manages the worker
threads/processes. We do not care which one, as it is
largely a performance issue, and we put only a light load on
the server during our testing.

As of Apache 2.4, the MPM module is loadable just like any
other module, but exactly one such module must be loaded. On
a system where the MPMs are compiled dynamically (e.g.,
Debian unstable), this means that our test Apache server
will not start unless we provide the appropriate
configuration.

Unfortunately, we do not actually know which MPM modules are
available or appropriate for the system on which the tests
are running. This patch picks the "prefork" module, as it
is likely to be available on all Unix-like systems.

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

t/lib-httpd/apache.conf: load compat access module... Jeff King Sun, 9 Jun 2013 08:08:45 +0000 (04:08 -0400)

t/lib-httpd/apache.conf: load compat access module in apache 2.4

In apache 2.4, the "Order" directive has gone away in favor
of a new system in mod_authz_host. However, since we want
our config file to remain compatible across multiple Apache
versions, we can use mod_access_compat to keep using the
older style.

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

t/lib-httpd/apache.conf: load extra auth modules in... Jeff King Sun, 9 Jun 2013 08:08:22 +0000 (04:08 -0400)

t/lib-httpd/apache.conf: load extra auth modules in apache 2.4

In apache 2.4, the "Auth*" and "Require" directives have
moved into the authn_core and authz_core modules,
respectively.

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

t/lib-httpd/apache.conf: do not use LockFile in apache... Jeff King Sun, 9 Jun 2013 08:07:59 +0000 (04:07 -0400)

t/lib-httpd/apache.conf: do not use LockFile in apache >= 2.4

The LockFile directive from earlier versions of apache has
been replaced by the Mutex directive. The latter seems to
give sane defaults and does not need any specific
customization, so we can get away with just adding a version
check to the use of LockFile.

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

rebase: use peel_committish() where appropriateRamkumar Ramachandra Fri, 14 Jun 2013 13:17:52 +0000 (18:47 +0530)

rebase: use peel_committish() where appropriate

The revisions specified on the command-line as <onto> and <upstream>
arguments could be of the form :/quuxery; so, use peel_committish() to
resolve them. The failing tests in t/rebase and t/rebase-interactive
now pass.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sh-setup: add new peel_committish() helperRamkumar Ramachandra Fri, 14 Jun 2013 13:17:51 +0000 (18:47 +0530)

sh-setup: add new peel_committish() helper

The normal way to check whether a certain revision resolves to a valid
commit is:

$ git rev-parse --verify $REV^0

Unfortunately, this does not work when $REV is of the type :/quuxery.
Write a helper to work around this limitation.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/rebase: add failing tests for a peculiar revisionRamkumar Ramachandra Fri, 14 Jun 2013 13:17:50 +0000 (18:47 +0530)

t/rebase: add failing tests for a peculiar revision

The following commands fail, even if :/quuxery and :/foomery resolve to
perfectly valid commits:

$ git rebase [-i] --onto :/quuxery :/foomery

This is because rebase [-i] attempts to rev-parse ${REV}^0 to verify
that the given revision resolves to a commit. Add tests to document
these failures.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: make error message more preciseCélestin Matte Fri, 14 Jun 2013 13:50:39 +0000 (15:50 +0200)

git-remote-mediawiki: make error message more precise

In subroutine parse_command, error messages were not correct. For the "import"
function, having too much or incorrect arguments displayed both
"invalid arguments", while it displayed "too many arguments" for the "option"
functions under the same conditions.
Separate the two error messages in both cases.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: add a perlcritic rule in MakefileCélestin Matte Fri, 14 Jun 2013 13:50:38 +0000 (15:50 +0200)

git-remote-mediawiki: add a perlcritic rule in Makefile

Option "-2" launches perlcritic with level 2. Levels go from 5 (most pertinent)
to 1. Rules of level 1 are mostly a question of style, and are therefore
ignored.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: add a .perlcriticrc fileCélestin Matte Fri, 14 Jun 2013 13:50:37 +0000 (15:50 +0200)

git-remote-mediawiki: add a .perlcriticrc file

Such a file allows to configure perlcritic.
Here, it is used to remove many unwanted rules and configure one to
remove unwanted warnings.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: clearly rewrite double dereferenceCélestin Matte Fri, 14 Jun 2013 13:50:36 +0000 (15:50 +0200)

git-remote-mediawiki: clearly rewrite double dereference

@$var structures are re-written in the following way: @{$var}
It makes them more readable.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: fix a typo ("mediwiki" instead... Célestin Matte Fri, 14 Jun 2013 13:50:35 +0000 (15:50 +0200)

git-remote-mediawiki: fix a typo ("mediwiki" instead of "mediawiki")

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: put non-trivial numeric values... Célestin Matte Fri, 14 Jun 2013 13:50:34 +0000 (15:50 +0200)

git-remote-mediawiki: put non-trivial numeric values in constants.

Non-trivial numeric values (e.g., different from 0, 1 and 2) are placed in
constants at the top of the code to be easily modifiable and to make more sense

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: don't use quotes for empty stringsCélestin Matte Fri, 14 Jun 2013 13:50:33 +0000 (15:50 +0200)

git-remote-mediawiki: don't use quotes for empty strings

Empty strings are replaced by an $EMPTY constant.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: replace "unless" statements with... Célestin Matte Fri, 14 Jun 2013 13:50:32 +0000 (15:50 +0200)

git-remote-mediawiki: replace "unless" statements with negated "if" statements

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: brace file handles for print... Célestin Matte Fri, 14 Jun 2013 13:50:31 +0000 (15:50 +0200)

git-remote-mediawiki: brace file handles for print for more clarity

This follows the following rule:
InputOutput::RequireBracedFileHandleWithPrint (Severity: 1)
The `print' and `printf' functions have a unique syntax that supports an
optional file handle argument. Conway suggests wrapping this argument in
braces to make it visually stand out from the other arguments. When you
put braces around any of the special package-level file handles like
`STDOUT', `STDERR', and `DATA', you must the `'*'' sigil or else it
won't compile under `use strict 'subs''.

print $FH "Mary had a little lamb\n"; #not ok
print {$FH} "Mary had a little lamb\n"; #ok

print STDERR $foo, $bar, $baz; #not ok
print {STDERR} $foo, $bar, $baz; #won't compile under 'strict'
print {*STDERR} $foo, $bar, $baz; #perfect!

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: modify strings for a better codin... Célestin Matte Fri, 14 Jun 2013 13:50:30 +0000 (15:50 +0200)

git-remote-mediawiki: modify strings for a better coding-style

- strings which don't need interpolation are single-quoted for more clarity and
slight gain of performance
- interpolation is preferred over concatenation in many cases, for more clarity
- variables are always used with the ${} operator inside strings
- strings including double-quotes are written with qq() so that the quotes do
not have to be escaped

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: put long code into a subroutineCélestin Matte Fri, 14 Jun 2013 13:50:29 +0000 (15:50 +0200)

git-remote-mediawiki: put long code into a subroutine

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: remove import of unused open2Célestin Matte Fri, 14 Jun 2013 13:50:28 +0000 (15:50 +0200)

git-remote-mediawiki: remove import of unused open2

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: check return value of openCélestin Matte Fri, 14 Jun 2013 13:50:27 +0000 (15:50 +0200)

git-remote-mediawiki: check return value of open

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: assign a variable as undef and... Célestin Matte Fri, 14 Jun 2013 13:50:26 +0000 (15:50 +0200)

git-remote-mediawiki: assign a variable as undef and make proper indentation

Explicitly assign local variable $/ as undef and make a proper
one-instruction-by-line indentation

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: rename a variable ($last) which... Célestin Matte Fri, 14 Jun 2013 13:50:25 +0000 (15:50 +0200)

git-remote-mediawiki: rename a variable ($last) which has the name of a keyword

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: remove unused variable $entryCélestin Matte Fri, 14 Jun 2013 13:50:24 +0000 (15:50 +0200)

git-remote-mediawiki: remove unused variable $entry

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: turn double-negated expressions... Célestin Matte Fri, 14 Jun 2013 13:50:23 +0000 (15:50 +0200)

git-remote-mediawiki: turn double-negated expressions into simple expressions

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change the name of a variableCélestin Matte Fri, 14 Jun 2013 13:50:22 +0000 (15:50 +0200)

git-remote-mediawiki: change the name of a variable

Local variable $url has the same name as a global variable. Changing the name
of the local variable prevents future possible misunderstanding.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: add newline in the end of die... Célestin Matte Fri, 14 Jun 2013 13:50:21 +0000 (15:50 +0200)

git-remote-mediawiki: add newline in the end of die() error messages

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change style in a regexpCélestin Matte Fri, 14 Jun 2013 13:50:20 +0000 (15:50 +0200)

git-remote-mediawiki: change style in a regexp

Change '[\n]' to '\n': brackets are useless here.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change style in a regexpCélestin Matte Fri, 14 Jun 2013 13:50:19 +0000 (15:50 +0200)

git-remote-mediawiki: change style in a regexp

In this regexp, ' |\n' is used, whereas its equivalent '[ \n]', which is
clearer, is used elsewhere. Make the style coherent.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change separator of some regexpsCélestin Matte Fri, 14 Jun 2013 13:50:18 +0000 (15:50 +0200)

git-remote-mediawiki: change separator of some regexps

Use {}{} instead of /// when slashes are used inside the regexp so as not to
escape it.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change the behaviour of a splitCélestin Matte Fri, 14 Jun 2013 13:50:17 +0000 (15:50 +0200)

git-remote-mediawiki: change the behaviour of a split

A "split ' '" is turned into a "split / /", which changes its behaviour: the
old method matched a run of whitespaces (/\s*/), while the new one will match a
single space, which is what we want here. Indeed, in other contexts,
changing split(' ') to split(/ /) could potentially be a regression, however,
here, when parsing the output of "rev-list --parents", whose output SHA-1's are
each separated by a single space, splitting on a single space is perfectly
correct.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: remove useless regexp modifier (m)Célestin Matte Fri, 14 Jun 2013 13:50:16 +0000 (15:50 +0200)

git-remote-mediawiki: remove useless regexp modifier (m)

m// and // is used randomly. It is better to use the m modifier only when
needed, e.g., when the regexp uses another separator than //.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: rewrite unclear line of instructionsCélestin Matte Fri, 14 Jun 2013 13:50:15 +0000 (15:50 +0200)

git-remote-mediawiki: rewrite unclear line of instructions

Subroutines' parameters should be assigned to variable before doing anything
else
Besides, existing instruction affected a variable inside a "if", which break
Git's coding style

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: change syntax of map callsCélestin Matte Fri, 14 Jun 2013 13:50:14 +0000 (15:50 +0200)

git-remote-mediawiki: change syntax of map calls

Put first parameter of map inside a block, for better readability.
Follow BuiltinFunctions::RequireBlockMap

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: move a variable declaration at... Célestin Matte Fri, 14 Jun 2013 13:50:13 +0000 (15:50 +0200)

git-remote-mediawiki: move a variable declaration at the top of the code

%basetimestamps declaration was lost in the middle of subroutines

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: always end a subroutine with... Célestin Matte Fri, 14 Jun 2013 13:50:12 +0000 (15:50 +0200)

git-remote-mediawiki: always end a subroutine with a return

Follow Subroutines::RequireFinalReturn

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: replace :utf8 by :encoding(UTF-8)Célestin Matte Fri, 14 Jun 2013 13:50:11 +0000 (15:50 +0200)

git-remote-mediawiki: replace :utf8 by :encoding(UTF-8)

Follow perlcritic's InputOutput::RequireEncodingWithUTF8Layer policy

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: move "use warnings;" before any... Célestin Matte Fri, 14 Jun 2013 13:50:10 +0000 (15:50 +0200)

git-remote-mediawiki: move "use warnings;" before any instruction

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: make a regexp clearerCélestin Matte Fri, 14 Jun 2013 13:50:09 +0000 (15:50 +0200)

git-remote-mediawiki: make a regexp clearer

Perl's split function takes a regex pattern argument. You can also
feed it an expression, which is then compiled into a regex at runtime.
It therefore works to pass your pattern via single quotes, but it is
much less obvious to a reader that the argument is meant to be a
regex, not a static string. Using the traditional slash-delimiters
makes this easier to read.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rr/complete-difftool-fixup'Junio C Hamano Fri, 14 Jun 2013 15:46:23 +0000 (08:46 -0700)

Merge branch 'rr/complete-difftool-fixup'

"git difftool" can take both revs to be compared and pathspecs.
"git show" takes revs, revs:path and pathspecs.

* rr/complete-difftool-fixup:
completion: show can take both revlist and paths
completion: difftool takes both revs and files

Merge branch 'mt/send-email-cc-match-fix'Junio C Hamano Fri, 14 Jun 2013 15:46:20 +0000 (08:46 -0700)

Merge branch 'mt/send-email-cc-match-fix'

Logic git-send-email used to suppress cc mishandled names like "A
U. Thor" <author@example.xz>, where the human readable part needs
to be quoted (the user input may not have the double quotes around
the name, and comparison was done between quoted and unquoted
strings).

* mt/send-email-cc-match-fix:
test-send-email: test for pre-sanitized self name
t/send-email: test suppress-cc=self with non-ascii
t/send-email: add test with quoted sender
send-email: make --suppress-cc=self sanitize input
t/send-email: test suppress-cc=self on cccmd
send-email: fix suppress-cc=self on cccmd
t/send-email.sh: add test for suppress-cc=self