summaryrefslogtreecommitdiff
path: root/git.c
AgeCommit message (Collapse)AuthorFilesLines
2010-10-08Use angles for placeholders consistentlyLibravatar Štěpán Němec1-4/+4
Signed-off-by: Štěpán Němec <stepnem@gmail.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-08Merge branch 'tf/cleanup-builtin-help-headers'Libravatar Junio C Hamano1-1/+2
* tf/cleanup-builtin-help-headers: builtin.h: Move two functions definitions to help.h.
2010-09-08Merge branch 'kf/askpass-config'Libravatar Junio C Hamano1-3/+0
* kf/askpass-config: Extend documentation of core.askpass and GIT_ASKPASS. Allow core.askpass to override SSH_ASKPASS. Add a new option 'core.askpass'.
2010-09-08Merge branch 'jk/maint-pass-c-config-in-env'Libravatar Junio C Hamano1-1/+1
* jk/maint-pass-c-config-in-env: do not pass "git -c foo=bar" params to transport helpers pass "git -c foo=bar" params through environment
2010-09-01builtin.h: Move two functions definitions to help.h.Libravatar Thiago Farina1-1/+2
The two functions defined here are implemented in help.c, so makes more sense to put the definition of those in help.h instead of in builtin.h. Signed-off-by: Thiago Farina <tfransosi@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-31Merge branch 'jn/paginate-fix'Libravatar Junio C Hamano1-15/+23
* jn/paginate-fix: t7006 (pager): add missing TTY prerequisites merge-file: run setup_git_directory_gently() sooner var: run setup_git_directory_gently() sooner ls-remote: run setup_git_directory_gently() sooner index-pack: run setup_git_directory_gently() sooner config: run setup_git_directory_gently() sooner bundle: run setup_git_directory_gently() sooner apply: run setup_git_directory_gently() sooner grep: run setup_git_directory_gently() sooner shortlog: run setup_git_directory_gently() sooner git wrapper: allow setup_git_directory_gently() be called earlier setup: remember whether repository was found git wrapper: introduce startup_info struct Conflicts: builtin/index-pack.c
2010-08-31Allow core.askpass to override SSH_ASKPASS.Libravatar Knut Franke1-3/+0
Modify handling of the 'core.askpass' option so that it has the same effect as GIT_ASKPASS also if SSH_ASKPASS is set. Signed-off-by: Knut Franke <k.franke@science-computing.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-26Merge branch 'maint'Libravatar Junio C Hamano1-3/+3
* maint: for-each-ref: fix objectname:short bug tree-walk: Correct bitrotted comment about tree_entry() Fix 'git log' early pager startup error case
2010-08-25Fix 'git log' early pager startup error caseLibravatar Linus Torvalds1-3/+3
We start the pager too early for several git commands, which results in the errors sometimes going to the pager rather than show up as errors. This is often hidden by the fact that we pass in '-X' to less by default, which causes 'less' to exit for small output, but if you do export LESS=-S you can then clearly see the problem by doing git log --prretty which shows the error message ("fatal: unrecognized argument: --prretty") being sent to the pager. This happens for pretty much all git commands that use USE_PAGER, and then check arguments separately. But "git diff" does it too early too (even though it does an explicit setup_pager() call) This only fixes it for the trivial "git log" family case. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-24pass "git -c foo=bar" params through environmentLibravatar Jeff King1-1/+1
Git uses the "-c foo=bar" parameters to set a config variable for a single git invocation. We currently do this by making a list in the current process and consulting that list in git_config. This works fine for built-ins, but the config changes are silently ignored by subprocesses, including dashed externals and invocations to "git config" from shell scripts. This patch instead puts them in an environment variable which we consult when looking at config (both internally and via calls "git config"). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-21Merge branch 'gb/split-cmdline-errmsg'Libravatar Junio C Hamano1-1/+2
* gb/split-cmdline-errmsg: split_cmdline: Allow caller to access error string
2010-08-15merge-file: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
Part of a campaign to make repository-local configuration available early (simplifying the startup sequence for built-in commands). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15var: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
Part of a campaign to make repository-local configuration available early (simplifying the startup sequence for built-in commands). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15ls-remote: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-2/+2
ls-remote already runs a repository search unconditionally to learn about remote nicknames and "[url] insteadof" shortcuts. Run that search a little sooner, and now one can try [pager] ls-remote to automatically paginate ls-remote output, or use repository-local [core] pager = whatever with "git --paginate ls-remote <url>". Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15index-pack: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
index-pack already runs a repository search unconditionally; running such a search earlier is not risky and ensures GIT_DIR will be set correctly if the configuration needs to be accessed from run_builtin(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15config: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-2/+2
For the pager choice (and the choice to paginate) to reflect the current repository configuration, the repository needs to be located first. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15bundle: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
Without this change, “git -p bundle” does not always respect the repository-local “[core] pager” setting. It is hard to notice because subcommands other than “git bundle unbundle” do not produce much output. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-15apply: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
As v1.7.2~16^2 (2010-07-14) explains, without this change, “git --paginate apply” can ignore the repository-local “[core] pager” configuration. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11split_cmdline: Allow caller to access error stringLibravatar Greg Brockman1-1/+2
This allows the caller to add its own error message to that returned by split_cmdline. Thus error output following a failed split_cmdline can be of the form fatal: Bad alias.test string: cmdline ends with \ rather than error: cmdline ends with \ fatal: Bad alias.test string Signed-off-by: Greg Brockman <gdb@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11grep: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
git grep already runs a repository search unconditionally, even when the --no-index option is supplied; running such a search earlier is not very risky. Just like with shortlog, without this change, the “[pager] grep” configuration is not respected at all. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11shortlog: run setup_git_directory_gently() soonerLibravatar Nguyễn Thái Ngọc Duy1-1/+1
shortlog already runs a repository search unconditionally; running such a search earlier is not very risky. Without this change, the “[pager] shortlog” configuration is not respected at all: “git shortlog” unconditionally paginates. The tests are a bit slow. Running the full battery like this for all built-in commands would be counterproductive; the intent is rather to test shortlog as a representative example command using ..._gently(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11git wrapper: allow setup_git_directory_gently() be called earlierLibravatar Nguyễn Thái Ngọc Duy1-4/+9
In the spirit of v1.4.2-rc3~34^2^2 (Call setup_git_directory() much earlier, 2006-07-28), let run_builtin() take care of searching for a repository for built-ins that want to make use of one if present. So now you can mark your command with RUN_SETUP_GENTLY and use nongit = !startup_info->have_repository; in place of prefix = setup_git_directory_gently(&nongit); and everything will be the same, except the repository is discovered a little sooner. As v1.7.2~16^2 (2010-07-14) explains, this should allow more commands to robustly use features like "git --paginate" that look at local configuration before the command is actually run. This patch sets up the infrastructure. Later patches will teach particular commands to use it. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11git wrapper: introduce startup_info structLibravatar Nguyễn Thái Ngọc Duy1-0/+3
The startup_info struct will collect information managed by the git setup code, such as the prefix for relative paths passed on the command line (i.e., path to the starting cwd from the toplevel of the work tree) and whether a git repository has been found. In other words, startup_info is intended to be a collection of global variables with results that were previously returned from setup functions. This state is global anyway (since the cwd is), even if it is not currently tracked that way. Letting these values persist means there is more flexibility in deciding when to run setup. For now, the struct is empty. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-27Fix 'git' wrapper usage stringLibravatar Thomas Rast1-2/+2
8b1fa77 (Allow passing of configuration parameters in the command line, 2010-03-26) forgot the closing ']' for the -c option. While we're there, also rewrap. Instead of folding the last two lines together, try to highlight that COMMAND is required by starting a line with it. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-15Merge branch 'jn/paginate-fix'Libravatar Junio C Hamano1-1/+4
* jn/paginate-fix: git --paginate: paginate external commands again git --paginate: do not commit pager choice too early tests: local config file should be honored from subdirs of toplevel t7006: test pager configuration for several git commands t7006 (pager): introduce helper for parameterized tests Conflicts: t/t7006-pager.sh
2010-07-14git --paginate: paginate external commands againLibravatar Jonathan Nieder1-0/+3
73e25e7c (git --paginate: do not commit pager choice too early, 2010-06-26) failed to take some cases into account. 1b. Builtins that do not use RUN_SETUP (like git config) do not find GIT_DIR set correctly when the pager is launched from run_builtin(). So the core.pager configuration is not honored from subdirectories of the toplevel for them. 4a. External git commands (like git request-pull) relied on the early pager launch to take care of handling the -p option. Ever since 73e25e7c, they do not honor the -p option at all. 4b. Commands invoked through ! aliases (like ls) were also relying on the early pager launch. Fix (4a) by launching the pager (if requested) before running such a “dashed external”. For simplicity, this still does not search for a .git directory before running the external command; when run from a subdirectory of the toplevel, therefore, the “[core] pager” configuration is still not honored. Fix (4b) by launching pager if requested before carrying out such an alias. Actually doing this has no effect, since the pager (if any) would have already been launched in a failed attempt to try a dashed external first. The choice-of-pager-not-honored-from- subdirectory bug still applies here, too. (1b) is not a regression. There is no need to fix it yet. Noticed by Junio. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-28git --paginate: do not commit pager choice too earlyLibravatar Nguyễn Thái Ngọc Duy1-1/+1
When git is passed the --paginate option, starting up a pager requires deciding what pager to start, which requires access to the core.pager configuration. At the relevant moment, the repository has not been searched for yet. Attempting to access the configuration at this point results in git_dir being set to .git [*], which is almost certainly not what was wanted. In particular, when run from a subdirectory of the toplevel, git --paginate does not respect the core.pager setting from the current repository. [*] unless GIT_DIR or GIT_CONFIG is set So delay the pager startup when possible: 1. run_argv() already commits pager choice inside run_builtin() if a command is found. For commands that use RUN_SETUP, waiting until then fixes the problem described above: once git knows where to look, it happily respects the core.pager setting. 2. list_common_cmds_help() prints out 29 lines and exits. This can benefit from pagination, so we need to commit the pager choice before writing this output. Luckily ‘git’ without subcommand has no other reason to access a repository, so it would be intuitive to ignore repository-local configuration in this case. Simpler for now to choose a pager using the funny code that notices a repository that happens to be at .git. That this accesses a repository when it is very convenient to is a bug but not an important one. 3. help_unknown_cmd() prints out a few lines to stderr. It is not important to paginate this, so don’t. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-13grep: Add the option '--open-files-in-pager'Libravatar Johannes Schindelin1-1/+1
This adds an option to open the matching files in the pager, and if the pager happens to be "less" (or "vi") and there is only one grep pattern, it also jumps to the first match right away. The short option was chose as '-O' to avoid clashes with GNU grep's options (as suggested by Junio). So, 'git grep -O abc' is a short form for 'less +/abc $(grep -l abc)' except that it works also with spaces in file names, and it does not start the pager if there was no matching file. [jn: rebased and added tests; with error handling fix from Junio squashed in] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28Allow passing of configuration parameters in the command lineLibravatar Alex Riesen1-0/+9
The values passed this way will override whatever is defined in the config files. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-15Merge branch 'jh/notes'Libravatar Junio C Hamano1-0/+1
* jh/notes: (33 commits) Documentation: fix a few typos in git-notes.txt notes: fix malformed tree entry builtin-notes: Minor (mostly parse_options-related) fixes builtin-notes: Add "copy" subcommand for copying notes between objects builtin-notes: Misc. refactoring of argc and exit value handling builtin-notes: Add -c/-C options for reusing notes builtin-notes: Refactor handling of -F option to allow combining -m and -F builtin-notes: Deprecate the -m/-F options for "git notes edit" builtin-notes: Add "append" subcommand for appending to note objects builtin-notes: Add "add" subcommand for adding notes to objects builtin-notes: Add --message/--file aliases for -m/-F options builtin-notes: Add "list" subcommand for listing note objects Documentation: Generalize git-notes docs to 'objects' instead of 'commits' builtin-notes: Add "prune" subcommand for removing notes for missing objects Notes API: prune_notes(): Prune notes that belong to non-existing objects t3305: Verify that removing notes triggers automatic fanout consolidation builtin-notes: Add "remove" subcommand for removing existing notes Teach builtin-notes to remove empty notes Teach notes code to properly preserve non-notes in the notes tree t3305: Verify that adding many notes with git-notes triggers increased fanout ... Conflicts: Makefile
2010-03-02fallback SSH_ASKPASS when GIT_ASKPASS not setLibravatar Frank Li1-0/+3
If GIT_ASKPASS is not set and SSH_ASKPASS set, GIT_ASKPASS will use SSH_ASKPASS. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-16Merge branch 'maint'Libravatar Junio C Hamano1-1/+1
* maint: Prepare 1.7.0.1 release notes Fix use of mutex in threaded grep dwim_ref: fix dangling symref warning stash pop: remove 'apply' options during 'drop' invocation diff: make sure --output=/bad/path is caught Remove hyphen from "git-command" in two error messages
2010-02-16Merge branch 'maint-1.6.6' into maintLibravatar Junio C Hamano1-1/+1
* maint-1.6.6: dwim_ref: fix dangling symref warning stash pop: remove 'apply' options during 'drop' invocation diff: make sure --output=/bad/path is caught Remove hyphen from "git-command" in two error messages
2010-02-15Remove hyphen from "git-command" in two error messagesLibravatar Pete Harlan1-1/+1
Signed-off-by: Pete Harlan <pgit@pcharlan.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-13Builtin-ify git-notesLibravatar Johan Herland1-0/+1
The builtin-ification includes some minor behavioural changes to the command-line interface: It is no longer allowed to mix the -m and -F arguments, and it is not allowed to use multiple -F options. As part of the builtin-ification, we add the commit_notes() function to the builtin API. This function (together with the notes.h API) can be easily used from other builtins to manipulate the notes tree. Also includes needed changes to t3301. This patch has been improved by the following contributions: - Stephen Boyd: Use die() instead of fprintf(stderr, ...) followed by exit(1) Cc: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-13Resurrect "git grep --no-index"Libravatar Junio C Hamano1-1/+1
This reverts commit 3c8f6c8 (Revert 30816237 and 7e62265, 2010-02-05) as the issue has been sorted out.
2010-02-05Revert 30816237 and 7e62265Libravatar Junio C Hamano1-1/+1
It seems that we have bad interaction with the code related to GIT_WORK_TREE and "grep --no-index", and broke running grep inside the .git directory. For now, just revert it and resurrect it after 1.7.0 ships. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "index-pack" a built-inLibravatar Linus Torvalds1-0/+1
This required some fairly trivial packfile function 'const' cleanup, since the builtin commands get a const char *argv[] array. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "git pack-redundant" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "git unpack-file" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "mktag" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22make "merge-index" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-21make "git patch-id" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-21make "git var" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-21make "git hash-object" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-21make "git merge-tree" a built-inLibravatar Linus Torvalds1-0/+1
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-20Merge branch 'ap/merge-backend-opts'Libravatar Junio C Hamano1-0/+2
* ap/merge-backend-opts: Document that merge strategies can now take their own options Extend merge-subtree tests to test -Xsubtree=dir. Make "subtree" part more orthogonal to the rest of merge-recursive. pull: Fix parsing of -X<option> Teach git-pull to pass -X<option> to git-merge git merge -X<option> git-merge-file --ours, --theirs Conflicts: git-compat-util.h
2010-01-17git merge -X<option>Libravatar Avery Pennarun1-0/+2
Teach "-X <option>" command line argument to "git merge" that is passed to strategy implementations. "ours" and "theirs" autoresolution introduced by the previous commit can be asked to the recursive strategy. Signed-off-by: Avery Pennarun <apenwarr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15grep: prepare to run outside of a work treeLibravatar Junio C Hamano1-1/+1
This moves the call to setup_git_directory() for running "grep" from the "git" wrapper to the implementation of the "grep" subcommand. A new variable "use_index" is always true at this stage in the series, and when it is on, we require that we are in a directory that is under git control. To make sure we die the same way, we make a second call into setup_git_directory() when we detect this situation. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-23Merge branch 'cc/replace'Libravatar Junio C Hamano1-0/+3
* cc/replace: Documentation: talk a little bit about GIT_NO_REPLACE_OBJECTS Documentation: fix typos and spelling in replace documentation replace: use a GIT_NO_REPLACE_OBJECTS env variable