Code

git.git
13 years agomake_absolute_path: return the input path if it points to our buffer
Carlos Martín Nieto [Wed, 16 Mar 2011 16:06:17 +0000 (17:06 +0100)]
make_absolute_path: return the input path if it points to our buffer

Some codepaths call make_absolute_path with its own return value as
input. In such a cases, return the path immediately.

This fixes a valgrind-discovered error, whereby we tried to copy a
string onto itself.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agovalgrind: ignore SSE-based strlen invalid reads
Carlos Martín Nieto [Wed, 16 Mar 2011 11:46:01 +0000 (12:46 +0100)]
valgrind: ignore SSE-based strlen invalid reads

Some versions of strlen use SSE to speed up the calculation and load 4
bytes at a time, even if it means reading past the end of the
allocated memory. This read is safe and when the strlen function is
inlined, it is not replaced by valgrind, which reports a
false-possitive.

Tell valgrind to ignore this particular error, as the read is, in
fact, safe. Current upstream-released version 3.6.1 is affected. Some
distributions have this fixed in their latest versions.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiff --submodule: split into bite-sized pieces
Jonathan Nieder [Wed, 16 Mar 2011 07:14:11 +0000 (02:14 -0500)]
diff --submodule: split into bite-sized pieces

Introduce two functions:

 - prepare_submodule_summary prepares the revision walker
   to list changes in a submodule.  That is, it:

   * finds merge bases between the commits pointed to this
     path from before ("left") and after ("right") the change;
   * checks whether this is a fast-forward or fast-backward;
   * prepares a revision walk to list commits in the symmetric
     difference between the commits at each endpoint.

   It returns nonzero on error.

 - print_submodule_summary runs the revision walk and saves
   the result to a strbuf in --left-right format.

The goal is just readability.  No functional change intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocherry: split off function to print output lines
Jonathan Nieder [Wed, 16 Mar 2011 07:12:48 +0000 (02:12 -0500)]
cherry: split off function to print output lines

Readers uninterested in the details of "git cherry"'s output format
can see

print_commit('-', commit, verbose, abbrev);

and ignore the details.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agobranch: split off function that writes tracking info and commit subject
Jonathan Nieder [Wed, 16 Mar 2011 07:10:14 +0000 (02:10 -0500)]
branch: split off function that writes tracking info and commit subject

Introduce a add_verbose_info function that takes care of adding

 - an abbreviated object name;
 - a summary of the form [ahead x, behind y] of the relationship
   to the corresponding upstream branch;
 - a one line commit subject

for the tip commit of a branch, for use in "git branch -v" output.

No functional change intended.  This just unindents the code a little
and makes it easier to skip on first reading.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agostandardize brace placement in struct definitions
Jonathan Nieder [Wed, 16 Mar 2011 07:08:34 +0000 (02:08 -0500)]
standardize brace placement in struct definitions

In a struct definitions, unlike functions, the prevailing style is for
the opening brace to go on the same line as the struct name, like so:

 struct foo {
int bar;
char *baz;
 };

Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many
matches as 'struct [a-z_]*$'.

Linus sayeth:

 Heretic people all over the world have claimed that this inconsistency
 is ...  well ...  inconsistent, but all right-thinking people know that
 (a) K&R are _right_ and (b) K&R are right.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocompat: make gcc bswap an inline function
Jonathan Nieder [Wed, 16 Mar 2011 07:00:49 +0000 (02:00 -0500)]
compat: make gcc bswap an inline function

Without this change, gcc -pedantic warns:

 cache.h: In function 'ce_to_dtype':
 cache.h:270:21: warning: ISO C forbids braced-groups within expressions [-pedantic]

An inline function is more readable anyway.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoenums: omit trailing comma for portability
Jonathan Nieder [Wed, 16 Mar 2011 06:59:10 +0000 (01:59 -0500)]
enums: omit trailing comma for portability

Since v1.7.2-rc0~23^2~2 (Add per-repository eol normalization,
2010-05-19), building with gcc -std=gnu89 -pedantic produces warnings
like the following:

 convert.c:21:11: warning: comma at end of enumerator list [-pedantic]

gcc is right to complain --- these commas are not permitted in C89.
In the spirit of v1.7.2-rc0~32^2~16 (2010-05-14), remove them.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-bisect.txt: example for bisecting with hot-fix
Michael J Gruber [Tue, 15 Mar 2011 21:24:56 +0000 (22:24 +0100)]
git-bisect.txt: example for bisecting with hot-fix

Give an example on how to bisect when older revisions need a hot-fix to
build, run or test. Triggered by the binutils/kernel issue at

http://thread.gmane.org/gmane.comp.gnu.binutils/52601/focus=1112779

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-bisect.txt: streamline run presentation
Michael J Gruber [Tue, 15 Mar 2011 21:24:55 +0000 (22:24 +0100)]
git-bisect.txt: streamline run presentation

Streamline the presentation of "bisect run" by removing one example
which does not introduce new concepts.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agolist-objects.c: don't add an unparsed NULL as a pending tree
Junio C Hamano [Mon, 14 Mar 2011 19:29:50 +0000 (12:29 -0700)]
list-objects.c: don't add an unparsed NULL as a pending tree

"git rev-list --first-parent --boundary $commit^..$commit" segfaults on a
merge commit since 8d2dfc4 (process_{tree,blob}: show objects without
buffering, 2009-04-10), as it tried to dereference a commit that was
discarded as UNINTERESTING without being parsed (hence lacking "tree").

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit stash: show status relative to current directory
Piotr Krukowiecki [Sat, 12 Mar 2011 08:57:46 +0000 (09:57 +0100)]
git stash: show status relative to current directory

git status shows modified paths relative to current directory, so it's
possible to copy&paste them directly, even if you're in a subdirectory.

But "git stash apply" always shows status from root of git repository.
This is misleading because you can't use the paths without modifications.

This is caused by changing directory to root of repository at the
beginning of git stash.

This patch makes git stash show status relative to current directory.
Instead of removing the "cd to toplevel", which would affect whole
script and might have other side-effects, the fix is to change directory
temporarily back to original dir just before displaying status.

Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMake the default abbrev length configurable
Linus Torvalds [Thu, 28 Oct 2010 18:28:04 +0000 (11:28 -0700)]
Make the default abbrev length configurable

The default of 7 comes from fairly early in git development, when
seven hex digits was a lot (it covers about 250+ million hash
values). Back then I thought that 65k revisions was a lot (it was what
we were about to hit in BK), and each revision tends to be about 5-10
new objects or so, so a million objects was a big number.

These days, the kernel isn't even the largest git project, and even
the kernel has about 220k revisions (_much_ bigger than the BK tree
ever was) and we are approaching two million objects. At that point,
seven hex digits is still unique for a lot of them, but when we're
talking about just two orders of magnitude difference between number
of objects and the hash size, there _will_ be collisions in truncated
hash values. It's no longer even close to unrealistic - it happens all
the time.

We should both increase the default abbrev that was unrealistically
small, _and_ add a way for people to set their own default per-project
in the git config file.

This is the first step to first make it configurable; the default of 7
is not raised yet.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoRevert "core.abbrevguard: Ensure short object names stay unique a bit longer"
Junio C Hamano [Fri, 11 Mar 2011 06:41:14 +0000 (22:41 -0800)]
Revert "core.abbrevguard: Ensure short object names stay unique a bit longer"

This reverts commit 72a5b561fc1c4286bc7c5b0693afc076af261e1f, as adding
fixed number of hexdigits more than necessary to make one object name
locally unique does not help in futureproofing the uniqueness of names
we generate today.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-log.txt,rev-list-options.txt: put option blocks in proper order
Michael J Gruber [Tue, 8 Mar 2011 08:31:26 +0000 (09:31 +0100)]
git-log.txt,rev-list-options.txt: put option blocks in proper order

Match the order of the description to the one in which they get applied:

  commit limiting
  commit ordering
  commit formatting
  diff options

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agolog: fix --max-count when used together with -S or -G
Matthieu Moy [Wed, 9 Mar 2011 20:52:15 +0000 (21:52 +0100)]
log: fix --max-count when used together with -S or -G

The --max-count limit is implemented by counting revisions in
get_revision(), but the -S and -G take effect later when running diff.
Hence "--max-count=10 -Sfoo" meant "examine the 10 first revisions, and
out of them, show only those changing the occurences of foo", not "show 10
revisions changing the occurences of foo".

In case the commit isn't actually shown, cancel the decrement of
max_count.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoFix typo in t/README
Mathias Lafeldt [Wed, 9 Mar 2011 20:25:09 +0000 (21:25 +0100)]
Fix typo in t/README

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agols-remote documentation: <refs> argument is optional
Piotr Krukowiecki [Wed, 9 Mar 2011 20:03:48 +0000 (21:03 +0100)]
ls-remote documentation: <refs> argument is optional

Correct SYNOPSIS section.

Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoAdd Author and Documentation sections to git-for-each-ref.txt
Alexei Sholik [Tue, 8 Mar 2011 13:16:10 +0000 (15:16 +0200)]
Add Author and Documentation sections to git-for-each-ref.txt

Signed-off-by: Alexei Sholik <alcosholik@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDocumentation: remove redundant colons in git-for-each-ref.txt
Alexei Sholik [Tue, 8 Mar 2011 13:16:09 +0000 (15:16 +0200)]
Documentation: remove redundant colons in git-for-each-ref.txt

Signed-off-by: Alexei Sholik <alcosholik@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoSubmittingPatches: clarify the expected commit log description
Junio C Hamano [Wed, 9 Mar 2011 00:58:19 +0000 (16:58 -0800)]
SubmittingPatches: clarify the expected commit log description

Earlier, 47afed5 (SubmittingPatches: itemize and reflect upon well written
changes, 2009-04-28) added a discussion on the contents of the commit log
message, but the last part of the new paragraph didn't make much sense.
Reword it slightly to make it more readable.

Update the "quicklist" to clarify what we mean by "motivation" and
"contrast".  Also mildly discourage external references.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiff format documentation: clarify --cc and -c
Adam Monsen [Tue, 8 Mar 2011 20:51:37 +0000 (12:51 -0800)]
diff format documentation: clarify --cc and -c

The description was unclear if -c or --cc was the default (--cc is for
some commands), and incorrectly implied that the default applies to
all the diff generating commands.

Most importantly, "log" does not default to "--cc" (it defaults to
"--no-merges") and "log -p" obeys the user's wish to see non-combined
format.  Only "diff" (during merge and three-blob comparison) and
"show" use --cc as the default.

Signed-off-by: Adam Monsen <haircut@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-log.txt,rev-list-options.txt: -n/--max-count is commit limiting
Michael J Gruber [Tue, 8 Mar 2011 08:31:25 +0000 (09:31 +0100)]
git-log.txt,rev-list-options.txt: -n/--max-count is commit limiting

They are applied after commit ordering and formatting options, in
particular --reverse.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agorev-list-options.txt: typo fix
Michael J Gruber [Tue, 8 Mar 2011 08:31:24 +0000 (09:31 +0100)]
rev-list-options.txt: typo fix

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-compat-util.h: Honor HP C's noreturn attribute
Michal Rokos [Mon, 7 Mar 2011 12:13:15 +0000 (13:13 +0100)]
git-compat-util.h: Honor HP C's noreturn attribute

HP C for Integrity servers (Itanium) gained support for noreturn
attribute sometime in 2006. It was released in Compiler Version
A.06.10 and made available in July 2006.

The __HP_cc define detects the HP C compiler version.  Precede the
__GNUC__ check so it works well when compiling with HP C using -Agcc
option that enables partial support for the GNU C dialect. The -Agcc
defines the __GNUC__ too.

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMakefile: add NO_FNMATCH_CASEFOLD to HP-UX section
Michal Rokos [Mon, 7 Mar 2011 11:43:11 +0000 (12:43 +0100)]
Makefile: add NO_FNMATCH_CASEFOLD to HP-UX section

fnmatch() on HP-UX does not support the GNU FNM_CASEFOLD extension,
so set NO_FNMATCH_CASEFOLD to use the internal fnmatch implementation.

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoapply -v: show offset count when patch did not apply exactly
Junio C Hamano [Fri, 4 Mar 2011 22:43:45 +0000 (14:43 -0800)]
apply -v: show offset count when patch did not apply exactly

When the line number the patch intended to touch does not match
the line in the version being patched, GNU patch reports that
it applied the hunk at a different line number, with how big an
offset.

Teach "git apply" to do the same under --verbose option.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoapply: do not patch lines that were already patched
Junio C Hamano [Fri, 4 Mar 2011 20:25:34 +0000 (12:25 -0800)]
apply: do not patch lines that were already patched

When looking for a place to apply a hunk, we used to check lines that
match the preimage of it, starting from the line that the patch wants to
apply the hunk at, looking forward and backward with increasing offsets
until we find a match.

Colin Guthrie found an interesting case where this misapplied a patch that
wanted to touch a preimage that consists of

                        }
                }

                return 0;
        }

which is a rather unfortunately common pattern.

The target version of the file originally had only one such location, but
the hunk immediately before that created another instance of such block of
lines, and find_pos() happily reported that the preimage of the hunk
matched what it wanted to modify.

Oops.

By marking the lines application of earlier hunks touched and preventing
match_fragment() from considering them as a match with preimage of other
hunks, we can reduce such an accident.

I also considered to teach apply_one_fragment() to take the offset we have
found while applying the previous hunk into account when looking for a
match with find_pos(), but dismissed that approach, because it would
sometimes work better but sometimes worse, depending on the difference
between the version the patch was created against and the version the
patch is being applied.

This does _not_ prevent misapplication of patches to a file that has many
similar looking blocks of lines and a preimage cannot identify which one
of them should be applied.  For that, we would need to scan beyond the
first match in find_pos(), and issue a warning (or error out).  That will
be a separate topic.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDocumentation: fix a typo in git-apply.txt
Michał Kiedrowicz [Thu, 3 Mar 2011 09:28:30 +0000 (10:28 +0100)]
Documentation: fix a typo in git-apply.txt

git-apply accepts the --cached option, not --cache.

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoinit: remove unnecessary check
Nguyễn Thái Ngọc Duy [Thu, 3 Mar 2011 12:34:51 +0000 (19:34 +0700)]
init: remove unnecessary check

git_dir must always be non-NULL so "if (git_dir)" is unnecessary.
Before this code, if git_dir == NULL, it will default to
DEFAULT_GIT_DIR_ENVIRONMENT.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agosha1_file.c: Don't retain open fds on small packs
Shawn O. Pearce [Wed, 2 Mar 2011 18:01:54 +0000 (10:01 -0800)]
sha1_file.c: Don't retain open fds on small packs

If a pack file is small enough that its entire contents fits within
one mmap window, mmap the file and then immediately close its file
descriptor.  This reduces the number of file descriptors that are
needed to read from repositories with many tiny pack files, such
as one that has received 1000 pushes (and created 1000 small pack
files) since its last repack.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agomingw: add minimum getrlimit() compatibility stub
Erik Faye-Lund [Mon, 28 Feb 2011 21:13:22 +0000 (22:13 +0100)]
mingw: add minimum getrlimit() compatibility stub

We don't have getrlimit on Windows :( Limit of 2048 taken from MSDN:

  http://msdn.microsoft.com/en-us/library/6e3b887c(v=vs.71).aspx

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
13 years agoverify-pack: add --stat-only to the synopsis section
Junio C Hamano [Tue, 1 Mar 2011 19:26:22 +0000 (11:26 -0800)]
verify-pack: add --stat-only to the synopsis section

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoLimit file descriptors used by packs
Shawn O. Pearce [Mon, 28 Feb 2011 20:52:39 +0000 (12:52 -0800)]
Limit file descriptors used by packs

Rather than using 'errno == EMFILE' after a failed open() call
to indicate the process is out of file descriptors and an LRU
pack window should be closed, place a hard upper limit on the
number of open packs based on the actual rlimit of the process.

By using a hard upper limit that is below the rlimit of the current
process it is not necessary to check for EMFILE on every single
fd-allocating system call.  Instead reserving 25 file descriptors
makes it safe to assume the system call won't fail due to being over
the filedescriptor limit.  Here 25 is chosen as a WAG, but considers
3 for stdin/stdout/stderr, and at least a few for other Git code
to operate on temporary files.  An additional 20 is reserved as it
is not known what the C library needs to perform other services on
Git's behalf, such as nsswitch or name resolution.

This fixes a case where running `git gc --auto` in a repository
with more than 1024 packs (but an rlimit of 1024 open fds) fails
due to the temporary output file not being able to allocate a
file descriptor.  The output file is opened by pack-objects after
object enumeration and delta compression are done, both of which
have already opened all of the packs and fully populated the file
descriptor table.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-instaweb: Change how gitweb.psgi is made runnable as standalone app
Jakub Narebski [Sat, 26 Feb 2011 22:32:33 +0000 (23:32 +0100)]
git-instaweb: Change how gitweb.psgi is made runnable as standalone app

According to blog post "FindBin, __FILE__, $0 and PSGI woes"

  http://bulknews.typepad.com/blog/2011/02/findbin-__file__-0-and-psgi-woes.html

by Tatsuhiko Miyagawa, using 'if (__FILE__ eq $0)' in .psgi code
(to check if script was run from command line), is not supposed to work
since Plack 0.9971.

Replace it with one of proposed solutions; while at it return $app
explicitely, rather than implicitely by being a last expression.

This affects 'plackup' web server.

While at it cleanup whitespace.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-cvsimport.perl: Bail out right away when reading from the server fails
Fabian Keil [Mon, 31 Jan 2011 19:29:46 +0000 (20:29 +0100)]
git-cvsimport.perl: Bail out right away when reading from the server fails

If the CVS server is down, this reduced the git-cvsimport output from:

ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused
Use of uninitialized value $rep in scalar chomp at /usr/local/libexec/git-core/git-cvsimport line 369.
Use of uninitialized value $rep in substitution (s///) at /usr/local/libexec/git-core/git-cvsimport line 370.
Expected Valid-requests from server, but got: <unknown>

to the less noisy:

ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused
Failed to read from server at /usr/local/libexec/git-core/git-cvsimport line 370.

In this case a silent exit() instead of the die() would probably do,
but I assume that there could be cases where the connection attempt
succeeds, but reading from the server fails for other reasons.

Signed-off-by: Fabian Keil <fk@fabiankeil.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodoc: technical details about the index file format
Nguyễn Thái Ngọc Duy [Mon, 6 Sep 2010 10:37:10 +0000 (20:37 +1000)]
doc: technical details about the index file format

This bases on the original work by Robin Rosenberg.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agobranch_merged: fix grammar in warning
Eric Hanchrow [Sat, 26 Feb 2011 03:29:42 +0000 (19:29 -0800)]
branch_merged: fix grammar in warning

Signed-off-by: Eric Hanchrow <eric.hanchrow@gmail.com>
Helped-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocommit: error out for missing commit message template
Jonathan Nieder [Fri, 25 Feb 2011 09:07:57 +0000 (03:07 -0600)]
commit: error out for missing commit message template

When "git commit" was rewritten in C (v1.5.4-rc0~78^2~30,
2007-11-08), a subtle bug in --template was introduced.  If the
file named by a --template parameter is missing, previously git
would error out with a message:

Commit template file does not exist.

but in the C version the --template parameter gets ignored and
the default template is used.

t7500 has two tests for this case which would have caught it, except
that with the default $EDITOR, the commit message template is left
unmodified, causing 'git commit' to error out and the test to
succeed.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agomergetool-lib: call vim in readonly mode for diffs
Michael J Gruber [Fri, 25 Feb 2011 09:36:39 +0000 (10:36 +0100)]
mergetool-lib: call vim in readonly mode for diffs

When [g]vimdiff is called for files which are opened already, the editor
complains about the existing swap file. But we do not want to write
anything when called from difftool. So, make difftool use "-R" for the
vim family. This

- prevents the use of a swap file and
- marks the buffers readonly.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoformat-patch: rfc2047-encode newlines in headers
Jeff King [Wed, 23 Feb 2011 09:59:18 +0000 (04:59 -0500)]
format-patch: rfc2047-encode newlines in headers

These should generally never happen, as we already
concatenate multiples in subjects into a single line. But
let's be defensive, since not encoding them means we will
output malformed headers.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoformat-patch: wrap long header lines
Jeff King [Wed, 23 Feb 2011 09:58:41 +0000 (04:58 -0500)]
format-patch: wrap long header lines

Subject and identity headers may be arbitrarily long. In the
past, we just assumed that single-line headers would be
reasonably short. For multi-line subjects that we squish
into a single line, we just "pre-folded" the data in
pp_title_line by adding a newline and indentation.

There were two problems. One is that, although rare,
single-line messages can actually be longer than the
recommended line-length limits. The second is that the
pre-folding interacted badly with rfc2047 encoding, leading
to malformed headers.

Instead, let's stop pre-folding the subject lines, and just
fold everything based on length in add_rfc2047, whether
it is encoded or not.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agostrbuf: add fixed-length version of add_wrapped_text
Jeff King [Wed, 23 Feb 2011 09:50:19 +0000 (04:50 -0500)]
strbuf: add fixed-length version of add_wrapped_text

The function strbuf_add_wrapped_text takes a NUL-terminated
string. This makes it annoying to wrap strings we have as a
pointer and a length.

Refactoring strbuf_add_wrapped_text and all of its
sub-functions to handle fixed-length strings turned out to
be really ugly. So this implementation is lame; it just
strdups the text and operates on the NUL-terminated version.
This should be fine as the strings we are wrapping are
generally pretty short.  If it becomes a problem, we can
optimize later.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDisallow empty section and variable names
Libor Pechacek [Tue, 1 Feb 2011 07:13:47 +0000 (08:13 +0100)]
Disallow empty section and variable names

It is possible to break your repository config by creating an invalid key.  The
config parser in turn chokes on it:

  $ git init
  Initialized empty Git repository in /tmp/gittest/.git/
  $ git config .foo false
  $ git config core.bare
  fatal: bad config file line 6 in .git/config

This patch makes git-config reject keys which start or end with a dot and adds
tests for these cases.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoSanity-check config variable names
Libor Pechacek [Sun, 30 Jan 2011 19:40:41 +0000 (20:40 +0100)]
Sanity-check config variable names

Sanity-check config variable names when adding and retrieving them.  As a side
effect code duplication between git_config_set_multivar and get_value (in
builtin/config.c) was removed and the common functionality was placed in
git_config_parse_key.

This breaks a test in t1300 which used invalid section-less keys in the tests
for "git -c". However, allowing such names there was useless, since there was
no way to set them via config file, and no part of git actually tried to use
section-less keys. This patch updates the test to use more realistic examples
as well as adding its own test.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiff: don't retrieve binary blobs for diffstat
Jeff King [Sat, 19 Feb 2011 08:16:32 +0000 (03:16 -0500)]
diff: don't retrieve binary blobs for diffstat

We only need the size, which is much cheaper to get,
especially if it is a big binary file.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiff: handle diffstat of rewritten binary files
Jeff King [Sat, 19 Feb 2011 08:04:56 +0000 (03:04 -0500)]
diff: handle diffstat of rewritten binary files

The logic in builtin_diffstat assumes that a
complete_rewrite pair should have its lines counted. This is
nonsensical for binary files and leads to confusing things
like:

  $ git diff --stat --summary HEAD^ HEAD
   foo.rand |  Bin 4096 -> 4096 bytes
   1 files changed, 0 insertions(+), 0 deletions(-)

  $ git diff --stat --summary -B HEAD^ HEAD
   foo.rand |   34 +++++++++++++++-------------------
   1 files changed, 15 insertions(+), 19 deletions(-)
   rewrite foo.rand (100%)

So let's reorder the function to handle binary files first
(which from diffstat's perspective look like complete
rewrites anyway), then rewrites, then actual diffstats.

There are two bonus prizes to this reorder:

  1. It gets rid of a now-superfluous goto.

  2. The binary case is at the top, which means we can
     further optimize it in the next patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodo not overwrite untracked symlinks
Clemens Buchacher [Sun, 20 Feb 2011 12:13:43 +0000 (13:13 +0100)]
do not overwrite untracked symlinks

Git traditionally overwrites untracked symlinks silently. This will
generally not cause massive data loss, but it is inconsistent with
the behavior for regular files, which are not silently overwritten.

With this change, git refuses to overwrite untracked symlinks by
default. If the user really wants to overwrite the untracked
symlink, he has git-clean and git-checkout -f at his disposal.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDocumentation: clarify -u<mode> option defaults
Clemens Buchacher [Mon, 21 Feb 2011 20:05:25 +0000 (21:05 +0100)]
Documentation: clarify -u<mode> option defaults

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agot/t7500-commit.sh: use test_cmp instead of test
Ævar Arnfjörð Bjarmason [Sat, 19 Feb 2011 18:29:09 +0000 (18:29 +0000)]
t/t7500-commit.sh: use test_cmp instead of test

Change commit_msg_is() in t/t7500-commit.sh to use test_cmp instead of
the shell's test function. Now if a test fails we'll get test_cmp
output showing us what failed.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agot/gitweb-lib.sh: Ensure that errors are shown for --debug --immediate
Ævar Arnfjörð Bjarmason [Sat, 19 Feb 2011 18:16:19 +0000 (19:16 +0100)]
t/gitweb-lib.sh: Ensure that errors are shown for --debug --immediate

Because '--immediate' stops test suite after first error, therefore in
this mode

  test_debug 'cat gitweb.log'

was never ran, thus in effect negating effect of '--debug' option.
This made finidng the cause of errors in gitweb test sute difficult.

Modify the gitweb_run test subroutine to run test_debug itself in the
case of errors (and also remove "test_debug 'cat gitweb.log'" from
gitweb tests).

This makes it possible to run *gitweb tests* with --immediate ---debug
combination of options; also it makes gitweb tests to not output
spurious debug data that is not considered error.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogitweb/gitweb.perl: don't call S_ISREG() with undef
Ævar Arnfjörð Bjarmason [Sat, 19 Feb 2011 15:27:42 +0000 (15:27 +0000)]
gitweb/gitweb.perl: don't call S_ISREG() with undef

Change S_ISREG($to_mode_oct) to S_ISREG($from_mode_oct) in the branch
that handles from modes, not to modes. This logic appears to have been
caused by copy/paste programming by Jakub Narebski in e8e41a93. It
would be better to rewrite this code not to be duplicated, but I
haven't done so.

This issue caused a failing test on perl 5.13.9, which has a warning
that turned this up:

     gitweb.perl: Use of uninitialized value in subroutine entry at /home/avar/g/git/t/../gitweb/gitweb.perl line 4415.

Which caused the Git test suite to fail on this test:

    ./t9500-gitweb-standalone-no-errors.sh             (Wstat: 256 Tests: 90 Failed: 84)
      Failed tests:  1-8, 10-36, 38-45, 47-48, 50-88
      Non-zero exit status: 1

Reported-by: perl 5.13.9
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogitweb/gitweb.perl: remove use of qw(...) as parentheses
Ævar Arnfjörð Bjarmason [Sat, 19 Feb 2011 15:27:41 +0000 (15:27 +0000)]
gitweb/gitweb.perl: remove use of qw(...) as parentheses

Using the qw(...) construct as implicit parentheses was deprecated in
perl 5.13.5. Change the relevant code in gitweb to not use the
deprecated construct. The offending code was introduced in 3562198b by
Jakub Narebski.

The issue is that perl will now warn about this:

    $ perl -wE 'for my $i qw(a b) { say $i }'
    Use of qw(...) as parentheses is deprecated at -e line 1.
    a
    b

This caused gitweb.perl to warn on perl 5.13.5 and above, and these
tests to fail on those perl versions:

    ./t9501-gitweb-standalone-http-status.sh           (Wstat: 256 Tests: 11 Failed: 10)
      Failed tests:  2-11
      Non-zero exit status: 1
    ./t9502-gitweb-standalone-parse-output.sh          (Wstat: 256 Tests: 10 Failed: 9)
      Failed tests:  2-10
      Non-zero exit status: 1

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiffcore-rename: improve estimate_similarity() heuristics
Linus Torvalds [Sat, 19 Feb 2011 04:12:06 +0000 (20:12 -0800)]
diffcore-rename: improve estimate_similarity() heuristics

The logic to quickly dismiss potential rename pairs was broken.  It
would too eagerly dismiss possible renames when all of the difference
was due to pure new data (or deleted data).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agodiffcore-rename: properly honor the difference between -M and -C
Linus Torvalds [Sat, 19 Feb 2011 04:10:32 +0000 (20:10 -0800)]
diffcore-rename: properly honor the difference between -M and -C

We would allow rename detection to do copy detection even when asked
purely for renames.  That confuses users, but more importantly it can
terminally confuse the recursive merge rename logic.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agofor_each_hash: allow passing a 'void *data' pointer to callback
Linus Torvalds [Sat, 19 Feb 2011 03:55:19 +0000 (19:55 -0800)]
for_each_hash: allow passing a 'void *data' pointer to callback

For the find_exact_renames() function, this allows us to pass the
diff_options structure pointer to the low-level routines.  We will use
that to distinguish between the "rename" and "copy" cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoclone: die when trying to clone missing local path
Jeff King [Fri, 18 Feb 2011 04:01:52 +0000 (23:01 -0500)]
clone: die when trying to clone missing local path

Since 86ac751 (Allow cloning an empty repository,
2009-01-23), doing:

  git clone does-not-exist

has created does-not-exist as an empty repository. This was
an unintentional side effect of 86ac751. Even weirder,
doing:

  git clone does-not-exist new-dir

_does_ fail, making this "feature" (if you want to consider
it such) broken. Let's detect this situation and explicitly
die. It's almost certainly not what the user intended.

This patch also adds two tests. One for the missing path
case, and one to confirm that a similar case, cloning a
non-repository directory, fails.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agotests: skip terminal output tests on OS X
Jonathan Nieder [Thu, 17 Feb 2011 12:38:52 +0000 (06:38 -0600)]
tests: skip terminal output tests on OS X

On Mac OS X 10.5.0, test_terminal gets stuck reading from the pty
master every once in a while.  To reproduce the problem:

 perl -MIO::Pty -MFile::Copy -e '
for (my $i = 0;; $i++) {
my $master = new IO::Pty;
my $slave = $master->slave;
if (fork == 0) {
close $master or die "close: $!";
open STDOUT, ">&", $slave or die "dup2: $!";
close $slave or die "close: $!";
exec("echo", "hi", $i) or die "exec: $!";
}
close $slave or die "close: $!";
copy($master, \*STDOUT) or die "copy: $!";
close $master or die "close: $!";
wait;
}
 '

It blocks after 7000 iterations or so in sysread().  The relevant
sysread() call is the second call by the parent, which presumably
executes before the child dies but after the parent has read all
output from there.

Since this is an intermitent problem, the quick check of terminal
support in lib-terminal doesn't catch it.  Skip these tests on the Mac
for now.

Noticed-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agot7406: "git submodule update {--merge|--rebase]" with new submodules
Spencer E. Olson [Thu, 17 Feb 2011 16:18:46 +0000 (09:18 -0700)]
t7406: "git submodule update {--merge|--rebase]" with new submodules

Add two test cases in t7406 to ensure that the --merge/--rebase options
are ignored for "git submodule update" with new modules.  These test that
a simple checkout is performed instead.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agosubmodule: no [--merge|--rebase] when newly cloned
Spencer E. Olson [Thu, 17 Feb 2011 16:18:45 +0000 (09:18 -0700)]
submodule: no [--merge|--rebase] when newly cloned

"git submodule update" can be run with either the "--merge" or "--rebase"
option, or submodule.<name>.update configuration variable can be set to
"merge" or "rebase, to cause local work to get integrated when updating
the submodule.

When a submodule is newly cloned, however, it does not have a check out
when a rebase or merge is attempted, leading to a failure.  For newly
cloned submodules, simply check out the appropriate revision.  There is no
local work to integrate with for them.

Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-patch-id: do not trip over "no newline" markers
Michael J Gruber [Thu, 17 Feb 2011 07:44:42 +0000 (08:44 +0100)]
git-patch-id: do not trip over "no newline" markers

Currently, patch-id trips over our very own diff extension for marking
the absence of newline at EOF.

Fix it. (Ignore it, it's whitespace.)

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-patch-id: test for "no newline" markers
Michael J Gruber [Wed, 16 Feb 2011 16:55:37 +0000 (17:55 +0100)]
git-patch-id: test for "no newline" markers

Currently, patch-id trips over our very own output that marks the absence
of newline at EOF.

Expose this in a test.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMake <identifier> lowercase in Documentation
Michael J Gruber [Thu, 17 Feb 2011 07:48:06 +0000 (08:48 +0100)]
Make <identifier> lowercase in Documentation

Leaving uppercase abbreviations (e.g. URL) and an identifier named after
an upercase env variable (CVSROOT) in place, this adjusts the few
remaining cases and fixes an unidentified identifier along the way.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agobranch/checkout --track: Ensure that upstream branch is indeed a branch
Johan Herland [Wed, 16 Feb 2011 23:12:20 +0000 (00:12 +0100)]
branch/checkout --track: Ensure that upstream branch is indeed a branch

When creating a new branch using the --track option, we must make sure that
we don't try to set an upstream that does not make sense to follow (using
'git pull') or update (using 'git push'). The current code checks against
using HEAD as upstream (since tracking a symref doesn't make sense). However,
tracking a tag doesn't make sense either. Indeed, tracking _any_ ref that is
not a (local or remote) branch doesn't make sense, and should be disallowed.

This patch achieves this by checking that the ref we're trying to --track
resides within refs/heads/* or refs/remotes/*. This new check replaces the
previous check against HEAD.

A couple of testcases are also added, verifying that we cannot create
branches with tags as upstreams.

Finally, some selftests relying on using a non-branch as an upstream have
been reworked or removed:

- t6040: Reverse the meaning of two tests that depend on the ability to
use (lightweight and annotated) tags as upstreams. These two tests were
originally added in commits 1be570f and 57ffc5f, and this patch reverts the
intention of those two commits.

- t7201: Remove part of a test (introduced in 9188ed8) relying on a
non-branch as upstream.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMerge branch 'maint-1.7.3' into maint
Junio C Hamano [Wed, 16 Feb 2011 22:33:11 +0000 (14:33 -0800)]
Merge branch 'maint-1.7.3' into maint

* maint-1.7.3:

13 years agoMerge branch 'maint-1.7.2' into maint-1.7.3
Junio C Hamano [Wed, 16 Feb 2011 22:32:59 +0000 (14:32 -0800)]
Merge branch 'maint-1.7.2' into maint-1.7.3

* maint-1.7.2:
  fast-import: introduce "feature notes" command
  fast-import: clarify documentation of "feature" command

13 years agoMerge branch 'maint-1.7.1' into maint-1.7.2
Junio C Hamano [Wed, 16 Feb 2011 22:32:54 +0000 (14:32 -0800)]
Merge branch 'maint-1.7.1' into maint-1.7.2

* maint-1.7.1:
  fast-import: introduce "feature notes" command
  fast-import: clarify documentation of "feature" command

13 years agoMerge branch 'maint-1.7.0' into maint-1.7.1
Junio C Hamano [Wed, 16 Feb 2011 22:32:47 +0000 (14:32 -0800)]
Merge branch 'maint-1.7.0' into maint-1.7.1

* maint-1.7.0:
  fast-import: introduce "feature notes" command
  fast-import: clarify documentation of "feature" command

13 years agopush.default: Rename 'tracking' to 'upstream'
Johan Herland [Wed, 16 Feb 2011 00:54:24 +0000 (01:54 +0100)]
push.default: Rename 'tracking' to 'upstream'

Users are sometimes confused with two different types of "tracking" behavior
in Git: "remote-tracking" branches (e.g. refs/remotes/*/*) versus the
merge/rebase relationship between a local branch and its @{upstream}
(controlled by branch.foo.remote and branch.foo.merge config settings).

When the push.default is set to 'tracking', it specifies that a branch should
be pushed to its @{upstream} branch. In other words, setting push.default to
'tracking' applies only to the latter of the above two types of "tracking"
behavior.

In order to make this more understandable to the user, we rename the
push.default == 'tracking' option to push.default == 'upstream'.

push.default == 'tracking' is left as a deprecated synonym for 'upstream'.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoparse_tag_buffer(): do not prefixcmp() out of range
Nguyễn Thái Ngọc Duy [Mon, 14 Feb 2011 13:02:51 +0000 (20:02 +0700)]
parse_tag_buffer(): do not prefixcmp() out of range

There is a check (size < 64) at the beginning of the function, but
that only covers object+type lines.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agomerge: honor prepare-commit-msg hook
Jay Soffian [Tue, 15 Feb 2011 01:07:50 +0000 (20:07 -0500)]
merge: honor prepare-commit-msg hook

When a merge is stopped due to conflicts or --no-commit, the
subsequent commit calls the prepare-commit-msg hook. However,
it is not called after a clean merge. Fix this inconsistency
by invoking the hook after clean merges as well.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMake <identifier> lowercase as per CodingGuidelines
Michael J Gruber [Tue, 15 Feb 2011 13:09:13 +0000 (14:09 +0100)]
Make <identifier> lowercase as per CodingGuidelines

*.c part for matches with '<[A-Z]+>' (and affected test).

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMake <identifier> lowercase as per CodingGuidelines
Michael J Gruber [Tue, 15 Feb 2011 13:09:12 +0000 (14:09 +0100)]
Make <identifier> lowercase as per CodingGuidelines

*.c part for matches with '"[A-Z]+"'.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMake <identifier> lowercase as per CodingGuidelines
Michael J Gruber [Tue, 15 Feb 2011 13:09:11 +0000 (14:09 +0100)]
Make <identifier> lowercase as per CodingGuidelines

parse-options part

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoCodingGuidelines: downcase placeholders in usage messages
Junio C Hamano [Tue, 15 Feb 2011 19:02:56 +0000 (11:02 -0800)]
CodingGuidelines: downcase placeholders in usage messages

We accumulated some inconsistencies without an explicit guidance to spell
this out over time.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agopull: do not display fetch usage on --help-all
Michael J Gruber [Mon, 14 Feb 2011 16:48:08 +0000 (17:48 +0100)]
pull: do not display fetch usage on --help-all

Currently, "git pull --help-all" displays the fetch usage info.

Make it equivalent to "git pull -h" instead since "--help-all" is
documented in gitcli(7).

Do not try to sanitize the pull option parser (aka last hair puller).

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agogit-tag.txt: list all modes in the description
Michael J Gruber [Tue, 15 Feb 2011 13:09:10 +0000 (14:09 +0100)]
git-tag.txt: list all modes in the description

Currently, the description sounds as if it applied always, but most of
its content is true in "create tag mode" only.

Make this clearer by listing all modes upfront.

Also, sneak in some linguistic improvements and make it clearer that
lightweight tags are "created" because "written" may be misread as
"are output".

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocommit,status: describe -u likewise
Michael J Gruber [Tue, 15 Feb 2011 13:09:09 +0000 (14:09 +0100)]
commit,status: describe -u likewise

They differ by one character only. Being exactly equal should help
translations.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoadd: describe --patch like checkout, reset
Michael J Gruber [Tue, 15 Feb 2011 13:09:08 +0000 (14:09 +0100)]
add: describe --patch like checkout, reset

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocommit,merge,tag: describe -m likewise
Michael J Gruber [Tue, 15 Feb 2011 13:09:07 +0000 (14:09 +0100)]
commit,merge,tag: describe -m likewise

This also removes the superfluous "specify" and rewords the misleading
"if any" which sounds as if omitting "-m" would omit the merge commit
message. (It means "if a merge commit is created at all".)

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoclone,init: describe --template using the same wording
Michael J Gruber [Tue, 15 Feb 2011 13:09:06 +0000 (14:09 +0100)]
clone,init: describe --template using the same wording

This also corrects a wrong description for clone.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocommit,status: describe --porcelain just like push
Michael J Gruber [Tue, 15 Feb 2011 13:09:05 +0000 (14:09 +0100)]
commit,status: describe --porcelain just like push

Push has the clearer description, so take that one for all.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocommit,tag: use same wording for -F
Michael J Gruber [Tue, 15 Feb 2011 13:09:04 +0000 (14:09 +0100)]
commit,tag: use same wording for -F

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDemonstrate breakage: checkout overwrites untracked symlink with directory
Johannes Sixt [Sat, 5 Feb 2011 18:18:44 +0000 (19:18 +0100)]
Demonstrate breakage: checkout overwrites untracked symlink with directory

This adds tests where an untracked file and an untracked symlink are in the
way where a directory should be created by 'git checkout'. Commit b1735b1a
(do not overwrite files in leading path, 2010-12-14) fixed the case where
a file is in the way, but the untracked symlink is still removed silently.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoperl: command_bidi_pipe() method should set-up git environmens
Masatake Osanai [Mon, 14 Feb 2011 22:13:04 +0000 (07:13 +0900)]
perl: command_bidi_pipe() method should set-up git environmens

When command_input_pipe and command_output_pipe are used as a
method of a Git::repository instance, they eventually call into
_cmd_exec method that sets up the execution environment such as
GIT_DIR, GIT_WORK_TREE environment variables and the current
working directory in the child process that interacts with the
repository.

command_bidi_pipe however didn't expect to be called as such, and
lacked all these set-up.  Because of this, a program that did this
did not work as expected:

    my $repo = Git->repository(Directory => '/some/where/else');
    my ($pid, $in, $out, $ctx) =
    $repo->command_bidi_pipe(qw(hash-object -w --stdin-paths));

This patch refactors the _cmd_exec into _setup_git_cmd_env that
sets up the execution environment, and makes _cmd_exec and
command_bidi_pipe to use it.

Note that unlike _cmd_exec that execv's a git command as an
external process, command_bidi_pipe is called from the main line
of control, and the execution environment needs to be restored
after open2() does its magic.

Signed-off-by: Masatake Osanai <unpush@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoconfigure: use AC_LANG_PROGRAM consistently
Ralf Wildenhues [Sun, 2 Jan 2011 10:24:55 +0000 (11:24 +0100)]
configure: use AC_LANG_PROGRAM consistently

Avoid warnings from Autoconf 2.68 about missing use of AC_LANG_PROGRAM
and friends.

Quoting autoconf-2.68/NEWS:

  ** The macros AC_PREPROC_IFELSE, AC_COMPILE_IFELSE, AC_LINK_IFELSE, and
     AC_RUN_IFELSE now warn if the first argument failed to use
     AC_LANG_SOURCE or AC_LANG_PROGRAM to generate the conftest file
     contents.  A new macro AC_LANG_DEFINES_PROVIDED exists if you have
     a compelling reason why you cannot use AC_LANG_SOURCE but must
     avoid the warning.

The underlying reason for that change is that AC_LANG_{SOURCE,PROGRAM}
take care to supply the previously computed set of #defines (and
include standard headers if so desired) for preprocessed languages
like C and C++.

In some cases, AC_LANG_PROGRAM is already used but not sufficiently
m4-quoted, so we just need to add another set of [quotes] to prevent
the autoconf warning from being triggered bogusly.  Quoting all
arguments (except when calling special macros that need to be expanded
before recursion) is better style, anyway.  These and more rules are
described in detail in 'info Autoconf "Programming in M4"'.

No change in the resulting config.mak.autogen after running
./configure intended.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agostring_list_append: always set util pointer to NULL
Jeff King [Sat, 12 Feb 2011 05:18:51 +0000 (00:18 -0500)]
string_list_append: always set util pointer to NULL

It is not immediately obvious that the util field may
contain random bytes after appending an item. Especially
since the string_list_insert* functions _do_ explicitly zero
the util pointer.

This does not appear to be a bug in any current git code, as
all callers either fill in the util field immediately or
never use it. However, it is worth it to be less surprising
to new users of the string-list API who may expect it to be
intialized to NULL.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocorrect type of EMPTY_TREE_SHA1_BIN
Jonathan Nieder [Mon, 7 Feb 2011 08:17:27 +0000 (02:17 -0600)]
correct type of EMPTY_TREE_SHA1_BIN

Functions such as hashcmp that expect a binary SHA-1 value take
parameters of type "unsigned char *" to avoid accepting a textual
SHA-1 passed by mistake.  Unfortunately, this means passing the string
literal EMPTY_TREE_SHA1_BIN requires an ugly cast.  Tweak the
definition of EMPTY_TREE_SHA1_BIN to produce a value of more
convenient type.

In the future the definition might change to

extern const unsigned char empty_tree_sha1_bin[20];
#define EMPTY_TREE_SHA1_BIN empty_tree_sha1_bin

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoGit 1.7.4.1 v1.7.4.1
Junio C Hamano [Fri, 11 Feb 2011 22:39:55 +0000 (14:39 -0800)]
Git 1.7.4.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMerge branch 'jc/fsck-fixes' into maint
Junio C Hamano [Fri, 11 Feb 2011 22:26:10 +0000 (14:26 -0800)]
Merge branch 'jc/fsck-fixes' into maint

* jc/fsck-fixes:
  fsck: do not give up too early in fsck_dir()
  fsck: drop unused parameter from traverse_one_object()

13 years agoclone: fixup recurse_submodules option
Chris Packham [Thu, 10 Feb 2011 22:59:31 +0000 (11:59 +1300)]
clone: fixup recurse_submodules option

The recurse_submodules option was added in ccdd3da6 to bring 'git clone'
into line with 'git fetch' and future commands. The correct option should
have been "recurse-submodules".

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agosvn-fe: warn about experimental status
Jonathan Nieder [Fri, 11 Feb 2011 10:36:44 +0000 (04:36 -0600)]
svn-fe: warn about experimental status

svn-fe is young and some coming cleanups might involve backward
incompatible UI changes.  Add some words of warning to the manual so
early adopters that are not following the project closely don't get
burned.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agocompat: helper for detecting unsigned overflow
Jonathan Nieder [Mon, 11 Oct 2010 02:59:26 +0000 (21:59 -0500)]
compat: helper for detecting unsigned overflow

The idiom (a + b < a) works fine for detecting that an unsigned
integer has overflowed, but a more explicit

unsigned_add_overflows(a, b)

might be easier to read.

Define such a macro, expanding roughly to ((a) < UINT_MAX - (b)).
Because the expansion uses each argument only once outside of sizeof()
expressions, it is safe to use with arguments that have side effects.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoMerge branch 'maint-1.7.0' into maint
Junio C Hamano [Thu, 10 Feb 2011 00:40:12 +0000 (16:40 -0800)]
Merge branch 'maint-1.7.0' into maint

* maint-1.7.0:
  fast-import: introduce "feature notes" command
  fast-import: clarify documentation of "feature" command

Conflicts:
Documentation/git-fast-import.txt

13 years agofast-import: introduce "feature notes" command
Jonathan Nieder [Wed, 9 Feb 2011 22:43:57 +0000 (16:43 -0600)]
fast-import: introduce "feature notes" command

Here is a 'feature' command for streams to use to require support for
the notemodify (N) command.

When the 'feature' facility was introduced (v1.7.0-rc0~95^2~4,
2009-12-04), the notes import feature was old news (v1.6.6-rc0~21^2~8,
2009-10-09) and it was not obvious it deserved to be a named feature.
But now that is clear, since all major non-git fast-import backends
lack support for it.

Details: on git version with this patch applied, any "feature notes"
command in the features/options section at the beginning of a stream
will be treated as a no-op.  On fast-import implementations without
the feature (and older git versions), the command instead errors out
with a message like

This version of fast-import does not support feature notes.

So by declaring use of notes at the beginning of a stream, frontends
can avoid wasting time and other resources when the backend does not
support notes.  (This would be especially important for backends that
do not support rewinding history after a botched import.)

Improved-by: Thomas Rast <trast@student.ethz.ch>
Improved-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agofast-import: clarify documentation of "feature" command
Jonathan Nieder [Sun, 28 Nov 2010 19:43:57 +0000 (13:43 -0600)]
fast-import: clarify documentation of "feature" command

The "feature" command allows streams to specify options for the import
that must not be ignored.  Logically, they are part of the stream,
even though technically most supported features are synonyms to
command-line options.

Make this more obvious by being more explicit about how the analogy
between most "feature" commands and command-line options works.  Treat
the feature (import-marks) that does not fit this analogy separately.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoDocumentation/merge subtree How-To: fix typo
Uwe Kleine-König [Wed, 9 Feb 2011 09:04:43 +0000 (10:04 +0100)]
Documentation/merge subtree How-To: fix typo

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agopull: Document the "--[no-]recurse-submodules" options
Jens Lehmann [Mon, 7 Feb 2011 22:24:54 +0000 (23:24 +0100)]
pull: Document the "--[no-]recurse-submodules" options

In commits be254a0ea9 and 7dce19d374 the handling of the new fetch options
"--[no-]recurse-submodules" had been added to git-pull.sh. But they were
not documented as the pull options they now are, so let's fix that.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agoquote.h: simplify the inclusion
Jonathan Nieder [Wed, 5 Jan 2011 00:36:34 +0000 (18:36 -0600)]
quote.h: simplify the inclusion

Attempting to include quote.h without first including strbuf.h results
in warnings:

 ./quote.h:33:33: warning: ‘struct strbuf’ declared inside parameter list
 ./quote.h:33:33: warning: its scope is only this definition or declaration, which is probably not what you want
 ./quote.h:34:34: warning: ‘struct strbuf’ declared inside parameter list
 ...

Add a toplevel declaration for struct strbuf to avoid this.

While at it, stop including system headers from quote.h.  git source
files already need to include git-compat-util.h sooner to ensure the
appropriate feature test macros are defined.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 years agosha1_object_info: examine cached_object store too
Nguyễn Thái Ngọc Duy [Sat, 5 Feb 2011 14:03:02 +0000 (21:03 +0700)]
sha1_object_info: examine cached_object store too

Cached object store was added in d66b37b (Add pretend_sha1_file()
interface. - 2007-02-04) as a way to temporarily inject some objects
to object store.

But only read_sha1_file() knows about this store. While it will return
an object from this store, sha1_object_info() will happily say
"object not found".

Teach sha1_object_info() about the cached store for consistency.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>