Code

git.git
16 years agoMerge branch 'jb/remote-rm'
Junio C Hamano [Sat, 29 Sep 2007 23:43:06 +0000 (16:43 -0700)]
Merge branch 'jb/remote-rm'

* jb/remote-rm:
  git-remote rm: add tests and minor fix-ups
  remote: document the 'rm' subcommand
  remote: add 'rm' subcommand

16 years agoMerge branch 'jk/diff-rename'
Junio C Hamano [Sat, 29 Sep 2007 23:42:50 +0000 (16:42 -0700)]
Merge branch 'jk/diff-rename'

* jk/diff-rename:
  diffcore-rename: cache file deltas

16 years agoSync with GIT 1.5.3.3
Junio C Hamano [Sat, 29 Sep 2007 23:31:40 +0000 (16:31 -0700)]
Sync with GIT 1.5.3.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoGIT 1.5.3.3 v1.5.3.3
Junio C Hamano [Sat, 29 Sep 2007 23:07:46 +0000 (16:07 -0700)]
GIT 1.5.3.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFix revision log diff setup, avoid unnecessary diff generation
Linus Torvalds [Sat, 29 Sep 2007 16:50:39 +0000 (09:50 -0700)]
Fix revision log diff setup, avoid unnecessary diff generation

We used to incorrectly start calculating diffs whenever any argument but
'-z' was recognized by the diff options parsing. That was bogus, since not
all arguments result in diffs being needed, so we just waste a lot of time
and effort on calculating diffs that don't matter.

This actually also fixes another bug in "git log". Try this:

git log -C

and notice how it prints an extra empty line in between log entries, even
though it never prints the actual diff (because we didn't ask for any diff
format, so the diff machinery never prints anything).

With this patch, that bogus empty line is gone, because "revs->diff" is
never set.  So this isn't just a "wasted time and effort" issue, it's also
a slight semantic fix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-bundle: fix commandline examples in the manpage
Miklos Vajna [Wed, 26 Sep 2007 23:34:59 +0000 (01:34 +0200)]
git-bundle: fix commandline examples in the manpage

Multiple commands were displayed in one line, making the manpage hard to read.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'mergetool' of git://repo.or.cz/git/mergetool into maint
Junio C Hamano [Sat, 29 Sep 2007 22:39:39 +0000 (15:39 -0700)]
Merge branch 'mergetool' of git://repo.or.cz/git/mergetool into maint

* 'mergetool' of git://repo.or.cz/git/mergetool:
  mergetool: Fix typo in options passed to kdiff3
  mergetool: fix emerge when running in a subdirectory
  Mergetool generating blank files (1.5.3)

16 years agostrbuf change: be sure ->buf is never ever NULL.
Pierre Habouzit [Thu, 27 Sep 2007 10:58:23 +0000 (12:58 +0200)]
strbuf change: be sure ->buf is never ever NULL.

For that purpose, the ->buf is always initialized with a char * buf living
in the strbuf module. It is made a char * so that we can sloppily accept
things that perform: sb->buf[0] = '\0', and because you can't pass "" as an
initializer for ->buf without making gcc unhappy for very good reasons.

strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf
anymore.

as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
->buf isn't an option anymore, if ->buf is going to escape from the scope,
and eventually be free'd.

API changes:
  * strbuf_setlen now always works, so just make strbuf_reset a convenience
    macro.
  * strbuf_detatch takes a size_t* optional argument (meaning it can be
    NULL) to copy the buffer's len, as it was needed for this refactor to
    make the code more readable, and working like the callers.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agodouble free in builtin-update-index.c
Pierre Habouzit [Thu, 27 Sep 2007 10:51:18 +0000 (12:51 +0200)]
double free in builtin-update-index.c

path_name is either ptr that should not be freed, or a pointer to a strbuf
buffer that is deallocated when exiting the loop. Don't do that !

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agomergetool: Fix typo in options passed to kdiff3
Theodore Ts'o [Sat, 29 Sep 2007 02:26:05 +0000 (22:26 -0400)]
mergetool: Fix typo in options passed to kdiff3

Fix missing double hyphens in "-L1" and "-L2"

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
16 years agomergetool: fix emerge when running in a subdirectory
Theodore Ts'o [Sat, 29 Sep 2007 01:23:22 +0000 (21:23 -0400)]
mergetool: fix emerge when running in a subdirectory

Only pass the basename of the output filename when to emerge, since
emerge interprets non-absolute pathnames relative to the containing
directory of the output buffer.

Thanks to Kelvie Wong for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
16 years agoMergetool generating blank files (1.5.3)
Junio C Hamano [Thu, 27 Sep 2007 21:41:23 +0000 (14:41 -0700)]
Mergetool generating blank files (1.5.3)

When mergetool is run from a subdirectory, "ls-files -u" nicely
limits the output to conflicted files in that directory, but
we need to give the full path to cat-file plumbing to grab the
contents of stages.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
16 years agoquiltimport: Skip non-existent patches
Dan Nicholson [Thu, 27 Sep 2007 20:30:59 +0000 (13:30 -0700)]
quiltimport: Skip non-existent patches

When quiltimport encounters a non-existent patch in the series file,
just skip to the next patch. This matches the behavior of quilt.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoClean up stripspace a bit, use strbuf even more.
Kristian Høgsberg [Tue, 18 Sep 2007 00:06:45 +0000 (20:06 -0400)]
Clean up stripspace a bit, use strbuf even more.

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAdd strbuf_read_file().
Kristian Høgsberg [Tue, 18 Sep 2007 00:06:46 +0000 (20:06 -0400)]
Add strbuf_read_file().

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorerere: Fix use of an empty strbuf.buf
Junio C Hamano [Thu, 27 Sep 2007 06:34:01 +0000 (23:34 -0700)]
rerere: Fix use of an empty strbuf.buf

The code incorrectly assumed that strbuf.buf is always an
allocated piece of memory that has NUL at offset strbuf.len.
That assumption does not hold for a freshly initialized empty
strbuf.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoapply: get rid of --index-info in favor of --build-fake-ancestor
Johannes Schindelin [Mon, 17 Sep 2007 22:34:06 +0000 (23:34 +0100)]
apply: get rid of --index-info in favor of --build-fake-ancestor

git-am used "git apply -z --index-info" to find the original versions
of the files touched by the diff, to be able to do an inexpensive
three-way merge.

This operation makes only sense in a repository, since the index
information in the diff refers to blobs, which have to be present in
the current repository.

Therefore, teach "git apply" a mode to write out the result as an
index file to begin with, obviating the need for scripts to do it
themselves.

The sole user for --index-info is "git am" is converted to
use --build-fake-ancestor in this patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMove make_cache_entry() from merge-recursive.c into read-cache.c
Carlos Rica [Tue, 11 Sep 2007 03:17:28 +0000 (05:17 +0200)]
Move make_cache_entry() from merge-recursive.c into read-cache.c

The function make_cache_entry() is too useful to be hidden away in
merge-recursive.  So move it to libgit.a (exposing it via cache.h).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agosend-email --smtp-server-port: allow overriding the default port
Junio C Hamano [Wed, 26 Sep 2007 00:27:54 +0000 (17:27 -0700)]
send-email --smtp-server-port: allow overriding the default port

You can use --smtp-server-port option to specify a port
different from the default (typically, SMTP servers listen
to smtp port 25 and ssmtp port 465).

Users should be aware that sending auth info over non-ssl
connections may be unsafe or just may not work at all
depending on SMTP server config.

Signed-off-by: Glenn Rempe <glenn@rempe.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoSmall cache_tree_write refactor.
Pierre Habouzit [Tue, 25 Sep 2007 08:22:44 +0000 (10:22 +0200)]
Small cache_tree_write refactor.

This function cannot fail, make it void. Also make write_one act on a
const char* instead of a char*.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMake builtin-rerere use of strbuf nicer and more efficient.
Pierre Habouzit [Mon, 24 Sep 2007 09:25:04 +0000 (11:25 +0200)]
Make builtin-rerere use of strbuf nicer and more efficient.

memory is now reused across hunks.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAdd strbuf_cmp.
Pierre Habouzit [Mon, 24 Sep 2007 09:25:03 +0000 (11:25 +0200)]
Add strbuf_cmp.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agostrbuf_setlen(): do not barf on setting length of an empty buffer to 0
Junio C Hamano [Wed, 26 Sep 2007 09:26:06 +0000 (02:26 -0700)]
strbuf_setlen(): do not barf on setting length of an empty buffer to 0

strbuf_setlen() expect to be able to NUL terminate the buffer,
but a completely empty strbuf could have an empty buffer with 0
allocation; both the assert() and the assignment for NUL
termination would fail.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: work on a detached HEAD
Johannes Schindelin [Tue, 25 Sep 2007 15:43:15 +0000 (16:43 +0100)]
rebase -i: work on a detached HEAD

Earlier, rebase -i refused to rebase a detached HEAD.  Now it no longer
does.

Incidentally, this fixes "git gc --auto" shadowing the true exit status.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'jc/autogc' into js/rebase-i
Junio C Hamano [Wed, 26 Sep 2007 07:42:12 +0000 (00:42 -0700)]
Merge branch 'jc/autogc' into js/rebase-i

* jc/autogc:
  git-gc --auto: run "repack -A -d -l" as necessary.
  git-gc --auto: restructure the way "repack" command line is built.
  git-gc --auto: protect ourselves from accumulated cruft
  git-gc --auto: add documentation.
  git-gc --auto: move threshold check to need_to_gc() function.
  repack -A -d: use --keep-unreachable when repacking
  pack-objects --keep-unreachable
  Export matches_pack_name() and fix its return value
  Invoke "git gc --auto" from commit, merge, am and rebase.
  Implement git gc --auto

Conflicts:

builtin-pack-objects.c

16 years agoDon't use "<unknown>" for placeholders and suppress printing of empty user formats.
Michal Vitecek [Tue, 25 Sep 2007 14:38:46 +0000 (16:38 +0200)]
Don't use "<unknown>" for placeholders and suppress printing of empty user formats.

This changes the interporate() to replace entries with NULL values
by the empty string, and uses it to interpolate missing fields in
custom format output used in git-log and friends.  It is most useful
to avoid <unknown> output from %b format for a commit log message
that lack any body text.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agodiffcore-rename: cache file deltas
Jeff King [Tue, 25 Sep 2007 19:29:42 +0000 (15:29 -0400)]
diffcore-rename: cache file deltas

We find rename candidates by computing a fingerprint hash of
each file, and then comparing those fingerprints. There are
inherently O(n^2) comparisons, so it pays in CPU time to
hoist the (rather expensive) computation of the fingerprint
out of that loop (or to cache it once we have computed it once).

Previously, we didn't keep the filespec information around
because then we had the potential to consume a great deal of
memory. However, instead of keeping all of the filespec
data, we can instead just keep the fingerprint.

This patch implements and uses diff_free_filespec_data_large
to accomplish that goal. We also have to change
estimate_similarity not to needlessly repopulate the
filespec data when we already have the hash.

Practical tests showed 4.5x speedup for a 10% memory usage
increase.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: create .dotest-merge after validating options.
Matt Kraai [Wed, 26 Sep 2007 01:30:13 +0000 (18:30 -0700)]
rebase -i: create .dotest-merge after validating options.

Creating .dotest-merge before validating the options prevents both
--continue and --interactive from working if the options are invalid,
so only create it after validating the options.

[jc: however, just moving the creation of DOTEST breaks output]

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agocore-tutorial: correct URL
Randy Dunlap [Wed, 26 Sep 2007 05:02:28 +0000 (22:02 -0700)]
core-tutorial: correct URL

The tinyurl is incorrect -- it attempts to go to groups.osdl.org,
which is gone.  Either use the full URL (in patch) or create a new
tinyurl for this URL.

Is the web page (where I first saw this problem) generated from
this txt file?
http://www.kernel.org/pub/software/scm/git/docs/core-tutorial.html
If not, it needs to be updated also.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFix spelling of overridden in documentation
Shawn Bohrer [Wed, 26 Sep 2007 04:12:46 +0000 (23:12 -0500)]
Fix spelling of overridden in documentation

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: avoid exporting GIT_AUTHOR_* variables
Johannes Schindelin [Tue, 25 Sep 2007 15:43:44 +0000 (16:43 +0100)]
rebase -i: avoid exporting GIT_AUTHOR_* variables

It is somewhat unsafe to export the GIT_AUTHOR_* variables, since a later
call to git-commit or git-merge could pick them up inadvertently.

So avoid the export, using a recipe provided by Johannes Sixt.

Incidentally, this fixes authorship of merges with "rebase --preserve -i".

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: Fix numbers in progress report
Johannes Schindelin [Tue, 25 Sep 2007 15:43:04 +0000 (16:43 +0100)]
rebase -i: Fix numbers in progress report

Instead of counting all lines in done and todo, we now count the actions
before outputting "$Rebasing ($count/$total)".

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: style fixes and minor cleanups
Johannes Schindelin [Tue, 25 Sep 2007 15:42:51 +0000 (16:42 +0100)]
rebase -i: style fixes and minor cleanups

This patch indents ";;" consistently with the rest of git's shell scripts,
and makes sure that ";;" are before each "esac".

It introduces a helper function "has_action", to make it easier to read
the intentions of the code.

Errors from "git rev-parse --verify" are no longer ignored.

Spaces are quoted using single quotes instead of a backslash, for
readability.

A "test $preserve=f" (missing spaces) was fixed; hashes are no longer
written to "$DOTEST"/rewritten/ unnecessarily.

We used to quote the message for a squash, only to have "echo" unquote it.
Now we use "printf" and do not need to quote to start with.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agorebase -i: commit when continuing after "edit"
Johannes Schindelin [Tue, 25 Sep 2007 15:42:36 +0000 (16:42 +0100)]
rebase -i: commit when continuing after "edit"

When doing an "edit" on a commit, editing and git-adding some files,
"git rebase -i" complained about a missing "author-script".  The idea was
that the user would call "git commit --amend" herself.

But we can be nice and do that for the user.

Noticed by Dmitry Potapov.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogitattributes.txt: Be more to the point in the filter driver description.
Johannes Sixt [Tue, 25 Sep 2007 13:05:29 +0000 (15:05 +0200)]
gitattributes.txt: Be more to the point in the filter driver description.

The description was meant to emphasizes that the project should remain
usable even if the filter driver was not used. This makes it more explicit
and removes the "here is rope to hang yourself" paraphrase.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogitattributes.txt: Remove a duplicated paragraph about 'ident' and 'crlf' interaction.
Johannes Sixt [Tue, 25 Sep 2007 13:05:28 +0000 (15:05 +0200)]
gitattributes.txt: Remove a duplicated paragraph about 'ident' and 'crlf' interaction.

The order in which 'ident' and 'crlf' are carried out is documented a few paragraphs
later again, after 'filter' was introduced.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMake merge-recursive honor diff.renamelimit
Lars Hjemli [Tue, 25 Sep 2007 06:36:38 +0000 (08:36 +0200)]
Make merge-recursive honor diff.renamelimit

It might be a sign of source code management gone bad, but when two branches
has diverged almost beyond recognition and time has come for the branches to
merge, the user is going to need all the help his tool can give him. Honoring
diff.renamelimit has great potential as a painkiller in such situations.

The painkiller effect could have been achieved by e.g. 'merge.renamelimit',
but the flexibility gained by a separate option is questionable: our user
would probably expect git to detect renames equally good when merging as
when diffing (I known I did).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMove convert-objects to contrib.
Matt Kraai [Tue, 25 Sep 2007 14:03:46 +0000 (07:03 -0700)]
Move convert-objects to contrib.

convert-objects was needed to convert from an old-style repository,
which hashed the compressed contents and used a different date format.
Such repositories are presumably no longer common and, if such
conversions are necessary, should be done by writing a frontend for
git-fast-import.

Linus, the original author, is OK with moving it to contrib.

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agouser-manual: Explain what submodules are good for.
Michael Smith [Tue, 25 Sep 2007 12:44:38 +0000 (08:44 -0400)]
user-manual: Explain what submodules are good for.

Rework the introduction to the Submodules section to explain why
someone would use them, and fix up submodule references from the
tree-object and todo sections.

Signed-off-by: Michael Smith <msmith@cbnco.com>
Acked-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'jn/web' into maint
Junio C Hamano [Tue, 25 Sep 2007 22:17:22 +0000 (15:17 -0700)]
Merge branch 'jn/web' into maint

* jn/web:
  gitweb: No difftree output for trivial merge
  gitweb: Remove parse_from_to_diffinfo code from git_patchset_body

16 years agogit-submodule - allow a relative path as the subproject url
Mark Levedahl [Mon, 24 Sep 2007 02:19:42 +0000 (22:19 -0400)]
git-submodule - allow a relative path as the subproject url

This allows a subproject's location to be specified and stored as relative
to the parent project's location (e.g., ./foo, or ../foo). This url is
stored in .gitmodules as given. It is resolved into an absolute url by
appending it to the parent project's url when the information is written
to .git/config (i.e., during submodule add for the originator, and
submodule init for a downstream recipient). This allows cloning of the
project to work "as expected" if the project is hosted on a different
server than when the subprojects were added.

Signed-off-by: Mark Levedahl <mdl123@verizon.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'maint'
Junio C Hamano [Tue, 25 Sep 2007 07:30:33 +0000 (00:30 -0700)]
Merge branch 'maint'

* maint:
  Do not over-quote the -f envelopesender value.
  unexpected Make output (e.g. from --debug) causes build failure
  Fixed minor typo in t/t9001-send-email.sh test command line.

16 years agoDo not over-quote the -f envelopesender value.
Jim Meyering [Tue, 25 Sep 2007 06:48:59 +0000 (08:48 +0200)]
Do not over-quote the -f envelopesender value.

Without this, the value passed to sendmail would have an extra set of
single quotes.  At least exim's sendmail emulation would object to that:

    exim: bad -f address "'list-addr@example.org'": malformed address: ' \
      may not follow 'list-addr@example.org
    error: hooks/post-receive exited with error code 1

Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agounexpected Make output (e.g. from --debug) causes build failure
Jim Meyering [Tue, 25 Sep 2007 06:42:16 +0000 (08:42 +0200)]
unexpected Make output (e.g. from --debug) causes build failure

Without this, the extra output produced e.g., by "make --debug"
would go into $INSTLIBDIR and then cause the sed command to fail.

Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoPrevent send-pack from segfaulting when a branch doesn't match
Shawn O. Pearce [Tue, 25 Sep 2007 04:13:25 +0000 (00:13 -0400)]
Prevent send-pack from segfaulting when a branch doesn't match

If `git push url foo` can't find a local branch named foo we can't
match it to any remote branch as the local branch is NULL and its
name is probably at position 0x34 in memory.  On most systems that
isn't a valid address for git-send-pack's virtual address space
and we segfault.

If we can't find a source match and we have no destination we
need to abort the match function early before we try to match the
destination against the remote.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoCleanup unnecessary break in remote.c
Shawn O. Pearce [Tue, 25 Sep 2007 04:13:19 +0000 (00:13 -0400)]
Cleanup unnecessary break in remote.c

This simple change makes the body of "case 0" easier to read; no
matter what the value of matched_src is we want to break out of
the switch and not fall through.  We only want to display an error
if matched_src is NULL, as this indicates there is no local branch
matching the input.

Also modified the default case's error message so it uses one less
line of text.  Even at 8 column per tab indentation we still don't
break 80 columns with this new formatting.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoCleanup style nit of 'x == NULL' in remote.c
Shawn O. Pearce [Tue, 25 Sep 2007 04:13:14 +0000 (00:13 -0400)]
Cleanup style nit of 'x == NULL' in remote.c

Git style tends to prefer "!x" over "x == NULL".  Make it so in
these handful of locations that were not following along.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFixed minor typo in t/t9001-send-email.sh test command line.
Glenn Rempe [Mon, 24 Sep 2007 20:33:38 +0000 (13:33 -0700)]
Fixed minor typo in t/t9001-send-email.sh test command line.

The git-send-email command line in the test was missing a single hyphen.

Signed-off-by: Glenn Rempe <glenn@rempe.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFix pool handling in git-svnimport to avoid memory leaks.
Stefan Sperling [Mon, 24 Sep 2007 10:57:40 +0000 (12:57 +0200)]
Fix pool handling in git-svnimport to avoid memory leaks.

- Create an explicit one-and-only root pool.
- Closely follow examples in SVN::Core man page.
  Before calling a subversion function, create a subpool of our
  root pool and make it the new default pool.
- Create a subpool for looping over svn revisions and clear
  this subpool (i.e. it mark for reuse, don't decallocate it)
  at the start of the loop instead of allocating new memory
  with each iteration.

See http://marc.info/?l=git&m=118554191513822&w=2 for a detailed
explanation of the issue.

Signed-off-by: Stefan Sperling <stsp@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoStart RelNotes for 1.5.4
Junio C Hamano [Mon, 24 Sep 2007 08:12:16 +0000 (01:12 -0700)]
Start RelNotes for 1.5.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'jn/web'
Junio C Hamano [Mon, 24 Sep 2007 06:13:08 +0000 (23:13 -0700)]
Merge branch 'jn/web'

* jn/web:
  gitweb: No difftree output for trivial merge
  gitweb: Remove parse_from_to_diffinfo code from git_patchset_body

16 years agogitweb: No difftree output for trivial merge
Jakub Narebski [Sat, 8 Sep 2007 19:54:28 +0000 (21:54 +0200)]
gitweb: No difftree output for trivial merge

In 'commitdiff' view, for the merge commit, there is an extra header
for the difftree table, with links to commitdiffs to individual
parents.  Do not show such header when there is nothing to show, for
trivial merges.

This means that for trivial merge you have to go to 'commit' view
to get links to diffs to each parent.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
16 years agogitweb: Remove parse_from_to_diffinfo code from git_patchset_body
Jakub Narebski [Sat, 8 Sep 2007 19:49:11 +0000 (21:49 +0200)]
gitweb: Remove parse_from_to_diffinfo code from git_patchset_body

In commit 90921740bd00029708370673fdc537522aa48e6f
  "gitweb: Split git_patchset_body into separate subroutines"
a part of git_patchset_body code was separated into parse_from_to_diffinfo
subroutine.  But instead of replacing the separated code by the call to
mentioned subroutine, the call to subroutine was placed before the separated
code.  This patch removes parse_from_to_diffinfo code from git_patchset_body
subroutine.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
16 years agoMerge branch 'je/hooks'
Junio C Hamano [Mon, 24 Sep 2007 05:51:03 +0000 (22:51 -0700)]
Merge branch 'je/hooks'

* je/hooks:
  Added example hook script to save/restore permissions/ownership.
  Add post-merge hook, related documentation, and tests.

16 years agogit-remote rm: add tests and minor fix-ups
Junio C Hamano [Mon, 24 Sep 2007 05:29:12 +0000 (22:29 -0700)]
git-remote rm: add tests and minor fix-ups

This fixes "git remote rm" which always exited with a failure,
corrects indentation, and adds tests.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'js/apply-build-ancestor'
Junio C Hamano [Mon, 24 Sep 2007 04:16:33 +0000 (21:16 -0700)]
Merge branch 'js/apply-build-ancestor'

* js/apply-build-ancestor:
  apply: get rid of --index-info in favor of --build-fake-ancestor

16 years agogit-merge: add --ff and --no-ff options
Lars Hjemli [Sun, 23 Sep 2007 22:51:45 +0000 (00:51 +0200)]
git-merge: add --ff and --no-ff options

These new options can be used to control the policy for fast-forward
merges: --ff allows it (this is the default) while --no-ff will create
a merge commit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-merge: add support for --commit and --no-squash
Lars Hjemli [Sun, 23 Sep 2007 22:51:44 +0000 (00:51 +0200)]
git-merge: add support for --commit and --no-squash

These options can be used to override --no-commit and --squash, which is
needed since --no-commit and --squash now can be specified as default merge
options in $GIT_DIR/config.

The change also introduces slightly different behavior for --no-commit:
when specified, it explicitly overrides --squash. Earlier,
'git merge --squash --no-commit' would result in a squashed merge (i.e. no
$GIT_DIR/MERGE_HEAD was created) but with this patch the command will
behave as if --squash hadn't been specified.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-merge: add support for branch.<name>.mergeoptions
Lars Hjemli [Sun, 23 Sep 2007 22:51:43 +0000 (00:51 +0200)]
git-merge: add support for branch.<name>.mergeoptions

This enables per branch configuration of merge options. Currently, the most
useful options to specify per branch are --squash, --summary/--no-summary
and possibly --strategy, but all options are supported.

Note: Options containing whitespace will _not_ be handled correctly. Luckily,
the only option which can include whitespace is --message and it doesn't
make much sense to give that option a default value.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-merge: refactor option parsing
Lars Hjemli [Sun, 23 Sep 2007 22:51:42 +0000 (00:51 +0200)]
git-merge: refactor option parsing

Move the option parsing into a separate function as preparation for reuse
by the next commit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-merge: fix faulty SQUASH_MSG
Lars Hjemli [Sun, 23 Sep 2007 22:51:41 +0000 (00:51 +0200)]
git-merge: fix faulty SQUASH_MSG

Only the first 'remote' head is currently specified as an argument to 'git
log' when generating a SQUSH_MSG, which makes the generated message fail
to mention every commit involved in the merge. This fixes the problem.

Noticed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAdd test-script for git-merge porcelain
Lars Hjemli [Sun, 23 Sep 2007 22:51:40 +0000 (00:51 +0200)]
Add test-script for git-merge porcelain

This test-script excercises the porcelainish aspects of git-merge, and
does it thoroughly enough to detect a small bug already noticed by Junio:
squashing an octopus generates a faulty .git/SQUASH_MSG.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMerge branch 'maint'
Junio C Hamano [Mon, 24 Sep 2007 00:13:55 +0000 (17:13 -0700)]
Merge branch 'maint'

* maint:
  git-svn: don't attempt to spawn pager if we don't want one
  Supplant the "while case ... break ;; esac" idiom
  User Manual: add a chapter for submodules
  user-manual: don't assume refs are stored under .git/refs
  Detect exec bit in more cases.
  Conjugate "search" correctly in the git-prune-packed man page.
  Move the paragraph specifying where the .idx and .pack files should be
  Documentation/git-lost-found.txt: drop unnecessarily duplicated name.

16 years agoMerge branch 'maint' of git://linux-nfs.org/~bfields/git into maint
Junio C Hamano [Mon, 24 Sep 2007 00:08:45 +0000 (17:08 -0700)]
Merge branch 'maint' of git://linux-nfs.org/~bfields/git into maint

* 'maint' of git://linux-nfs.org/~bfields/git:
  User Manual: add a chapter for submodules
  user-manual: don't assume refs are stored under .git/refs

16 years agogit-svn: don't attempt to spawn pager if we don't want one
Eric Wong [Sat, 22 Sep 2007 01:48:45 +0000 (18:48 -0700)]
git-svn: don't attempt to spawn pager if we don't want one

Even though config_pager() unset the $pager variable, we were
blindly calling exec() on it through run_pager().

Noticed-by: Chris Moore <christopher.ian.moore@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoSupplant the "while case ... break ;; esac" idiom
David Kastrup [Sun, 23 Sep 2007 20:42:08 +0000 (22:42 +0200)]
Supplant the "while case ... break ;; esac" idiom

A lot of shell scripts contained stuff starting with

while case "$#" in 0) break ;; esac

and similar.  I consider breaking out of the condition instead of the
body od the loop ugly, and the implied "true" value of the
non-matching case is not really obvious to humans at first glance.  It
happens not to be obvious to some BSD shells, either, but that's
because they are not POSIX-compliant.  In most cases, this has been
replaced by a straight condition using "test".  "case" has the
advantage of being faster than "test" on vintage shells where "test"
is not a builtin.  Since none of them is likely to run the git
scripts, anyway, the added readability should be worth the change.

A few loops have had their termination condition expressed
differently.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoUser Manual: add a chapter for submodules
Miklos Vajna [Thu, 20 Sep 2007 00:34:14 +0000 (02:34 +0200)]
User Manual: add a chapter for submodules

Signed-off-by: Michael Smith <msmith@cbnco.com>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
16 years agouser-manual: don't assume refs are stored under .git/refs
J. Bruce Fields [Mon, 10 Sep 2007 02:07:02 +0000 (22:07 -0400)]
user-manual: don't assume refs are stored under .git/refs

The scripts taken from Tony Luck's howto assume all refs can be found
under .git/refs, but this is not necessarily true, especially since
git-gc runs git-pack-refs.

Also add a note warning of this in the chapter that introduces refs, and
fix the same incorrect assumption in one other spot.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
16 years agoDetect exec bit in more cases.
David Brown [Wed, 19 Sep 2007 20:12:48 +0000 (13:12 -0700)]
Detect exec bit in more cases.

git-p4 was missing the execute bit setting if the file had other attribute
bits set.

Acked-By: Simon Hausmann <simon@lst.de>
16 years agoConjugate "search" correctly in the git-prune-packed man page.
Matt Kraai [Fri, 21 Sep 2007 14:37:18 +0000 (07:37 -0700)]
Conjugate "search" correctly in the git-prune-packed man page.

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoMove the paragraph specifying where the .idx and .pack files should be
Matt Kraai [Fri, 21 Sep 2007 13:43:44 +0000 (06:43 -0700)]
Move the paragraph specifying where the .idx and .pack files should be

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoDocumentation/git-lost-found.txt: drop unnecessarily duplicated name.
Junio C Hamano [Fri, 21 Sep 2007 19:52:30 +0000 (12:52 -0700)]
Documentation/git-lost-found.txt: drop unnecessarily duplicated name.

I only did this back when I wanted to make sure git-log and gitk work
properly with non Occidental characters.  There is really no reason to
keep it around.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agosq_quote_argv and add_to_string rework with strbuf's.
Pierre Habouzit [Wed, 19 Sep 2007 22:42:13 +0000 (00:42 +0200)]
sq_quote_argv and add_to_string rework with strbuf's.

* sq_quote_buf is made public, and works on a strbuf.
* sq_quote_argv also works on a strbuf.
* make sq_quote_argv take a "maxlen" argument to check the buffer won't grow
  too big.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-svn: handle changed svn command-line syntax
Sam Vilain [Fri, 21 Sep 2007 03:27:01 +0000 (15:27 +1200)]
git-svn: handle changed svn command-line syntax

Previously, if you passed a revision and a path to svn cp, it meant to look
back at that revision and select that path.  New behaviour is to get the
path then go back to the revision (like other commands that accept @REV
or -rREV do).  The more consistent syntax is not supported by the old
tools, so we have to try both in turn.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-svn: fix test for trunk svn (transaction out of date)
Sam Vilain [Fri, 21 Sep 2007 02:02:34 +0000 (14:02 +1200)]
git-svn: fix test for trunk svn (transaction out of date)

Older svn clients did not raise a 'transaction out of date' error here, but
trunk does - so 'svn up'.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agogit-svn: fix test for trunk svn (commit message not needed)
Sam Vilain [Fri, 21 Sep 2007 02:02:33 +0000 (14:02 +1200)]
git-svn: fix test for trunk svn (commit message not needed)

The 'svn mv -m "rename to thunk"' was a local operation, therefore not
needing a commit message, it was silently ignored.  Newer svn clients will
instead raise an error.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFull rework of quote_c_style and write_name_quoted.
Pierre Habouzit [Wed, 19 Sep 2007 22:42:15 +0000 (00:42 +0200)]
Full rework of quote_c_style and write_name_quoted.

* quote_c_style works on a strbuf instead of a wild buffer.
* quote_c_style is now clever enough to not add double quotes if not needed.

* write_name_quoted inherits those advantages, but also take a different
  set of arguments. Now instead of asking for quotes or not, you pass a
  "terminator". If it's \0 then we assume you don't want to escape, else C
  escaping is performed. In any case, the terminator is also appended to the
  stream. It also no longer takes the prefix/prefix_len arguments, as it's
  seldomly used, and makes some optimizations harder.

* write_name_quotedpfx is created to work like write_name_quoted and take
  the prefix/prefix_len arguments.

Thanks to those API changes, diff.c has somehow lost weight, thanks to the
removal of functions that were wrappers around the old write_name_quoted
trying to give it a semantics like the new one, but performing a lot of
allocations for this goal. Now we always write directly to the stream, no
intermediate allocation is performed.

As a side effect of the refactor in builtin-apply.c, the length of the bar
graphs in diffstats are not affected anymore by the fact that the path was
clipped.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
16 years agoRework unquote_c_style to work on a strbuf.
Pierre Habouzit [Wed, 19 Sep 2007 22:42:14 +0000 (00:42 +0200)]
Rework unquote_c_style to work on a strbuf.

If the gain is not obvious in the diffstat, the resulting code is more
readable, _and_ in checkout-index/update-index we now reuse the same buffer
to unquote strings instead of always freeing/mallocing.

This also is more coherent with the next patch that reworks quoting
functions.

The quoting function is also made more efficient scanning for backslashes
and treating portions of strings without a backslash at once.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
16 years agostrbuf API additions and enhancements.
Pierre Habouzit [Wed, 19 Sep 2007 22:42:12 +0000 (00:42 +0200)]
strbuf API additions and enhancements.

Add strbuf_remove, change strbuf_insert:
  As both are special cases of strbuf_splice, implement them as such.
  gcc is able to do the math and generate almost optimal code this way.

Add strbuf_swap:
  Exchange the values of its arguments.
  Use it in fast-import.c

Also fix spacing issues in strbuf.h

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
16 years agonfv?asprintf are broken without va_copy, workaround them.
Pierre Habouzit [Thu, 20 Sep 2007 08:43:11 +0000 (10:43 +0200)]
nfv?asprintf are broken without va_copy, workaround them.

* drop nfasprintf.
* move nfvasprintf into imap-send.c back, and let it work on a 8k buffer,
  and die() in case of overflow. It should be enough for imap commands, if
  someone cares about imap-send, he's welcomed to fix it properly.
* replace nfvasprintf use in merge-recursive with a copy of the strbuf_addf
  logic, it's one place, we'll live with it.
  To ease the change, output_buffer string list is replaced with a strbuf ;)
* rework trace.c to call vsnprintf itself.  It's used to format strerror()s
  and git command names, it should never be more than a few octets long, let
  it work on a 8k static buffer with vsnprintf or die loudly.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
16 years agoFix the expansion pattern of the pseudo-static path buffer.
Pierre Habouzit [Wed, 19 Sep 2007 22:42:10 +0000 (00:42 +0200)]
Fix the expansion pattern of the pseudo-static path buffer.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
16 years agorev-list --bisect: Fix best == NULL case.
Christian Couder [Thu, 20 Sep 2007 05:23:01 +0000 (07:23 +0200)]
rev-list --bisect: Fix best == NULL case.

Earlier commit ce0cbad77 broke rev-list --bisect to cause it
segfault when the resulting set is empty.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoFix memory leaks when disconnecting transport instances
Shawn O. Pearce [Wed, 19 Sep 2007 04:49:42 +0000 (00:49 -0400)]
Fix memory leaks when disconnecting transport instances

Most transport implementations tend to allocate a data buffer
in the struct transport instance during transport_get() so we
need to free that data buffer when we disconnect it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoEnsure builtin-fetch honors {fetch,transfer}.unpackLimit
Shawn O. Pearce [Wed, 19 Sep 2007 04:49:39 +0000 (00:49 -0400)]
Ensure builtin-fetch honors {fetch,transfer}.unpackLimit

The only way to configure the unpacking limit is currently through
the .git/config (or ~/.gitconfig) mechanism as we have no existing
command line option interface to control this threshold on a per
invocation basis.  This was intentional by design as the storage
policy of the repository should be a repository-wide decision and
should not be subject to variations made on individual command
executions.

Earlier builtin-fetch was bypassing the unpacking limit chosen by
the user through the configuration file as it did not reread the
configuration options through fetch_pack_config if we called the
internal fetch_pack() API directly.  We now ensure we always run the
config file through fetch_pack_config at least once in this process,
thereby setting our unpackLimit properly.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAlways obtain fetch-pack arguments from struct fetch_pack_args
Shawn O. Pearce [Wed, 19 Sep 2007 04:49:35 +0000 (00:49 -0400)]
Always obtain fetch-pack arguments from struct fetch_pack_args

Copying the arguments from a fetch_pack_args into static globals
within the builtin-fetch-pack module is error-prone and may lead
rise to cases where arguments supplied via the struct from the
new fetch_pack() API may not be honored by the implementation.

Here we reorganize all of the static globals into a single static
struct fetch_pack_args instance and use memcpy() to move the data
from the caller supplied structure into the globals before we
execute our pack fetching implementation.  This strategy is more
robust to additions and deletions of properties.

As keep_pack is a single bit we have also introduced lock_pack to
mean not only download and store the packfile via index-pack but
also to lock it against repacking by creating a .keep file when
the packfile itself is stored.  The caller must remove the .keep
file when it is safe to do so.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoRefactor struct transport_ops inlined into struct transport
Shawn O. Pearce [Wed, 19 Sep 2007 04:49:31 +0000 (00:49 -0400)]
Refactor struct transport_ops inlined into struct transport

Aside from reducing the code by 20 lines this refactoring removes
a level of indirection when trying to access the operations of a
given transport "instance", making the code clearer and easier to
follow.

It also has the nice effect of giving us the benefits of C99 style
struct initialization (namely ".fetch = X") without requiring that
level of language support from our compiler.  We don't need to worry
about new operation methods being added as they will now be NULL'd
out automatically by the xcalloc() we use to create the new struct
transport we supply to the caller.

This pattern already exists in struct walker, so we already have
a precedent for it in Git.  We also don't really need to worry
about any sort of performance decreases that may occur as a result
of filling out 4-8 op pointers when we make a "struct transport".
The extra few CPU cycles this requires over filling in the "struct
transport_ops" is killed by the time it will take Git to actually
*use* one of those functions, as most transport operations are
going over the wire or will be copying object data locally between
two directories.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoRename remote.uri to remote.url within remote handling internals
Shawn O. Pearce [Wed, 19 Sep 2007 04:49:27 +0000 (00:49 -0400)]
Rename remote.uri to remote.url within remote handling internals

Anyplace we talk about the address of a remote repository we always
refer to it as a URL, especially in the configuration file and
.git/remotes where we call it "remote.$n.url" or start the first
line with "URL:".  Calling this value a uri within the internal C
code just doesn't jive well with our commonly accepted terms.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoUse 'unsigned:1' when we mean boolean options
Shawn O. Pearce [Tue, 18 Sep 2007 08:55:00 +0000 (04:55 -0400)]
Use 'unsigned:1' when we mean boolean options

These options are all strictly boolean (true/false).  Its easier to
document this implicitly by making their storage type a single bit.
There is no compelling memory space reduction reason for this change,
it just makes the structure definition slightly more readable.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
16 years agoAvoid printing unnecessary warnings during fetch and push
Shawn O. Pearce [Tue, 18 Sep 2007 08:54:57 +0000 (04:54 -0400)]
Avoid printing unnecessary warnings during fetch and push

If a transport doesn't support an option we already are telling
the higher level application (fetch or push) that the option is not
valid by sending back a >0 return value from transport_set_option
so there's not a strong motivation to have the function perform the
output itself.  Instead we should let the higher level application
do the output if it is necessary.  This avoids always telling the
user that depth isn't supported on HTTP urls even when they did
not pass a --depth option to git-fetch.

If the user passes an option and the option value is invalid we now
properly die in git-fetch instead of just spitting out a message
and running anyway.  This mimics prior behavior better where
incorrect/malformed options are not accepted by the process.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
16 years agoCorrect handling of branch.$name.merge in builtin-fetch
Shawn O. Pearce [Tue, 18 Sep 2007 08:54:53 +0000 (04:54 -0400)]
Correct handling of branch.$name.merge in builtin-fetch

My prior bug fix for git-push titled "Don't configure remote "." to
fetch everything to itself" actually broke t5520 as we were unable
to evaluate a branch configuration of:

  [branch "copy"]
    remote = .
    merge = refs/heads/master

as remote "." did not have a "remote...fetch" configuration entry to
offer up refs/heads/master as a possible candidate available to be
fetched and merged.  In shell script git-fetch and prior to the above
mentioned commit this was hardcoded for a url of "." to be the set of
local branches.

Chasing down this bug led me to the conclusion that our prior behavior
with regards to branch.$name.merge was incorrect.  In the shell script
based git-fetch implementation we only fetched and merged a branch if
it appeared both in branch.$name.merge *and* in remote.$r.fetch, where
$r = branch.$name.remote.  In other words in the following config file:

  [remote "origin"]
    url = git://git.kernel.org/pub/scm/git/git.git
    fetch = refs/heads/master:refs/remotes/origin/master
  [branch "master"]
    remote = origin
    merge = refs/heads/master
  [branch "pu"]
    remote = origin
    merge = refs/heads/pu

Attempting to run `git pull` while on branch "pu" would always give
the user "Already up-to-date" as git-fetch did not fetch pu and thus
did not mark it for merge in .git/FETCH_HEAD.  The configured merge
would always be ignored and the user would be left scratching her
confused head wondering why merge did not work on "pu" but worked
fine on "master".

If we are using the "default fetch" specification for the current
branch and the current branch has a branch.$name.merge configured
we now union it with the list of refs in remote.$r.fetch.  This
way the above configuration does what the user expects it to do,
which is to fetch only "master" by default but when on "pu" to
fetch both "master" and "pu".

This uncovered some breakage in the test suite where old-style Cogito
branches (.git/branches/$r) did not fetch the branches listed in
.git/config for merging and thus did not actually merge them if the
user tried to use `git pull` on that branch.  Junio and I discussed
it on list and felt that the union approach here makes more sense to
DWIM for the end-user than silently ignoring their configured request
so the test vectors for t5515 have been updated to include for-merge
lines in .git/FETCH_HEAD where they have been configured for-merge
in .git/config.

Since we are now performing a union of the fetch specification and
the merge specification and we cannot allow a branch to be listed
twice (otherwise it comes out twice in .git/FETCH_HEAD) we need to
perform a double loop here over all of the branch.$name.merge lines
and try to set their merge flag if we have already schedule that
branch for fetching by remote.$r.fetch.  If no match is found then
we must add new specifications to fetch the branch but not store it
as no local tracking branch has been designated.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
16 years agoDon't attempt to merge non-existant remotes in t5515
Shawn O. Pearce [Tue, 18 Sep 2007 08:54:51 +0000 (04:54 -0400)]
Don't attempt to merge non-existant remotes in t5515

This was actually reverted in 756373da by Junio.  We no longer
support merging the right hand side of a fetchspec in a branch's
branch.$name.merge configuration setting as we interpret these
names as being only those published by the remote we are going to
fetch from.

The older shell based implementation of git-fetch did not report an
error when branch.$name.merge was referencing a branch that does
not exist on the remote and we are running `git fetch` for the
current branch.  The new builtin-fetch does notice this failure
and aborts the fetch, thus breaking the tests.

Junio and I kicked it around on #git earlier today and decided that
the best approach here is to error out and tell the user that their
configuration is wrong, as this is likely more user friendly than
silently ignoring the user's request.  Since the new builtin-fetch
is already issuing the error there is no code change required, we
just need to remove the bad configuration from our test.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
16 years agobuiltin-fetch: Don't segfault on "fetch +foo"
Shawn O. Pearce [Tue, 18 Sep 2007 08:54:48 +0000 (04:54 -0400)]
builtin-fetch: Don't segfault on "fetch +foo"

If we are fetching something and were configured to do a forced
fetch and have no local ref to store the fetched object into we
cannot mark the local ref as having a forced update.  Instead we
should just silently discard the + request.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
16 years agoRemove more debugging from builtin-fetch
Shawn O. Pearce [Sun, 16 Sep 2007 06:32:17 +0000 (02:32 -0400)]
Remove more debugging from builtin-fetch

Older git-fetch.sh doesn't print "ref: X" when invoked as
`git fetch $url X" so we shouldn't do that now in the new
builtin version.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoDon't configure remote "." to fetch everything to itself
Shawn O. Pearce [Sun, 16 Sep 2007 06:32:11 +0000 (02:32 -0400)]
Don't configure remote "." to fetch everything to itself

When we are talking about a remote URI of "." we are really talking
about *this* repository that we are fetching into or pushing out of.
There are no matching tracking branches for this repository; we
do not attempt to map a ref back to ourselves as this would either
create an infinite cycle (for example "fetch = +refs/*:refs/mine/*")
or it causes problems when we attempt to push back to ourselves.

So we really cannot setup a remote like this:

  [remote "."]
    url = .
    fetch = +refs/*:refs/*

In the case of `git push . B:T` to fast-forward branch T to B's
current commit git-send-pack will update branch T to B, assuming that
T is the remote tracking branch for B.  This update is performed
immediately before git-send-pack asks git-receive-pack to perform
the same update, and git-receive-pack then fails because T is not
where git-send-pack told it to expect T to be at.

In the case of `git fetch .` we really should do the same thing as
`git fetch $otherrepo`, that is load .git/FETCH_HEAD with the commit
of HEAD, so that `git pull .` will report "Already up-to-date".
We have always behaved like this before on this insane request and
we should at least continue to behave the same way.  With the above
(bad) remote configuration we were instead getting fetch errors
about funny refs, e.g. "refs/stash".

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAllow builtin-fetch to work on a detached HEAD
Shawn O. Pearce [Sun, 16 Sep 2007 06:31:26 +0000 (02:31 -0400)]
Allow builtin-fetch to work on a detached HEAD

If we are running fetch in a repository that has a detached HEAD
then there is no current_branch available.  In such a case any ref
that the fetch might update by definition cannot also be the current
branch so we should always bypass the "don't update HEAD" test.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoRemove unnecessary 'fetch' argument from transport_get API
Shawn O. Pearce [Sat, 15 Sep 2007 07:23:14 +0000 (03:23 -0400)]
Remove unnecessary 'fetch' argument from transport_get API

We don't actually need to know at the time of transport_get if the
caller wants to fetch, push, or do both on the returned object.
It is easier to just delay the initialization of the HTTP walker
until we know we will need it by providing a CURL specific fetch
function in the curl_transport that makes sure the walker instance
is initialized before use.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoAdd transport.h to LIB_H as transport.o is in LIB_OBJS
Shawn O. Pearce [Sat, 15 Sep 2007 07:23:10 +0000 (03:23 -0400)]
Add transport.h to LIB_H as transport.o is in LIB_OBJS

Any changes to transport.h probably will require rebuilding a
number of object files so we should make sure it is included
in our set of headers.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoCleanup duplicate initialization code in transport_get
Shawn O. Pearce [Sat, 15 Sep 2007 07:23:07 +0000 (03:23 -0400)]
Cleanup duplicate initialization code in transport_get

We always allocate and return a struct transport* right now as every
URL is considered to be a native Git transport if it is not rsync,
http/https/ftp or a bundle.  So we can simplify the initialization
of a new transport object by performing one xcalloc call and filling
in only the attributes required.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoDon't bother passing ref log details to walker in builtin-fetch
Shawn O. Pearce [Sat, 15 Sep 2007 07:23:04 +0000 (03:23 -0400)]
Don't bother passing ref log details to walker in builtin-fetch

When using the walker API within builtin-fetch we don't allow
it to update refs locally; instead that action is reserved for
builtin-fetch's own main loop once the objects have actually
been downloaded.

Passing NULL here will bypass the unnecessary malloc/free of a
string buffer within the walker API.  That buffer is never used
because the prior argument (the refs to update) is also NULL.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 years agoProperly cleanup in http_cleanup so builtin-fetch does not segfault
Shawn O. Pearce [Sat, 15 Sep 2007 07:23:00 +0000 (03:23 -0400)]
Properly cleanup in http_cleanup so builtin-fetch does not segfault

Junio and I both noticed that the new builtin-fetch was segfaulting
immediately on http/https/ftp style URLs (those that went through
libcurl and the commit walker).  Although the builtin-fetch changes
in this area were really just minor refactorings there was one major
change made: we invoked http_init(), http_cleanup() then http_init()
again in the same process.

When we call curl_easy_cleanup() on each active_request_slot we
are telling libcurl we did not want that buffer to be used again.
Unfortunately we did not also deallocate the active_request_slot
itself nor did we NULL out active_queue_head.  This lead us to
attempt to reuse these cleaned up libcurl handles when we later tried
to invoke http_init() a second time to reactivate the curl library.
The next file get operation then immediately segfaulted on most
versions of libcurl.

Properly freeing our own buffers and clearing the list causes us to
reinitialize the curl buffers again if/when we need to use libcurl
from within this same process.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>