Commit Graph

126 Commits

Author SHA1 Message Date
Steffen Prohaska
5d54e5d4f2 setup (Windows): Revert leftovers of old implementation
The handling of paths was resolved differently in the MinGW port that
is merged to official git.  This commit takes this implementation.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2008-07-14 08:01:27 +02:00
Steffen Prohaska
c1f5a4fc46 Merge commit 'junio/master' into devel
Conflicts:
	Makefile
	cache.h
	compat/mingw.c
	git-compat-util.h
	run-command.c
	setup.c
	t/t4109-apply-multifrag.sh
2008-07-14 07:12:23 +02:00
Junio C Hamano
17d778e710 Merge branch 'dr/ceiling'
* dr/ceiling:
  Eliminate an unnecessary chdir("..")
  Add support for GIT_CEILING_DIRECTORIES
  Fold test-absolute-path into test-path-utils
  Implement normalize_absolute_path

Conflicts:

	cache.h
	setup.c
2008-07-07 02:17:23 -07:00
Junio C Hamano
bb1ab2db08 Merge branch 'j6t/mingw'
* j6t/mingw: (38 commits)
  compat/pread.c: Add a forward declaration to fix a warning
  Windows: Fix ntohl() related warnings about printf formatting
  Windows: TMP and TEMP environment variables specify a temporary directory.
  Windows: Make 'git help -a' work.
  Windows: Work around an oddity when a pipe with no reader is written to.
  Windows: Make the pager work.
  When installing, be prepared that template_dir may be relative.
  Windows: Use a relative default template_dir and ETC_GITCONFIG
  Windows: Compute the fallback for exec_path from the program invocation.
  Turn builtin_exec_path into a function.
  Windows: Use a customized struct stat that also has the st_blocks member.
  Windows: Add a custom implementation for utime().
  Windows: Add a new lstat and fstat implementation based on Win32 API.
  Windows: Implement a custom spawnve().
  Windows: Implement wrappers for gethostbyname(), socket(), and connect().
  Windows: Work around incompatible sort and find.
  Windows: Implement asynchronous functions as threads.
  Windows: Disambiguate DOS style paths from SSH URLs.
  Windows: A rudimentary poll() emulation.
  Windows: Implement start_command().
  ...
2008-07-02 21:57:52 -07:00
Steffen Prohaska
76fbe95f5e Merge commit 'v1.5.6.1' into devel
Conflicts:

	RelNotes
	cache.h
2008-07-01 10:42:12 +02:00
Steffen Prohaska
d21c3cb9d4 Merge commit 'mingw/master' into devel 2008-06-30 12:26:19 +02:00
Johannes Sixt
25fe217b86 Windows: Treat Windows style path names.
GIT's guts work with a forward slash as a path separators. We do not change
that. Rather we make sure that only "normalized" paths enter the depths
of the machinery.

We have to translate backslashes to forward slashes in the prefix and in
command line arguments. Fortunately, all of them are passed through
functions in setup.c.

A macro has_dos_drive_path() is defined that checks whether a path begins
with a drive letter+colon combination. This predicate is always false on
Unix. Another macro is_dir_sep() abstracts that a backslash is also a
directory separator on Windows.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23 13:30:22 +02:00
Johannes Sixt
4cd148d83f setup.c: Prepare for Windows directory separators.
This turns two switch/case statements into an if-else-if cascade because
we later do not want to have

        case '/':
    #ifdef __MINGW32__
        case '\\':
    #endif

but use a predicate is_dir_sep(foo) in order to check for the directory
separator.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23 13:22:35 +02:00
Johannes Sixt
b0115de333 Remove a 'break' that was accidentally left over
The conversion of the 'switch' statement to an 'if' cascade forgot to
remove the break.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23 10:57:56 +02:00
Linus Torvalds
044bbbcb63 Make git_dir a path relative to work_tree in setup_work_tree()
Once we find the absolute paths for git_dir and work_tree, we can make
git_dir a relative path since we know pwd will be work_tree. This should
save the kernel some time traversing the path to work_tree all the time
if git_dir is inside work_tree.

Daniel's patch didn't apply for me as-is, so I recreated it with some
differences, and here are the numbers from ten runs each.

There is some IO for me - probably due to more-or-less random flushing of
the journal - so the variation is bigger than I'd like, but whatever:

	Before:
		real    0m8.135s
		real    0m7.933s
		real    0m8.080s
		real    0m7.954s
		real    0m7.949s
		real    0m8.112s
		real    0m7.934s
		real    0m8.059s
		real    0m7.979s
		real    0m8.038s

	After:
		real    0m7.685s
		real    0m7.968s
		real    0m7.703s
		real    0m7.850s
		real    0m7.995s
		real    0m7.817s
		real    0m7.963s
		real    0m7.955s
		real    0m7.848s
		real    0m7.969s

Now, going by "best of ten" (on the assumption that the longer numbers
are all due to IO), I'm saying a 7.933s -> 7.685s reduction, and it does
seem to be outside of the noise (ie the "after" case never broke 8s, while
the "before" case did so half the time).

So looks like about 3% to me.

Doing it for a slightly smaller test-case (just the "arch" subdirectory)
gets more stable numbers probably due to not filling the journal with
metadata updates, so we have:

	Before:
		real    0m1.633s
		real    0m1.633s
		real    0m1.633s
		real    0m1.632s
		real    0m1.632s
		real    0m1.630s
		real    0m1.634s
		real    0m1.631s
		real    0m1.632s
		real    0m1.632s

	After:
		real    0m1.610s
		real    0m1.609s
		real    0m1.610s
		real    0m1.608s
		real    0m1.607s
		real    0m1.610s
		real    0m1.609s
		real    0m1.611s
		real    0m1.608s
		real    0m1.611s

where I'ld just take the averages and say 1.632 vs 1.610, which is just
over 1% peformance improvement.

So it's not in the noise, but it's not as big as I initially thought and
measured.

(That said, it obviously depends on how deep the working directory path is
too, and whether it is behind NFS or something else that might need to
cause more work to look up).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-19 16:44:21 -07:00
Steffen Prohaska
d0a15401e1 Merge commit 'mingw/master' into devel 2008-06-08 13:12:24 +02:00
Johannes Sixt
ec346a5ada Merge branch 'master' of git://repo.or.cz/alt-git 2008-05-27 08:43:58 +02:00
David Reiss
450f437fb0 Eliminate an unnecessary chdir("..")
In the case where setup_git_directory_gently fails, avoid the last
chdir("..") by moving it after the ceil_offset check.

Signed-off-by: David Reiss <dreiss@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-23 14:15:01 -07:00
David Reiss
0454dd93bf Add support for GIT_CEILING_DIRECTORIES
Make git recognize a new environment variable that prevents it from
chdir'ing up into specified directories when looking for a GIT_DIR.
Useful for avoiding slow network directories.

For example, I use git in an environment where homedirs are automounted
and "ls /home/nonexistent" takes about 9 seconds.  Setting
GIT_CEILING_DIRS="/home" allows "git help -a" (for bash completion) and
"git symbolic-ref" (for my shell prompt) to run in a reasonable time.

Signed-off-by: David Reiss <dreiss@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-23 14:15:01 -07:00
Steffen Prohaska
21bd486984 Merge commit 'mingw/master' into devel 2008-05-21 23:13:05 +02:00
Steffen Prohaska
ba6c6a839e Merge commit 'mingw/master' into devel
Conflicts:

	RelNotes
2008-05-16 22:15:42 +02:00
Johannes Sixt
e561672203 Merge branch 'master' of git://repo.or.cz/alt-git.git 2008-05-15 21:46:46 +02:00
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
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
Johannes Sixt
ef0d937dbb Merge branch 'master' of git://repo.or.cz/alt-git 2008-05-02 22:07:19 +02:00
Heikki Orsila
06cbe85503 Make core.sharedRepository more generic
git init --shared=0xxx, where '0xxx' is an octal number, will create
a repository with file modes set to '0xxx'. Users with a safe umask
value (0077) can use this option to force file modes. For example,
'0640' is a group-readable but not group-writable regardless of
user's umask value. Values compatible with old Git versions are written
as they were before, for compatibility reasons. That is, "1" for
"group" and "2" for "everybody".

"git config core.sharedRepository 0xxx" is also handled.

Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-16 18:23:54 -07:00
Lars Hjemli
b44ebb19e3 Add platform-independent .git "symlink"
This patch allows .git to be a regular textfile containing the path of
the real git directory (prefixed with "gitdir: "), which can be useful on
platforms lacking support for real symlinks.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:50 -07:00
Steffen Prohaska
adb59c0f01 Merge commit 'mingw/master' into devel 2008-03-28 18:21:08 +01:00
Johannes Sixt
d4a7a8147a Merge branch 'master' of git://repo.or.cz/alt-git 2008-03-28 08:35:38 +01:00
SZEDER Gábor
af05d67939 Always set *nongit_ok in setup_git_directory_gently()
setup_git_directory_gently() only modified the value of its *nongit_ok
argument if we were not in a git repository.  Now it will always set it
to 0 when we are inside a repository.

Also remove now unnecessary initializations in the callers of this
function.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-26 15:41:35 -07:00
Steffen Prohaska
64934ca81e Merge commit 'mingw/master' into devel
Conflicts:

	Makefile
	git-compat-util.h
	help.c
	t/t5505-remote.sh
2008-03-16 22:26:33 +01:00
Johannes Sixt
a76ef1f443 Define is_dir_sep conditionally in compat/mingw.h and git-compat-util.h.
By doing it there we can reduce yet another bunch of conditionals from
setup.c.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-03-13 13:28:17 +01:00
Johannes Sixt
5c499964de Merge branch 'master' of git://repo.or.cz/alt-git 2008-03-09 20:14:15 +01:00
Junio C Hamano
3296766eb5 get_pathspec(): die when an out-of-tree path is given
An earlier commit d089ebaa (setup: sanitize absolute and funny paths) made
get_pathspec() aware of absolute paths, but with a botched interface that
forced the callers to count the resulting pathspecs in order to detect
an error of giving a path that is outside the work tree.

This fixes it, by dying inside the function.

We had ls-tree test that relied on a misfeature in the original
implementation of its pathspec handling.  Leading slashes were silently
removed from them.  However we allow giving absolute pathnames (people
want to cut and paste from elsewhere) that are inside work tree these
days, so a pathspec that begin with slash _should_ be treated as a full
path.  The test is adjusted to match the updated rule for get_pathspec().

Earlier I mistook three tests given by Robin that they should succeed, but
these are attempts to add path outside work tree, which should fail
loudly.  These tests also have been fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-07 00:14:42 -08:00
Johannes Sixt
3031522444 Introduce has_dos_drive_prefix() and use it.
This function tests whether there is a C: style prefix in the argument.
It returns always 0 on Unix.

With this functions a number of conditionals #ifdef __MINGW32__/#endif
can be removed.

The getcwd() replacement was simplified: It tried to elide the translation
of backslashes to slashes if there was no drive prfix, but this
optimization is wrong: We could be looking at an UNC path, which we also
want to translate.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-03-02 21:54:30 +01:00
Johannes Sixt
3f0f6847aa Merge branch 'master' of git://repo.or.cz/alt-git 2008-03-02 20:49:32 +01:00
Steffen Prohaska
1a6f052e01 Merge commit 'mingw/master' into devel
Conflicts:

	builtin-tag.c
2008-03-01 10:06:38 +01:00
Johannes Sixt
d4af30b7c7 Fix sanitary_path_copy() for absolute Windows style paths.
We recognized the drive letter and colon, but we did not copy them. So far
this was not a problem since the only call site used the same pointer for
source and destination. But better safe than sorry.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-02-24 17:35:39 +01:00
Steffen Prohaska
446c466821 Merge commit 'mingw/master' into devel
Conflicts:

	Makefile
	RelNotes
	compat/qsort.c
	help.c
	read-cache.c
2008-02-24 15:48:45 +01:00
Jim Meyering
8e0f70033b Avoid unnecessary "if-before-free" tests.
This change removes all obvious useless if-before-free tests.
E.g., it replaces code like this:

        if (some_expression)
                free (some_expression);

with the now-equivalent:

        free (some_expression);

It is equivalent not just because POSIX has required free(NULL)
to work for a long time, but simply because it has worked for
so long that no reasonable porting target fails the test.
Here's some evidence from nearly 1.5 years ago:

    http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html

FYI, the change below was prepared by running the following:

  git ls-files -z | xargs -0 \
  perl -0x3b -pi -e \
    's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s'

Note however, that it doesn't handle brace-enclosed blocks like
"if (x) { free (x); }".  But that's ok, since there were none like
that in git sources.

Beware: if you do use the above snippet, note that it can
produce syntactically invalid C code.  That happens when the
affected "if"-statement has a matching "else".
E.g., it would transform this

  if (x)
    free (x);
  else
    foo ();

into this:

  free (x);
  else
    foo ();

There were none of those here, either.

If you're interested in automating detection of the useless
tests, you might like the useless-if-before-free script in gnulib:
[it *does* detect brace-enclosed free statements, and has a --name=S
 option to make it detect free-like functions with different names]

  http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free

Addendum:
  Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-22 14:14:40 -08:00
Johannes Sixt
9a13ba1bed prefix_path: use is_absolute_path() instead of *orig == '/'
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-20 20:21:43 -08:00
Junio C Hamano
9e7bd0110b Merge branch 'jc/setup'
* jc/setup:
  builtin-mv: minimum fix to avoid losing files
  git-add: adjust to the get_pathspec() changes.
  Make blame accept absolute paths
  setup: sanitize absolute and funny paths in get_pathspec()
2008-02-20 16:13:16 -08:00
Johannes Sixt
6b17197be4 Windows: convert '\\' to '/' in sanitary_path_copy().
sanitary_path_copy() is only used by prefix_path(). A helper function
is_dir_sep() is introduced that checks for both '/' and '\\' on Windows.
Note that the remaining checks for '/' in prefix_path() don't need to
to be converted to is_dir_sep() since they operate on the sanitized path.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-02-19 22:15:17 +01:00
Johannes Sixt
304601534d prefix_path: use is_absolute_path() instead of *orig == '/'
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-02-19 22:11:12 +01:00
Johannes Sixt
0f70fafb13 Merge branch 'jc/setup'
This reverts the MinGW specific part of prefix_path(). It needs to be
dealt with in a different way.
2008-02-19 21:18:55 +01:00
Johannes Sixt
8221a4b1fb Merge branch 'master' of git://repo.or.cz/alt-git 2008-02-17 21:54:08 +01:00
Junio C Hamano
180483c5c9 setup.c: guard config parser from value=NULL
core.worktree expects a string value

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11 13:11:37 -08:00
Junio C Hamano
d089ebaad5 setup: sanitize absolute and funny paths in get_pathspec()
The prefix_path() function called from get_pathspec() is
responsible for translating list of user-supplied pathspecs to
list of pathspecs that is relative to the root of the work
tree.  When working inside a subdirectory, the user-supplied
pathspecs are taken to be relative to the current subdirectory.

Among special path components in pathspecs, we used to accept
and interpret only "." ("the directory", meaning a no-op) and
".."  ("up one level") at the beginning.  Everything else was
passed through as-is.

For example, if you are in Documentation/ directory of the
project, you can name Documentation/howto/maintain-git.txt as:

    howto/maintain-git.txt
    ../Documentation/howto/maitain-git.txt
    ../././Documentation/howto/maitain-git.txt

but not as:

    howto/./maintain-git.txt
    $(pwd)/howto/maintain-git.txt

This patch updates prefix_path() in several ways:

 - If the pathspec is not absolute, prefix (i.e. the current
   subdirectory relative to the root of the work tree, with
   terminating slash, if not empty) and the pathspec is
   concatenated first and used in the next step.  Otherwise,
   that absolute pathspec is used in the next step.

 - Then special path components "." (no-op) and ".." (up one
   level) are interpreted to simplify the path.  It is an error
   to have too many ".." to cause the intermediate result to
   step outside of the input to this step.

 - If the original pathspec was not absolute, the result from
   the previous step is the resulting "sanitized" pathspec.
   Otherwise, the result from the previous step is still
   absolute, and it is an error if it does not begin with the
   directory that corresponds to the root of the work tree.  The
   directory is stripped away from the result and is returned.

 - In any case, the resulting pathspec in the array
   get_pathspec() returns omit the ones that caused errors.

With this patch, the last two examples also behave as expected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-05 00:44:10 -08:00
Steffen Prohaska
ebb79d06bf Merge commit 'mingw/master' into devel 2008-01-13 14:17:32 +01:00
Johannes Sixt
758eec41e2 Merge branch 'master' of git://repo.or.cz/alt-git 2008-01-12 20:37:40 +01:00
Jim Meyering
790296fd88 Fix grammar nits in documentation and in code comments.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-03 09:15:17 -08:00
Steffen Prohaska
7b25739391 Merge commit 'mingw/master' into work/merge-mingw
Conflicts:

	Makefile
	help.c
	  moved msysgit specific code to show_html_page
	  and call show_html_page per default.
2007-12-13 22:38:05 +01:00
Johannes Sixt
224244e4ca Merge branch 'master' of git://repo.or.cz/alt-git to sync with v1.5.4-rc0 2007-12-13 20:54:23 +01:00
Nguyễn Thái Ngọc Duy
bb4e3527b5 Remove repo version check from setup_git_directory
setup_git_directory_gently has done the check already.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09 02:24:51 -08:00
Johannes Sixt
4a8d948eac Fix prefix_filename() function.
The previous implementation translated '\' to '/' on non-Windows, too
(in those cases where the prefix was actually prepended to the path).

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-12-08 20:51:36 +01:00