Commit graph

14334 commits

Author SHA1 Message Date
Johannes Schindelin ef90d6d420 Provide git_config with a callback-data parameter
git_config() only had a function parameter, but no callback data
parameter.  This assumes that all callback functions only modify
global variables.

With this patch, every callback gets a void * parameter, and it is hoped
that this will help the libification effort.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-14 12:34:44 -07:00
Jeff King 0bdf93cbf0 filter-branch: fix variable export logic
filter-branch tries to restore "old" copies of some
environment variables by using the construct:

  unset var
  test -z "$old_var" || var="$old_var" && export var

This is just wrong.  AND-list and OR-list operators && and || have equal
precedence and they bind left to right.  The second term, var="$old"
assignment always succeeds, so we always end up exporting var.

On bash and dash, exporting an unset variable has no effect. However, on
some shells (such as FreeBSD's /bin/sh), the shell exports the empty
value.

This manifested itself in this case as git-filter-branch setting
GIT_INDEX_FILE to the empty string, which in turn caused its call to
git-read-tree to fail, leaving the working tree pointing at the original
HEAD instead of the rewritten one.

To fix this, we change the short-circuit logic to better match the intent:

  test -z "$old_var" || {
    var="$old_var" && export var
  }

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-13 21:45:28 -07:00
Jeff King 6d9878cc60 clone: bsd shell portability fix
When using /bin/sh from FreeBSD 6.1, the value of $? is lost
when calling a function inside the 'trap' action. This
resulted in clone erroneously indicating success when it
should have reported failure.

As a workaround, we save the value of $? before calling any
functions.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-13 21:45:28 -07:00
Jeff King 30684dfaf8 t5000: tar portability fix
The output of 'tar tv' varies from system to system. In
particular, the t5000 was expecting to parse the date from
something like:

  -rw-rw-r-- root/root         0 2008-05-13 04:27 file

but FreeBSD's tar produces this:

  -rw-rw-r--  0 root   root        0 May 13 04:27 file

Instead of relying on tar's output, let's just extract the
file using tar and stat the result using perl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-13 21:45:28 -07:00
Jeff King bbf08124e0 fix bsd shell negation
On some shells (notably /bin/sh on FreeBSD 6.1), the
construct

  foo && ! bar | baz

is true if

  foo && baz

whereas for most other shells (such as bash) is true if

  foo && ! baz

We can work around this by specifying

  foo && ! (bar | baz)

which works everywhere.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-13 21:44:48 -07:00
Alex Riesen 64c0d71ce9 Improve reporting of errors in config file routines
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-12 20:40:00 -07:00
Junio C Hamano eafa29b7cb Merge branch 'gp/bisect-fix'
* gp/bisect-fix:
  bisect: print an error message when "git rev-list --bisect-vars" fails
  git-bisect.sh: don't accidentally override existing branch "bisect"
2008-05-12 15:44:43 -07:00
Junio C Hamano 65ea3b8c6d Merge branch 'maint'
* maint:
  wt-status.h: declare global variables as extern
  builtin-commit.c: add -u as short name for --untracked-files
  git-repack: re-enable parsing of -n command line option
2008-05-11 12:09:18 -07:00
Junio C Hamano 3e08f5db65 Merge branch 'maint-1.5.4' into maint
* maint-1.5.4:
  wt-status.h: declare global variables as extern
  builtin-commit.c: add -u as short name for --untracked-files
  git-repack: re-enable parsing of -n command line option
2008-05-11 12:09:12 -07:00
Junio C Hamano dccb3a6acb Merge branch 'lt/core-optim'
* lt/core-optim:
  Optimize symlink/directory detection
  Avoid some unnecessary lstat() calls
  is_racy_timestamp(): do not check timestamp for gitlinks
  diff-lib.c: rename check_work_tree_entity()
  diff: a submodule not checked out is not modified
  Add t7506 to test submodule related functions for git-status
  t4027: test diff for submodule with empty directory
  Make git-add behave more sensibly in a case-insensitive environment
  When adding files to the index, add support for case-independent matches
  Make unpack-tree update removed files before any updated files
  Make branch merging aware of underlying case-insensitive filsystems
  Add 'core.ignorecase' option
  Make hash_name_lookup able to do case-independent lookups
  Make "index_name_exists()" return the cache_entry it found
  Move name hashing functions into a file of its own
  Make unpack_trees_options bit flags actual bitfields
2008-05-11 12:08:20 -07:00
Christian Couder dfd1b749be rev-parse --verify: do not output anything on error
Before this patch, when "git rev-parse --verify" was passed at least one
good rev and then anything, it would output something for the good rev
even if it would latter exit on error.

With this patch, we only output something if everything is ok.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 11:51:12 -07:00
Christian Couder 28bfa145e4 rev-parse: fix using "--default" with "--verify"
Before this patch, something like:

$ git rev-parse --verify HEAD --default master

did not work, while:

$ git rev-parse --default master --verify HEAD

worked.

This patch fixes that, so that they both work (assuming
HEAD and master can be parsed).

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 11:36:07 -07:00
Christian Couder 921df15f1d rev-parse: add test script for "--verify"
This patch documents the current behavior of "git rev-parse --verify".

This command is tested both with and without the "--quiet" and
"--default" options.

This shows some problems with the current behavior that will be fixed
in latter patches:

	- in case of errors, there should be no good rev output on
	stdout,
	- with "--default" one test case is broken

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 11:35:42 -07:00
Steven Grimm 4be4038153 Add svn-compatible "blame" output format to git-svn
git-svn blame produced output in the format of git blame; in environments
where there are scripts that read the output of svn blame, it's useful
to be able to use them with the output of git-svn. The git-compatible
format is still available using the new "--git-format" option.

This also fixes a bug in the initial git-svn blame implementation; it was
bombing out on uncommitted local changes.

Signed-off-by: Steven Grimm <koreth@midwinter.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:12:19 -07:00
Sebastian Schuberth f4e9f786f7 mergetool: Make ECMerge use the settings as specified by the user in the GUI
When run from the command line, ECMerge does not automatically use the same
settings for a merge / diff that it would use when starting the GUI and loading
files manually. In the first case the built-in factory defaults would be used,
while in the second case the settings the user has specified in the GUI would
be used, which can be misleading. Specifying the "--default" command line
option changes this behavior so that always the user specfified GUI settings
are used.

Signed-off-by: Sebastian Schuberth <sschuberth@visageimaging.com>
Tested-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:12:19 -07:00
Caio Marcelo de Oliveira Filho 37c22a4bf8 git-format-patch: add --no-binary to omit binary changes in the patch.
Add a new option --no-binary to git-format-patch so that no binary
changes are included in the generated patches, only notices that those
files changed.  This generate patches that cannot be applied, but still
is useful for generating mails for code review purposes.

See also: commit e47f306d4b, where --binary
option was turned on by default.

Signed-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:12:19 -07:00
Johannes Sixt 32efcd91c6 wt-status.h: declare global variables as extern
There are linkers out there that complain if a global non-static variable
is defined multiple times.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:04:46 -07:00
Sitaram Chamarty e1645901ed builtin-commit.c: add -u as short name for --untracked-files
This makes the C code consistent with the documentation and the old shell
code.

Signed-off-by: Sitaram Chamarty <sitaramc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:04:20 -07:00
A Large Angry SCM 2b36b146fa git-repack: re-enable parsing of -n command line option
In commit 5715d0b (Migrate git-repack.sh to use git-rev-parse --parseopt,
2007-11-04), parsing of the '-n' command line option was accidentally lost
when git-repack.sh was migrated to use git-rev-parse --parseopt. This adds
it back.

Signed-off-by: A Large Angry SCM <gitzilla@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 10:03:58 -07:00
Dustin Sallings c998ae9baa Allow tracking branches to set up rebase by default.
Change cd67e4d4 introduced a new configuration parameter that told
pull to automatically perform a rebase instead of a merge.  This
change provides a configuration option to enable this feature
automatically when creating a new branch.

If the variable branch.autosetuprebase applies for a branch that's
being created, that branch will have branch.<name>.rebase set to true.

Signed-off-by: Dustin Sallings <dustin@spy.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 09:28:52 -07:00
Eric Wong d1a8d0ea5f git-svn: fix cloning of HTTP URLs with '+' in their path
With this, git svn clone -s http://svn.gnome.org/svn/gtk+
is successful.

Also modified the funky rename test for this, which _does_
include escaped '+' signs for HTTP URLs.  SVN seems to accept
either "+" or "%2B" in filenames and directories (just not the
main URL), so I'll leave it alone for now.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 09:06:39 -07:00
Krzysztof Kowalczyk 737922aa64 alloc_ref_from_str(): factor out a common pattern of alloc_ref from string
Also fix an underallocation in walker.c::interpret_target().

Signed-off-by: Krzysztof Kowalczyk <kkowalczyk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-11 09:04:37 -07:00
Linus Torvalds c40641b77b Optimize symlink/directory detection
This is the base for making symlink detection in the middle fo a pathname
saner and (much) more efficient.

Under various loads, we want to verify that the full path leading up to a
filename is a real directory tree, and that when we successfully do an
'lstat()' on a filename, we don't get a false positive due to a symlink in
the middle of the path that git should have seen as a symlink, not as a
normal path component.

The 'has_symlink_leading_path()' function already did this, and cached
a single level of symlink information, but didn't cache the _lack_ of a
symlink, so the normal behaviour was actually the wrong way around, and we
ended up doing an 'lstat()' on each path component to check that it was a
real directory.

This caches the last detected full directory and symlink entries, and
speeds up especially deep directory structures a lot by avoiding to
lstat() all the directories leading up to each entry in the index.

[ This can - and should - probably be extended upon so that we eventually
  never do a bare 'lstat()' on any path entries at *all* when checking the
  index, but always check the full path carefully. Right now we do not
  generally check the whole path for all our normal quick index
  revalidation.

  We should also make sure that we're careful about all the invalidation,
  ie when we remove a link and replace it by a directory we should
  invalidate the symlink cache if it matches (and vice versa for the
  directory cache).

  But regardless, the basic function needs to be sane to do that. The old
  'has_symlink_leading_path()' was not capable enough - or indeed the code
  readable enough - to really do that sanely. So I'm pushing this as not
  just an optimization, but as a base for further work. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-10 18:16:31 -07:00
Linus Torvalds d177cab048 Avoid some unnecessary lstat() calls
The commit sequence used to do

	if (file_exists(p->path))
		add_file_to_cache(p->path, 0);

where both "file_exists()" and "add_file_to_cache()" needed to do a
lstat() on the path to do their work.

This cuts down 'lstat()' calls for the partial commit case by two
for each path we know about (because we do this twice per path).

Just move the lstat() to the caller instead (that's all that
"file_exists()" really does), and pass the stat information down to the
add_to_cache() function.

This essentially makes 'add_to_index()' the core function that adds a path
to the index, getting the index pointer, the pathname and the stat
information as arguments. There are then shorthand helper functions that
use this core function:

 - 'add_to_cache()' is just 'add_to_index()' with the default index

 - 'add_file_to_cache/index()' is the same, but does the lstat() call
   itself, so you can pass just the pathname if you don't already have the
   stat information available.

So old users of the 'add_file_to_xyzzy()' are essentially left unchanged,
and this just exposes the more generic helper function that can take
existing stat information into account.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-10 18:16:30 -07:00
Junio C Hamano 2855e70ad1 Merge branch 'py/diff-submodule'
* py/diff-submodule:
  is_racy_timestamp(): do not check timestamp for gitlinks
  diff-lib.c: rename check_work_tree_entity()
  diff: a submodule not checked out is not modified
  Add t7506 to test submodule related functions for git-status
  t4027: test diff for submodule with empty directory
2008-05-10 18:16:25 -07:00
Junio C Hamano 380a742679 Merge branch 'lt/case-insensitive'
* lt/case-insensitive:
  Make git-add behave more sensibly in a case-insensitive environment
  When adding files to the index, add support for case-independent matches
  Make unpack-tree update removed files before any updated files
  Make branch merging aware of underlying case-insensitive filsystems
  Add 'core.ignorecase' option
  Make hash_name_lookup able to do case-independent lookups
  Make "index_name_exists()" return the cache_entry it found
  Move name hashing functions into a file of its own
  Make unpack_trees_options bit flags actual bitfields
2008-05-10 18:14:28 -07:00
Junio C Hamano 1f8115b113 Merge branch 'maint'
* maint:
  Documentation/config.txt: Mention branch.<name>.rebase applies to "git pull"
  doc: clarify definition of "update" for git-add -u
2008-05-08 20:50:03 -07:00
Junio C Hamano 32a27b5666 Merge branch 'maint-1.5.4' into maint
* maint-1.5.4:
  Documentation/config.txt: Mention branch.<name>.rebase applies to "git pull"
  doc: clarify definition of "update" for git-add -u
2008-05-08 20:12:44 -07:00
Junio C Hamano ca1c9913f8 Merge branch 'sg/merge-options' (early part)
* 'sg/merge-options' (early part):
  merge, pull: add '--(no-)log' command line option
  fmt-merge-msg: add '--(no-)log' options and 'merge.log' config variable
  add 'merge.stat' config variable
  merge, pull: introduce '--(no-)stat' option
  doc: moved merge.* config variables into separate merge-config.txt
2008-05-08 20:06:36 -07:00
Junio C Hamano 31a3c6bb45 Merge branch 'db/learn-HEAD'
* db/learn-HEAD:
  Make ls-remote http://... list HEAD, like for git://...
  Make walker.fetch_ref() take a struct ref.
2008-05-08 20:06:23 -07:00
Junio C Hamano a064ac1bc3 Merge branch 'jn/webfeed'
* jn/webfeed:
  gitweb: Use feed link according to current view
2008-05-08 20:06:15 -07:00
Junio C Hamano d576c45aae Merge branch 'cc/help'
* cc/help:
  documentation: web--browse: add a note about konqueror
  documentation: help: add info about "man.<tool>.cmd" config var
  help: use "man.<tool>.cmd" as custom man viewer command
  documentation: help: add "man.<tool>.path" config variable
  help: use man viewer path from "man.<tool>.path" config var
2008-05-08 20:06:11 -07:00
Junio C Hamano ca1a5eeead Merge branch 'dm/cherry-pick-s'
* dm/cherry-pick-s:
  Allow cherry-pick (and revert) to add signoff line
2008-05-08 20:06:06 -07:00
Junio C Hamano 4c4d3ac746 Merge branch 'lt/dirmatch-optim'
* lt/dirmatch-optim:
  Optimize match_pathspec() to avoid fnmatch()
2008-05-08 20:05:43 -07:00
Christian Couder 42ba5ee776 bisect: print an error message when "git rev-list --bisect-vars" fails
Before this patch no error was printed when "git rev-list --bisect-vars"
failed. This can happen when bad and good revs are mistaken.

This patch prints an error message on stderr that describe the likely
failure cause.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 17:50:00 -07:00
Johannes Sixt c5445fe090 compat-util: avoid macro redefinition warning
Some systems define fopen as a macro based on compiler settings, and
unconditionally redefining it triggers a compilation warning.
2008-05-08 17:47:25 -07:00
Brandon Casey eb120e699f compat/fopen.c: avoid clobbering the system defined fopen macro
Some systems define fopen as a macro based on compiler settings.
The previous technique for reverting to the system fopen function
by merely undefining fopen is inadequate in this case. Instead,
avoid defining fopen entirely when compiling this source file.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 17:43:01 -07:00
Dustin Sallings 15ddb6fab2 Documentation/config.txt: Mention branch.<name>.rebase applies to "git pull"
Signed-off-by: Dustin Sallings <dustin@spy.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 12:15:30 -07:00
Jeff King afd899e1b7 doc: clarify definition of "update" for git-add -u
The "-u" option is described only in terms of "updating"
files, which in turn is described only as "similar to what
git commit -a does". Let's be a little more specific about
what updating entails.

Suggested by Geoffrey Irving.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 12:09:42 -07:00
Christian Couder bac59f19b1 Documentation: bisect: add a few "git bisect run" examples
Before this patch, there were no "git bisect run" example.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 11:37:59 -07:00
Gustaf Hendeby d84ae0dbd5 Documentation/config.txt: Add git-gui options
The 'git gui' has a number of options that can be specified using the
options dialog. Sometimes it is convenient to be able to specify these
from the command line, therefor document these options.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Acked-by: Shawn O. Pearce <speace@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-08 11:37:34 -07:00
Christian Couder 921177f50f Documentation: improve "add", "pull" and "format-patch" examples
Before this patch in "git-add.txt" and "git-format-patch.txt", the
commands used in the examples were "git-CMD" instead of "git CMD".
This patch fixes that.

In "git-pull.txt" only the last example had the code sample in an
asciidoc "Listing Block", and in the other two files, none.
This patch fixes that by putting all code samples in listing
blocks.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06 21:46:42 -07:00
Mark Hills c904bf392d Be more careful with objects directory permissions on clone
Honour the setgid and umask when re-creating the objects directory
at the destination.

cpio in copy-pass mode aims to copy file permissions which causes this
problem and cannot be disabled. Be explicit by copying the directory
structure first, honouring the permissions at the destination, then copy
the files with 0444 permissions. This also avoids bugs in some versions
of cpio.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06 21:34:35 -07:00
Junio C Hamano 867fa20fe9 Merge branch 'jc/lstat'
* jc/lstat:
  diff-files: mark an index entry we know is up-to-date as such
  write_index(): optimize ce_smudge_racily_clean_entry() calls with CE_UPTODATE
2008-05-05 19:16:26 -07:00
Junio C Hamano e9dd751866 Merge branch 'bc/filter-branch'
* bc/filter-branch:
  filter-branch.sh: support nearly proper tag name filtering
2008-05-05 19:16:20 -07:00
Junio C Hamano e2e2defc14 Merge branch 'lh/git-file'
* lh/git-file:
  Teach GIT-VERSION-GEN about the .git file
  Teach git-submodule.sh about the .git file
  Teach resolve_gitlink_ref() about the .git file
  Add platform-independent .git "symlink"
2008-05-05 19:16:16 -07:00
Junio C Hamano 9c36e1700f Merge branch 'jk/fetch-status'
* jk/fetch-status:
  git-fetch: always show status of non-tracking-ref fetches
2008-05-05 19:16:12 -07:00
Junio C Hamano b79c9859c8 Merge branch 'lh/branch-merged'
* lh/branch-merged:
  Add tests for `branch --[no-]merged`
  git-branch.txt: compare --contains, --merged and --no-merged
  git-branch: add support for --merged and --no-merged
2008-05-05 19:16:06 -07:00
Junio C Hamano dc484f2213 Merge branch 'pb/remote-mirror-config'
* pb/remote-mirror-config:
  Add a remote.*.mirror configuration option
2008-05-05 19:15:39 -07:00
Jörg Sommer 2b3e60c245 post-merge: Add it's not executed if merge failed.
Signed-off-by: J��rg Sommer <joerg@alea.gnuu.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-05 17:30:23 -07:00