summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2011-04-03Merge branch 'jc/index-update-if-able' into maintLibravatar Junio C Hamano2-13/+3
* jc/index-update-if-able: update $GIT_INDEX_FILE when there are racily clean entries diff/status: refactor opportunistic index update
2011-04-03Merge branch 'lt/default-abbrev' into maintLibravatar Junio C Hamano1-1/+5
* lt/default-abbrev: Rename core.abbrevlength back to core.abbrev Make the default abbrev length configurable
2011-04-03Merge branch 'mm/maint-log-n-with-diff-filtering' into maintLibravatar Junio C Hamano1-1/+7
* mm/maint-log-n-with-diff-filtering: log: fix --max-count when used together with -S or -G
2011-04-03Merge branch 'lp/config-vername-check' into maintLibravatar Junio C Hamano1-7/+20
* lp/config-vername-check: Disallow empty section and variable names Sanity-check config variable names
2011-04-01Merge branch 'jc/maint-apply-report-offset' into maintLibravatar Junio C Hamano1-2/+14
* jc/maint-apply-report-offset: apply -v: show offset count when patch did not apply exactly
2011-04-01Merge branch 'jc/maint-apply-no-double-patch' into maintLibravatar Junio C Hamano1-1/+6
* jc/maint-apply-no-double-patch: apply: do not patch lines that were already patched
2011-04-01Merge "checkout ambiguous ref bugfix" into maintLibravatar Junio C Hamano1-10/+13
* commit '0cb6ad3': checkout: fix bug with ambiguous refs
2011-03-28grep: Add the option '--line-number'Libravatar Joe Ratterman1-1/+1
This is a synonym for the existing '-n' option, matching GNU grep. Signed-off-by: Joe Ratterman <jratt0@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-21diff/status: refactor opportunistic index updateLibravatar Junio C Hamano2-13/+3
When we had to refresh the index internally before running diff or status, we opportunistically updated the $GIT_INDEX_FILE so that later invocation of git can use the lstat(2) we already did in this invocation. Make them share a helper function to do so. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16Merge branch 'jn/maint-commit-missing-template' into maintLibravatar Junio C Hamano1-1/+1
* jn/maint-commit-missing-template: commit: error out for missing commit message template
2011-03-16Merge branch 'lt/rename-no-extra-copy-detection' into maintLibravatar Junio C Hamano1-2/+2
* lt/rename-no-extra-copy-detection: diffcore-rename: improve estimate_similarity() heuristics diffcore-rename: properly honor the difference between -M and -C for_each_hash: allow passing a 'void *data' pointer to callback
2011-03-16Merge branch 'jk/fail-null-clone' into maintLibravatar Junio C Hamano1-1/+1
* jk/fail-null-clone: clone: die when trying to clone missing local path
2011-03-16Merge branch 'jh/push-default-upstream-configname' into maintLibravatar Junio C Hamano1-5/+5
* jh/push-default-upstream-configname: push.default: Rename 'tracking' to 'upstream'
2011-03-16Merge branch 'mg/placeholders-are-lowercase' into maintLibravatar Junio C Hamano8-25/+25
* mg/placeholders-are-lowercase: Make <identifier> lowercase in Documentation Make <identifier> lowercase as per CodingGuidelines Make <identifier> lowercase as per CodingGuidelines Make <identifier> lowercase as per CodingGuidelines CodingGuidelines: downcase placeholders in usage messages
2011-03-16Merge branch 'mg/patch-id' into maintLibravatar Junio C Hamano1-0/+2
* mg/patch-id: git-patch-id: do not trip over "no newline" markers git-patch-id: test for "no newline" markers
2011-03-16Merge branch 'js/maint-merge-use-prepare-commit-msg-hook' into maintLibravatar Junio C Hamano1-8/+29
* js/maint-merge-use-prepare-commit-msg-hook: merge: honor prepare-commit-msg hook
2011-03-16cherry: split off function to print output linesLibravatar Jonathan Nieder1-16/+18
Readers uninterested in the details of "git cherry"'s output format can see print_commit('-', commit, verbose, abbrev); and ignore the details. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16branch: split off function that writes tracking info and commit subjectLibravatar Jonathan Nieder1-21/+27
Introduce a add_verbose_info function that takes care of adding - an abbreviated object name; - a summary of the form [ahead x, behind y] of the relationship to the corresponding upstream branch; - a one line commit subject for the tip commit of a branch, for use in "git branch -v" output. No functional change intended. This just unindents the code a little and makes it easier to skip on first reading. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16standardize brace placement in struct definitionsLibravatar Jonathan Nieder4-10/+5
In a struct definitions, unlike functions, the prevailing style is for the opening brace to go on the same line as the struct name, like so: struct foo { int bar; char *baz; }; Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many matches as 'struct [a-z_]*$'. Linus sayeth: Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are _right_ and (b) K&R are right. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-11Make the default abbrev length configurableLibravatar Linus Torvalds1-1/+5
The default of 7 comes from fairly early in git development, when seven hex digits was a lot (it covers about 250+ million hash values). Back then I thought that 65k revisions was a lot (it was what we were about to hit in BK), and each revision tends to be about 5-10 new objects or so, so a million objects was a big number. These days, the kernel isn't even the largest git project, and even the kernel has about 220k revisions (_much_ bigger than the BK tree ever was) and we are approaching two million objects. At that point, seven hex digits is still unique for a lot of them, but when we're talking about just two orders of magnitude difference between number of objects and the hash size, there _will_ be collisions in truncated hash values. It's no longer even close to unrealistic - it happens all the time. We should both increase the default abbrev that was unrealistically small, _and_ add a way for people to set their own default per-project in the git config file. This is the first step to first make it configurable; the default of 7 is not raised yet. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-09log: fix --max-count when used together with -S or -GLibravatar Matthieu Moy1-1/+7
The --max-count limit is implemented by counting revisions in get_revision(), but the -S and -G take effect later when running diff. Hence "--max-count=10 -Sfoo" meant "examine the 10 first revisions, and out of them, show only those changing the occurences of foo", not "show 10 revisions changing the occurences of foo". In case the commit isn't actually shown, cancel the decrement of max_count. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-06apply -v: show offset count when patch did not apply exactlyLibravatar Junio C Hamano1-2/+14
When the line number the patch intended to touch does not match the line in the version being patched, GNU patch reports that it applied the hunk at a different line number, with how big an offset. Teach "git apply" to do the same under --verbose option. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-04apply: do not patch lines that were already patchedLibravatar Junio C Hamano1-1/+6
When looking for a place to apply a hunk, we used to check lines that match the preimage of it, starting from the line that the patch wants to apply the hunk at, looking forward and backward with increasing offsets until we find a match. Colin Guthrie found an interesting case where this misapplied a patch that wanted to touch a preimage that consists of } } return 0; } which is a rather unfortunately common pattern. The target version of the file originally had only one such location, but the hunk immediately before that created another instance of such block of lines, and find_pos() happily reported that the preimage of the hunk matched what it wanted to modify. Oops. By marking the lines application of earlier hunks touched and preventing match_fragment() from considering them as a match with preimage of other hunks, we can reduce such an accident. I also considered to teach apply_one_fragment() to take the offset we have found while applying the previous hunk into account when looking for a match with find_pos(), but dismissed that approach, because it would sometimes work better but sometimes worse, depending on the difference between the version the patch was created against and the version the patch is being applied. This does _not_ prevent misapplication of patches to a file that has many similar looking blocks of lines and a preimage cannot identify which one of them should be applied. For that, we would need to scan beyond the first match in find_pos(), and issue a warning (or error out). That will be a separate topic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-03init: remove unnecessary checkLibravatar Nguyễn Thái Ngọc Duy1-7/+5
git_dir must always be non-NULL so "if (git_dir)" is unnecessary. Before this code, if git_dir == NULL, it will default to DEFAULT_GIT_DIR_ENVIRONMENT. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-27branch_merged: fix grammar in warningLibravatar Eric Hanchrow1-1/+1
Signed-off-by: Eric Hanchrow <eric.hanchrow@gmail.com> Helped-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-25commit: error out for missing commit message templateLibravatar Jonathan Nieder1-1/+1
When "git commit" was rewritten in C (v1.5.4-rc0~78^2~30, 2007-11-08), a subtle bug in --template was introduced. If the file named by a --template parameter is missing, previously git would error out with a message: Commit template file does not exist. but in the C version the --template parameter gets ignored and the default template is used. t7500 has two tests for this case which would have caught it, except that with the default $EDITOR, the commit message template is left unmodified, causing 'git commit' to error out and the test to succeed. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-22Sanity-check config variable namesLibravatar Libor Pechacek1-7/+20
Sanity-check config variable names when adding and retrieving them. As a side effect code duplication between git_config_set_multivar and get_value (in builtin/config.c) was removed and the common functionality was placed in git_config_parse_key. This breaks a test in t1300 which used invalid section-less keys in the tests for "git -c". However, allowing such names there was useless, since there was no way to set them via config file, and no part of git actually tried to use section-less keys. This patch updates the test to use more realistic examples as well as adding its own test. Signed-off-by: Libor Pechacek <lpechacek@suse.cz> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-18for_each_hash: allow passing a 'void *data' pointer to callbackLibravatar Linus Torvalds1-2/+2
For the find_exact_renames() function, this allows us to pass the diff_options structure pointer to the low-level routines. We will use that to distinguish between the "rename" and "copy" cases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-18clone: die when trying to clone missing local pathLibravatar Jeff King1-1/+1
Since 86ac751 (Allow cloning an empty repository, 2009-01-23), doing: git clone does-not-exist has created does-not-exist as an empty repository. This was an unintentional side effect of 86ac751. Even weirder, doing: git clone does-not-exist new-dir _does_ fail, making this "feature" (if you want to consider it such) broken. Let's detect this situation and explicitly die. It's almost certainly not what the user intended. This patch also adds two tests. One for the missing path case, and one to confirm that a similar case, cloning a non-repository directory, fails. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-17git-patch-id: do not trip over "no newline" markersLibravatar Michael J Gruber1-0/+2
Currently, patch-id trips over our very own diff extension for marking the absence of newline at EOF. Fix it. (Ignore it, it's whitespace.) Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-16push.default: Rename 'tracking' to 'upstream'Libravatar Johan Herland1-5/+5
Users are sometimes confused with two different types of "tracking" behavior in Git: "remote-tracking" branches (e.g. refs/remotes/*/*) versus the merge/rebase relationship between a local branch and its @{upstream} (controlled by branch.foo.remote and branch.foo.merge config settings). When the push.default is set to 'tracking', it specifies that a branch should be pushed to its @{upstream} branch. In other words, setting push.default to 'tracking' applies only to the latter of the above two types of "tracking" behavior. In order to make this more understandable to the user, we rename the push.default == 'tracking' option to push.default == 'upstream'. push.default == 'tracking' is left as a deprecated synonym for 'upstream'. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15merge: honor prepare-commit-msg hookLibravatar Jay Soffian1-8/+29
When a merge is stopped due to conflicts or --no-commit, the subsequent commit calls the prepare-commit-msg hook. However, it is not called after a clean merge. Fix this inconsistency by invoking the hook after clean merges as well. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15Make <identifier> lowercase as per CodingGuidelinesLibravatar Michael J Gruber8-25/+25
*.c part for matches with '"[A-Z]+"'. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15commit,status: describe -u likewiseLibravatar Michael J Gruber1-1/+1
They differ by one character only. Being exactly equal should help translations. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15add: describe --patch like checkout, resetLibravatar Michael J Gruber1-1/+1
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15commit,merge,tag: describe -m likewiseLibravatar Michael J Gruber3-5/+5
This also removes the superfluous "specify" and rewords the misleading "if any" which sounds as if omitting "-m" would omit the merge commit message. (It means "if a merge commit is created at all".) Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15clone,init: describe --template using the same wordingLibravatar Michael J Gruber2-3/+3
This also corrects a wrong description for clone. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15commit,status: describe --porcelain just like pushLibravatar Michael J Gruber1-2/+2
Push has the clearer description, so take that one for all. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-15commit,tag: use same wording for -FLibravatar Michael J Gruber2-2/+2
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-14correct type of EMPTY_TREE_SHA1_BINLibravatar Jonathan Nieder1-1/+1
Functions such as hashcmp that expect a binary SHA-1 value take parameters of type "unsigned char *" to avoid accepting a textual SHA-1 passed by mistake. Unfortunately, this means passing the string literal EMPTY_TREE_SHA1_BIN requires an ugly cast. Tweak the definition of EMPTY_TREE_SHA1_BIN to produce a value of more convenient type. In the future the definition might change to extern const unsigned char empty_tree_sha1_bin[20]; #define EMPTY_TREE_SHA1_BIN empty_tree_sha1_bin Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-11Merge branch 'jc/fsck-fixes' into maintLibravatar Junio C Hamano1-9/+22
* jc/fsck-fixes: fsck: do not give up too early in fsck_dir() fsck: drop unused parameter from traverse_one_object()
2011-02-11clone: fixup recurse_submodules optionLibravatar Chris Packham1-1/+1
The recurse_submodules option was added in ccdd3da6 to bring 'git clone' into line with 'git fetch' and future commands. The correct option should have been "recurse-submodules". Signed-off-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-07diff: support --cached on unborn branchesLibravatar Nguyễn Thái Ngọc Duy1-2/+5
"git diff --cached" (without revision) used to mean "git diff --cached HEAD" (i.e. the user was too lazy to type HEAD). This "correctly" failed when there was no commit yet. But was that correctness useful? This patch changes the definition of what particular command means. It is a request to show what _would_ be committed without further "git add". The internal implementation is the same "git diff --cached HEAD" when HEAD exists, but when there is no commit yet, it compares the index with an empty tree object to achieve the desired result. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-27fsck: do not give up too early in fsck_dir()Libravatar Junio C Hamano1-6/+12
When there is a random garbage file whose name happens to be 38-byte long in a .git/objects/??/ directory, the loop terminated prematurely without marking all the other files that it hasn't checked in the readdir() loop. Treat such a file just like any other garbage file, and do not break out of the readdir() loop. While at it, replace repeated sprintf() calls to a single one outside the loop. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-27fsck: drop unused parameter from traverse_one_object()Libravatar Junio C Hamano1-3/+10
Also add comments to seemingly unsafe pointer dereferences, that are all safe. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-19Merge branch 'ak/describe-exact' into maintLibravatar Junio C Hamano1-25/+60
* ak/describe-exact: describe: Delay looking up commits until searching for an inexact match describe: Store commit_names in a hash table by commit SHA1 describe: Do not use a flex array in struct commit_name describe: Use for_each_rawref
2011-01-18remote-ext: do not segfault for blank linesLibravatar Jonathan Nieder1-4/+4
Instead of stripping space characters past the beginning of the line and overflowing a buffer, stop at the beginning of the line (mimicking the corresponding fix in remote-fd). The argument to isspace does not need to be cast explicitly because git isspace takes care of that already. Noticed-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-12Merge branch 'maint'Libravatar Junio C Hamano1-2/+2
* maint: commit: suggest --amend --reset-author to fix commiter identity
2011-01-12commit: suggest --amend --reset-author to fix commiter identityLibravatar Matthieu Moy1-2/+2
Since the message advises to fix the configuration first, the advantage of using this command is that it is cut-and-paste ready, while using --author='...' requires the user to type his name and email again. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-11checkout: fix bug with ambiguous refsLibravatar Junio C Hamano1-10/+13
The usual dwim_ref lookup prefers tags to branches. Because checkout primarily works on branches, though, we switch that behavior to prefer branches. However, there was a bug in the implementation in which we used lookup_commit_reference (which used the regular lookup rules) to get the actual commit to checkout. Checking out an ambiguous ref therefore ended up putting us in an extremely broken state in which we wrote the branch ref into HEAD, but actually checked out the tree for the tag. This patch fixes the bug by always attempting to pull the commit to be checked out from the branch-ified version of the name we were given. Patch by Junio, tests and commit message from Jeff King. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>