aboutsummaryrefslogtreecommitdiff
path: root/setup.c
Commit message (Collapse)AuthorAge
* Merge branch 'bk/fix-relative-gitdir-file'Junio C Hamano2010-01-20
|\ | | | | | | | | | | * bk/fix-relative-gitdir-file: Handle relative paths in submodule .git files Test update-index for a gitlink to a .git file
| * Handle relative paths in submodule .git filesBrad King2010-01-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 842abf0 (Teach resolve_gitlink_ref() about the .git file, 2008-02-20) taught resolve_gitlink_ref() to call read_gitfile_gently() to resolve .git files. In this commit teach read_gitfile_gently() to interpret a relative path in a .git file with respect to the file location. This change allows update-index to recognize a submodule that uses a relative path in its .git file. It previously failed because the relative path was wrongly interpreted with respect to the superproject directory. Signed-off-by: Brad King <brad.king@kitware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'mm/diag-path-in-treeish'Junio C Hamano2010-01-10
|\ \ | |/ |/| | | | | * mm/diag-path-in-treeish: Detailed diagnosis when parsing an object name fails.
| * Detailed diagnosis when parsing an object name fails.Matthieu Moy2009-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous error message was the same in many situations (unknown revision or path not in the working tree). We try to help the user as much as possible to understand the error, especially with the sha1:filename notation. In this case, we say whether the sha1 or the filename is problematic, and diagnose the confusion between relative-to-root and relative-to-$PWD confusion precisely. The 7 new error messages are tested. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'maint' to sync with 1.6.5.7Junio C Hamano2009-12-16
|\ \ | |/ |/| | | | | | | | | | | | | * maint: Git 1.6.5.7 worktree: don't segfault with an absolute pathspec without a work tree ignore unknown color configuration help.autocorrect: do not run a command if the command given is junk Illustrate "filter" attribute with an example
| * worktree: don't segfault with an absolute pathspec without a work treeJunio C Hamano2009-12-16
| | | | | | | | | | | | | | | | | | | | | | | | If a command is run with an absolute path as a pathspec inside a bare repository, e.g. "rev-list HEAD -- /home", the code tried to run strlen() on NULL, which is the result of get_git_work_tree(), and segfaulted. It should just fail instead. Currently the function returns NULL even inside .git/ in a repository with a work tree, but that is a separate issue. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | check_filename(): make verify_filename() callable without dyingJunio C Hamano2009-10-18
|/ | | | | | Make it possible to invole the logic of verify_filename() to make sure the pathname arguments are unambiguous without actually dying. The caller may want to do something different.
* Test for WIN32 instead of __MINGW32_Frank Li2009-09-18
| | | | | | | | | | | | | | | The code which is conditional on MinGW32 is actually conditional on Windows. Use the WIN32 symbol, which is defined by the MINGW32 and MSVC environments, but not by Cygwin. Define SNPRINTF_SIZE_CORR=1 for MSVC too, as its vsnprintf function does not add NUL at the end of the buffer if the result fits the buffer size exactly. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Use die_errno() instead of die() when checking syscallsThomas Rast2009-06-27
| | | | | | | | | | | | | | | | | | | | Lots of die() calls did not actually report the kind of error, which can leave the user confused as to the real problem. Use die_errno() where we check a system/library call that sets errno on failure, or one of the following that wrap such calls: Function Passes on error from -------- -------------------- odb_pack_keep open read_ancestry fopen read_in_full xread strbuf_read xread strbuf_read_file open or strbuf_read_file strbuf_readlink readlink write_in_full xwrite Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast2009-06-27
| | | | | | | | | | | Change calls to die(..., strerror(errno)) to use the new die_errno(). In the process, also make slight style adjustments: at least state _something_ about the function that failed (instead of just printing the pathname), and put paths in single quotes. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* "core.sharedrepository = 0mode" should set, not loosenJunio C Hamano2009-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the behaviour of octal notation to how it is defined in the documentation, while keeping the traditional "loosen only" semantics intact for "group" and "everybody". Three main points of this patch are: - For an explicit octal notation, the internal shared_repository variable is set to a negative value, so that we can tell "group" (which is to "OR" in 0660) and 0660 (which is to "SET" to 0660); - git-init did not set shared_repository variable early enough to affect the initial creation of many files, notably copied templates and the configuration. We set it very early when a command-line option specifies a custom value. - Many codepaths create files inside $GIT_DIR by various ways that all involve mkstemp(), and then call move_temp_to_file() to rename it to its final destination. We can add adjust_shared_perm() call here; for the traditional "loosen-only", this would be a no-op for many codepaths because the mode is already loose enough, but with the new behaviour it makes a difference. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'js/maint-1.6.0-path-normalize'Junio C Hamano2009-02-10
|\ | | | | | | | | | | | | | | | | * js/maint-1.6.0-path-normalize: Remove unused normalize_absolute_path() Test and fix normalize_path_copy() Fix GIT_CEILING_DIRECTORIES on Windows Move sanitary_path_copy() to path.c and rename it to normalize_path_copy() Make test-path-utils more robust against incorrect use
| * Move sanitary_path_copy() to path.c and rename it to normalize_path_copy()Johannes Sixt2009-02-07
| | | | | | | | | | | | | | | | | | | | | | | | | | This function and normalize_absolute_path() do almost the same thing. The former already works on Windows, but the latter crashes. In subsequent changes we will remove normalize_absolute_path(). Here we make the replacement function reusable. On the way we rename it to reflect that it does some path normalization. Apart from that this is only moving around code. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'sg/maint-gitdir-in-subdir'Junio C Hamano2009-01-21
|\ \ | | | | | | | | | | | | * sg/maint-gitdir-in-subdir: Fix gitdir detection when in subdir of gitdir
| * | Fix gitdir detection when in subdir of gitdirSZEDER Gábor2009-01-17
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the current working directory is a subdirectory of the gitdir (e.g. <repo>/.git/refs/), then setup_git_directory_gently() will climb its parent directories until it finds itself in a gitdir. However, no matter how many parent directories it climbs, it sets 'GIT_DIR_ENVIRONMENT' to ".", which is obviously wrong. This behaviour affected at least 'git rev-parse --git-dir' and hence caused some errors in bash completion (e.g. customized command prompt when on a detached head and completion of refs). To fix this, we set the absolute path of the found gitdir instead. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Always show which directory is not a git repositoryRichard Hartmann2008-12-21
| | | | | | | | | | | | | | | | | | | | | | Unify all fatal: Not a git repository error messages so they include path information. Signed-off-by: Richard Hartmann <richih@net.in.tum.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Make chdir failures visibleAlex Riesen2008-12-04
|/ | | | | Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* make prefix_path() never return NULLDmitry Potapov2008-10-06
| | | | | | | | | | | | | | | | There are 9 places where prefix_path is called, and only in one of them the returned pointer was checked to be non-zero and only to call exit(128) as it is usually done by die(). In other 8 places, the returned value was not checked and it caused SIGSEGV when a path outside of the working tree was used. For instance, running git update-index --add /some/path/outside caused SIGSEGV. This patch changes prefix_path() to die if the path is outside of the repository, so it never returns NULL. Signed-off-by: Dmitry Potapov <dpotapov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* setup_git_directory(): fix move to worktree toplevel directoryNguyễn Thái Ngọc Duy2008-08-30
| | | | | | | | | | | | | When setup_git_directory() returns successfully, it is supposed to move current working directory to worktree toplevel directory. However, the code recomputing prefix inside setup_git_directory() has to move cwd back to original working directory, in order to get new prefix. After that, it should move cwd back to worktree toplevel directory as expected. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'dr/ceiling'Junio C Hamano2008-07-07
|\ | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * Eliminate an unnecessary chdir("..")David Reiss2008-05-23
| | | | | | | | | | | | | | | | 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>
| * Add support for GIT_CEILING_DIRECTORIESDavid Reiss2008-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'j6t/mingw'Junio C Hamano2008-07-02
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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(). ...
| * | Windows: Treat Windows style path names.Johannes Sixt2008-06-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | setup.c: Prepare for Windows directory separators.Johannes Sixt2008-06-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Make git_dir a path relative to work_tree in setup_work_tree()Linus Torvalds2008-06-19
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Provide git_config with a callback-data parameterJohannes Schindelin2008-05-14
|/ | | | | | | | | | | | 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>
* Merge branch 'lh/git-file'Junio C Hamano2008-05-05
|\ | | | | | | | | | | | | | | * 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"
| * Add platform-independent .git "symlink"Lars Hjemli2008-04-09
| | | | | | | | | | | | | | | | | | 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>
* | Make core.sharedRepository more genericHeikki Orsila2008-04-16
|/ | | | | | | | | | | | | | | 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>
* Always set *nongit_ok in setup_git_directory_gently()SZEDER Gábor2008-03-26
| | | | | | | | | | | | 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>
* get_pathspec(): die when an out-of-tree path is givenJunio C Hamano2008-03-07
| | | | | | | | | | | | | | | | | | | | | | 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>
* Avoid unnecessary "if-before-free" tests.Jim Meyering2008-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* prefix_path: use is_absolute_path() instead of *orig == '/'Johannes Sixt2008-02-20
| | | | | Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jc/setup'Junio C Hamano2008-02-20
|\ | | | | | | | | | | | | | | * 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()
| * setup: sanitize absolute and funny paths in get_pathspec()Junio C Hamano2008-02-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | setup.c: guard config parser from value=NULLJunio C Hamano2008-02-11
|/ | | | | | core.worktree expects a string value Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix grammar nits in documentation and in code comments.Jim Meyering2008-01-03
| | | | | Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Remove repo version check from setup_git_directoryNguyễn Thái Ngọc Duy2007-12-09
| | | | | | | 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>
* Merge branch 'maint'Junio C Hamano2007-12-05
|\ | | | | | | | | | | | | | | | | * maint: git-am -i: report rewritten title git grep shows the same hit repeatedly for unmerged paths Do check_repository_format() early (re-fix) Do check_repository_format() early Add missing inside_work_tree setting in setup_git_directory_gently
| * Do check_repository_format() early (re-fix)Nguyễn Thái Ngọc Duy2007-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This pushes check_repository_format() (actually _gently() version) to setup_git_directory_gently() in order to prevent from using unsupported repositories. New setup_git_directory_gently()'s behaviour is stop searching for a valid gitdir and return as if there is no gitdir if a unsupported repository is found. Warning will be thrown in these cases. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Do check_repository_format() earlyNguyễn Thái Ngọc Duy2007-11-30
| | | | | | | | | | | | | | | | | | | | Repository version check is only performed when setup_git_directory() is called. This makes sure setup_git_directory_gently() does the check too. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Add missing inside_work_tree setting in setup_git_directory_gentlyNguyễn Thái Ngọc Duy2007-11-03
| | | | | | | | | | | | | | | | | | | | | | | | | | When both GIT_DIR and GIT_WORK_TREE are set, and setup_git_directory_gently() changes the current working directory accordingly, it should also set inside_work_tree = 1. Without this, work_tree handling code in setup_git_directory() will be activated. If you stay in root work tree (no prefix), it does not harm. It does if you work from a subdirectory though. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Use is_absolute_path() in diff-lib.c, lockfile.c, setup.c, trace.cSteffen Prohaska2007-11-26
| | | | | | | | | | | | | | Using the helper function to test for absolute paths makes porting easier. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-blame: set up the work_tree before the first file accessJohannes Schindelin2007-11-09
| | | | | | | | | | | | | | | | | | | | | | We check in cmd_blame() if the specified path is there, but we failed to set up the working tree before that. While at it, make setup_work_tree() just return if it was run before. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Style: place opening brace of a function definition at column 1Junio C Hamano2007-11-08
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Refactor working tree setupMike Hommey2007-11-05
|/ | | | | | | | | Create a setup_work_tree() that can be used from any command requiring a working tree conditionally. Signed-off-by: Mike Hommey <mh@glandium.org> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix setup_git_directory_gently() with relative GIT_DIR & GIT_WORK_TREEJohannes Schindelin2007-10-16
| | | | | | | | | | | | | | | | | There are a few programs, such as config and diff, which allow running without a git repository. Therefore, they have to call setup_git_directory_gently(). However, when GIT_DIR and GIT_WORK_TREE were set, and the current directory was a subdirectory of the work tree, setup_git_directory_gently() would return a bogus NULL prefix. This patch fixes that. Noticed by REPLeffect on IRC. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unsetJohannes Schindelin2007-08-10
| | | | | | | | | The old behaviour was to unilaterally default to the cwd is the work tree when GIT_DIR was set, but GIT_WORK_TREE wasn't, no matter if we are inside the GIT_DIR, or if GIT_DIR is actually something like ../../../.git. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'maint'Junio C Hamano2007-08-06
|\ | | | | | | | | | | * maint: apply: remove directory that becomes empty by renaming the last file away setup.c:verify_non_filename(): don't die unnecessarily while disambiguating