AgeCommit message (Collapse)Author
2008-02-26Improve collection of information for format-patch --cover-letterDaniel Barkalow
Use the "boundary" feature to find the origin (or find that there are multiple origins), and use the actual list of commits to pass to shortlog. This makes all cover letter include shortlogs, and all cover letters for series with a single boundary commit include diffstats (if there are multiple boundary commits it's unclear what would be meaningful as a diffstat). Note that the single boundary test is empirical, not theoretical; even a -2 limiting condition will give a diffstat if there's only one boundary commit in this particular case. Signed-off-by: Daniel Barkalow <>
2008-02-26Add API access to shortlogDaniel Barkalow
Shortlog is gives a pretty simple API for cases where you're already identifying all of the individual commits. Make this available to other code instead of requiring them to use the revision API and command line. Signed-off-by: Daniel Barkalow <>
2008-02-25Add tests for filesystem challenges (case and unicode normalization)Steffen Prohaska
Git has difficulties on file systems that do not properly distinguish case or modify filenames in unexpected ways. The two major examples are Windows and Mac OS X. Both systems preserve case of file names but do not distinguish between filenames that differ only by case. Simple operations such as "git mv" or "git merge" can fail unexpectedly. In addition, Mac OS X normalizes unicode, which make git's life even harder. This commit adds tests that currently fail but should pass if file system as decribed above are fully supported. The test need to be run on Windows and Mac X as they already pass on Linux. Mitch Tishmack is the original author of the tests for unicode normalization. [jc: fixed-up so that it will use test_expect_success to test on sanely behaving filesystems.] Signed-off-by: Steffen Prohaska <> Signed-off-by: Junio C Hamano <>
2008-02-25Use a single implementation and API for copy_file()Daniel Barkalow
Originally by Kristian Hï¿œgsberg; I fixed the conversion of rerere, which had a different API. Signed-off-by: Daniel Barkalow <> Signed-off-by: Junio C Hamano <>
2008-02-25Documentation/git-filter-branch: add a new msg-filter exampleMiklos Vajna
There were no example on how to edit commit messages, so add an msg-filter example. Signed-off-by: Miklos Vajna <> Signed-off-by: Junio C Hamano <>
2008-02-25url rewriting: take longest and first matchJunio C Hamano
Earlier we had a cop-out in the documentation to make the behaviour "undefined" if configuration had more than one insteadOf that would match the target URL, like this: [url "git://"] insteadOf = "" ; (1) insteadOf = "" ; (2) [url "/local/mirror/"] insteadOf = "" ; (3) insteadOf = "" ; (4) It would be most natural to take the longest and first match, i.e. - rewrite "" to "git://" by using (1), - rewrite "" to "/local/mirror/xyzzy" by favoring (3) over (1), and - rewrite "" to "git://" by favoring (2) over (4). Signed-off-by: Junio C Hamano <>
2008-02-25Correct fast-export file mode strings to match fast-import standardShawn O. Pearce
The fast-import file format does not expect leading '0' in front of a file mode; that is we want '100644' and '0100644'. Thanks to Ian Clatworthy of the Bazaar project for noticing the difference in output/input. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-25Add support for url aliases in config filesDaniel Barkalow
This allows users with different preferences for access methods to the same remote repositories to rewrite each other's URLs by pattern matching across a large set of similiarly set up repositories to each get the desired access. For example, if you don't have a account, you might want settings like: [url "git://"] insteadOf = Then, if you give git a URL like: it will act like you gave it: git:// and you can cut-and-paste pull requests in email without fixing them by hand, for example. Signed-off-by: Daniel Barkalow <> Signed-off-by: Junio C Hamano <>
2008-02-25git-bundle.txt: Add different strategies to create the bundleSanti Béjar
Signed-off-by: Santi Béjar <> Signed-off-by: Junio C Hamano <>
2008-02-25builtin-for-each-ref.c: fix typo in error messageMichele Ballabio
Signed-off-by: Michele Ballabio <> Signed-off-by: Junio C Hamano <>
2008-02-25help: respect aliasesJeff King
If we have an alias "foo" defined, then the help text for "foo" (via "git help foo" or "git foo --help") now shows the definition of the alias. Before showing an alias definition, we make sure that there is no git command which would override the alias (so that even though you may have a "log" alias, even though it will not work, we don't want to it supersede "git help log"). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-25make alias lookup a public, procedural functionJeff King
This converts git_config_alias to the public alias_lookup function. Because of the nature of our config parser, we still have to rely on setting static data. However, that interface is wrapped so that you can just say value = alias_lookup(key); Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-25help: use parseoptJeff King
This patch converts cmd_help to use parseopt, along with a few style cleanups, including: - enum constants are now ALL_CAPS - parse_help_format returns an enum value rather than setting a global as a side effect Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-25send-email: test compose functionalityJeff King
This is just a basic sanity check that --compose works at all. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-25t9001: enhance fake sendmail test harnessJeff King
Previously, the fake.sendmail test harness would write its output to a hardcoded file, allowing only a single message to be tested. Instead, let's have it save the messages for all of its invocations so that we can see which messages were sent, and in which order. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-25Merge branch 'lt/dirstat'Junio C Hamano
* lt/dirstat: diff --dirstat: saner handling of binary and unmerged files Add "--dirstat" for some directory statistics
2008-02-25Eliminate confusing "won't bisect on seeked tree" failureCarl Worth
This error message is very confusing---it doesn't tell the user anything about how to fix the situation. And the actual fix for the situation ("git bisect reset") does a checkout of a potentially random branch, (compared to what the user wants to be on for the bisect she is starting). The simplest way to eliminate the confusion is to just make "git bisect start" do the cleanup itself. There's no significant loss of safety here since we already have a general safety in the form of the reflog. Note: We preserve the warning for any cogito users. We do this by switching from .git/head-name to .git/BISECT_START for the extra state, (which is a more descriptive name anyway). Signed-off-by: Carl Worth <> Signed-off-by: Junio C Hamano <>
2008-02-25diff --dirstat: saner handling of binary and unmerged filesJunio C Hamano
We do not account binary nor unmerged files when --shortstat is asked for (or the summary stat at the end of --stat). The new option --dirstat should work the same way as it is about summarizing the changes of multiple files by adding them up. Signed-off-by: Junio C Hamano <>
2008-02-25Merge branch 'jc/apply-whitespace'Junio C Hamano
* jc/apply-whitespace: ws_fix_copy(): move the whitespace fixing function to ws.c apply: do not barf on patch with too large an offset core.whitespace: cr-at-eol git-apply --whitespace=fix: fix whitespace fuzz introduced by previous run builtin-apply.c: pass ws_rule down to match_fragment() builtin-apply.c: move copy_wsfix() function a bit higher. builtin-apply.c: do not feed copy_wsfix() leading '+' builtin-apply.c: simplify calling site to apply_line() builtin-apply.c: clean-up apply_one_fragment() builtin-apply.c: mark common context lines in lineinfo structure. builtin-apply.c: optimize match_beginning/end processing a bit. builtin-apply.c: make it more line oriented builtin-apply.c: push match-beginning/end logic down builtin-apply.c: restructure "offset" matching builtin-apply.c: refactor small part that matches context
2008-02-24Use git-describe --exact-match in bash prompt on detached HEADShawn O. Pearce
Most of the time when I am on a detached HEAD and I am not doing a rebase or bisect operation the working directory is sitting on a tagged release of the repository. Showing the tag name instead of the commit SHA-1 is much more descriptive and a much better reminder of the state of this working directory. Now that git-describe --exact-match is available as a cheap means of obtaining the exact annotated tag or nothing at all, we can favor the annotated tag name over the abbreviated commit SHA-1. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Teach git-describe --exact-match to avoid expensive tag searchesShawn O. Pearce
Sometimes scripts want (or need) the annotated tag name that exactly matches a specific commit, or no tag at all. In such cases it can be difficult to determine if the output of `git describe $commit` is a real tag name or a tag+abbreviated commit. A common idiom is to run git-describe twice: if test $(git describe $commit) = $(git describe --abbrev=0 $commit) ... but this is a huge waste of time if the caller is just going to pick a different method to describe $commit or abort because it is not exactly an annotated tag. Setting the maximum number of candidates to 0 allows the caller to ask for only a tag that directly points at the supplied commit, or to have git-describe abort if no such item exists. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Avoid accessing non-tag refs in git-describe unless --all is requestedShawn O. Pearce
If we aren't going to use a ref there is no reason for us to open its object from the object database. This avoids opening any of the head commits reachable from refs/heads/ unless they are also reachable through the commit we have been asked to describe and we need to walk through it to find a tag. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Teach git-describe to use peeled ref information when scanning tagsShawn O. Pearce
By using the peeled ref information inside of the packed-refs file we can avoid opening tag objects to obtain the commits they reference. This speeds up git-describe when there are a large number of tags in the repository as we have less objects to parse before we can start commit matching. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Optimize peel_ref for the current ref of a for_each_ref callbackShawn O. Pearce
Currently the only caller of peel_ref is show-ref, which is using this function to show the peeled tag information if it is available from an existing packed-refs file. The call happens during the for_each_ref callback function, so we have the proper struct ref_list already on the call stack but it is not easily available to return the peeled information to the caller. We now save the current struct ref_list item before calling back into the callback function so that future calls to peel_ref from within the callback function can quickly access the current ref. Doing so will save us an lstat() per ref processed as we no longer have to check the filesystem to see if the ref exists as a loose file or is packed. This current ref caching also saves a linear scan of the cached packed refs list. As a micro-optimization we test the address of the passed ref name against the current_ref->name before we go into the much more costly strcmp(). Nearly any caller of peel_ref will be passing us the same string do_for_each_ref passed them, which is current_ref->name. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Merge branch 'maint'Junio C Hamano
* maint: Protect peel_ref fallback case from NULL parse_object result Ensure 'make dist' compiles git-archive.exe on Cygwin
2008-02-24Be more verbose when checkout takes a long timeLinus Torvalds
So I find it irritating when git thinks for a long time without telling me what's taking so long. And by "long time" I definitely mean less than two seconds, which is already way too long for me. This hits me when doing a large pull and the checkout takes a long time, or when just switching to another branch that is old and again checkout takes a while. Now, git read-tree already had support for the "-v" flag that does nice updates about what's going on, but it was delayed by two seconds, and if the thing had already done more than half by then it would be quiet even after that, so in practice it meant that we migth be quiet for up to four seconds. Much too long. So this patch changes the timeout to just one second, which makes it much more palatable to me. The other thing this patch does is that "git checkout" now doesn't disable the "-v" flag when doing its thing, and only disables the output when given the -q flag. When allowing "checkout -m" to fall back to a 3-way merge, the users will see the error message from straight "checkout", so we will tell them that we do fall back to make them look less scary. Signed-off-by: Junio C Hamano <>
2008-02-24Protect peel_ref fallback case from NULL parse_object resultShawn O. Pearce
If the SHA-1 we are requesting the object for does not exist in the object database we get a NULL back. Accessing the type from that is not likely to succeed on any system. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24Ensure 'make dist' compiles git-archive.exe on CygwinShawn O. Pearce
On Cygwin we have to use git-archive.exe as the target, otherwise running 'make dist' does not compile git-archive in the current directory. That may cause 'make dist' to fail on a clean source tree that has never been built before. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2008-02-24checkout: error out when index is unmerged even with -mJunio C Hamano
Even when -m is given to allow fallilng back to 3-way merge while switching branches, we should refuse if the original index is unmerged. Signed-off-by: Junio C Hamano <> Acked-by: Daniel Barkalow <>
2008-02-24t4014: Replace sed's non-standard 'Q' by standard 'q'Steffen Prohaska
t4014 test used GNU extension 'Q' in its sed scripts, but the uses can safely be replaced with 'q'. Among other platforms, sed on Mac OS X 10.4 does not accept the former. Signed-off-by: Steffen Prohaska <> Signed-off-by: Junio C Hamano <>
2008-02-24ws_fix_copy(): move the whitespace fixing function to ws.cJunio C Hamano
This is used by git-apply but we can use it elsewhere by slightly generalizing it. Signed-off-by: Junio C Hamano <>
2008-02-23checkout: show progress when checkout takes long time while switching branchesJunio C Hamano
Signed-off-by: Junio C Hamano <>
2008-02-23gitweb: Fix bugs in git_search_grep_body: it's length(), not len()Jakub Narebski
Use int(<expr>/2) to get integer value for a substring length. Signed-off-by: Jakub Narebski <> Signed-off-by: Junio C Hamano <>
2008-02-23pack-objects: Print a message describing the number of threads for packingBrandon Casey
Signed-off-by: Brandon Casey <> Signed-off-by: Junio C Hamano <>
2008-02-23pack-objects: Add runtime detection of online CPU'sAndreas Ericsson
Packing objects can be done in parallell nowadays, but it's only done if the config option pack.threads is set to a value above 1. Because of that, the code-path used is often not the most optimal one. This patch adds a routine to detect the number of online CPU's at runtime (online_cpus()). When pack.threads (or --threads=) is given a value of 0, the number of threads is set to the number of online CPU's. This feature is also documented. As per Nicolas Pitre's recommendations, the default is still to run pack-objects single-threaded unless explicitly activated, either by configuration or by command line parameter. The routine online_cpus() is a rework of "numcpus.c", written by one Philip Willoughby <>. numcpus.c is in the public domain and can presently be downloaded from Signed-off-by: Andreas Ericsson <> Signed-off-by: Brandon Casey <> Signed-off-by: Junio C Hamano <>
2008-02-23start_command(), if .in/.out > 0, closes file descriptors, not the callersJohannes Sixt
Callers of start_command() can set the members .in and .out of struct child_process to a value > 0 to specify that this descriptor is used as the stdin or stdout of the child process. Previously, if start_command() was successful, this descriptor was closed upon return. Here we now make sure that the descriptor is also closed in case of failures. All callers are updated not to close the file descriptor themselves after start_command() was called. Note that earlier run_gpg_verify() of git-verify-tag set .out = 1, which worked because start_command() treated this as a special case, but now this is incorrect because it closes the descriptor. The intent here is to inherit stdout to the child, which is achieved by .out = 0. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2008-02-23start_command(), .in/.out/.err = -1: Callers must close the file descriptorJohannes Sixt
By setting .in, .out, or .err members of struct child_process to -1, the callers of start_command() can request that a pipe is allocated that talks to the child process and one end is returned by replacing -1 with the file descriptor. Previously, a flag was set (for .in and .out, but not .err) to signal finish_command() to close the pipe end that start_command() had handed out, so it was optional for callers to close the pipe, and many already do so. Now we make it mandatory to close the pipe. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2008-02-23Sync with C Hamano
Signed-off-by: Junio C Hamano <>
2008-02-23GIT C Hamano
Signed-off-by: Junio C Hamano <>
2008-02-23Merge branch 'maint' of git:// into maintJunio C Hamano
* 'maint' of git:// git-gui: Focus insertion point at end of strings in repository chooser git-gui: Avoid hardcoded Windows paths in Cygwin package files git-gui: Default TCL_PATH to same location as TCLTK_PATH git-gui: Paper bag fix error dialogs opening over the main window git-gui: Ensure error dialogs always appear over all other windows git-gui: relax "dirty" version detection git-gui: support Git under OS X 10.5
2008-02-23Add merge-subtree backJunio C Hamano
An earlier commit e1b3a2c (Build-in merge-recursive) made the subtree merge strategy backend unavailable. This resurrects it. A new test t6029 currently only tests the strategy is available, but it should be enhanced to check the real "subtree" case. Signed-off-by: Junio C Hamano <>
2008-02-23builtin-reflog.c: don't install new reflog on write failureBrandon Casey
When expiring reflog entries, a new temporary log is written which contains only the entries to retain. After it is written, it is renamed to replace the existing reflog. Currently, we check that writing of the new log is successful and print a message on failure, but the original reflog is still replaced with the new reflog even on failure. This patch causes the original reflog to be retained if we fail when writing the new reflog. Signed-off-by: Brandon Casey <> Signed-off-by: Junio C Hamano <>
2008-02-23pull: pass --strategy along to to rebaseJay Soffian
rebase supports --strategy, so pull should pass the option along to it. Signed-off-by: Jay Soffian <> Signed-off-by: Junio C Hamano <>
2008-02-23Use helper function for copying index entry informationLinus Torvalds
We used to just memcpy() the index entry when we copied the stat() and SHA1 hash information, which worked well enough back when the index entry was just an exact bit-for-bit representation of the information on disk. However, these days we actually have various management information in the cache entry too, and we should be careful to not overwrite it when we copy the stat information from another index entry. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
2008-02-23Name hash fixups: export (and rename) remove_hash_entryLinus Torvalds
This makes the name hash removal function (which really just sets the bit that disables lookups of it) available to external routines, and makes read_cache_unmerged() use it when it drops an unmerged entry from the index. It's renamed to remove_index_entry(), and we drop the (unused) 'istate' argument. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
2008-02-23Fix name re-hashing semanticsLinus Torvalds
We handled the case of removing and re-inserting cache entries badly, which is something that merging commonly needs to do (removing the different stages, and then re-inserting one of them as the merged state). We even had a rather ugly special case for this failure case, where replace_index_entry() basically turned itself into a no-op if the new and the old entries were the same, exactly because the hash routines didn't handle it on their own. So what this patch does is to not just have the UNHASHED bit, but a HASHED bit too, and when you insert an entry into the name hash, that involves: - clear the UNHASHED bit, because now it's valid again for lookup (which is really all that UNHASHED meant) - if we're being lazy, we're done here (but we still want to clear the UNHASHED bit regardless of lazy mode, since we can become unlazy later, and so we need the UNHASHED bit to always be set correctly, even if we never actually insert the entry into the hash list) - if it was already hashed, we just leave it on the list - otherwise mark it HASHED and insert it into the list this all means that unhashing and rehashing a name all just works automatically. Obviously, you cannot change the name of an entry (that would be a serious bug), but nothing can validly do that anyway (you'd have to allocate a new struct cache_entry anyway since the name length could change), so that's not a new limitation. The code actually gets simpler in many ways, although the lazy hashing does mean that there are a few odd cases (ie something can be marked unhashed even though it was never on the hash in the first place, and isn't actually marked hashed!). Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
2008-02-22Avoid unnecessary "if-before-free" tests.Jim Meyering
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: 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];a=blob;f=build-aux/useless-if-before-free Addendum: Remove one more (in imap-send.c), spotted by Jean-Luc Herren <>. Signed-off-by: Jim Meyering <> Signed-off-by: Junio C Hamano <>
2008-02-22Merge branch 'maint'Junio C Hamano
* maint: hash: fix lookup_hash semantics
2008-02-22hash: fix lookup_hash semanticsJeff King
We were returning the _address of_ the stored item (or NULL) instead of the item itself. While this sort of indirection is useful for insertion (since you can lookup and then modify), it is unnecessary for read-only lookup. Since the hash code splits these functions between the internal lookup_hash_entry function and the public lookup_hash function, it makes sense for the latter to provide what users of the library expect. The result of this was that the index caching returned bogus results on lookup. We unfortunately didn't catch this because we were returning a "struct cache_entry **" as a "void *", and accidentally assigning it to a "struct cache_entry *". As it happens, this actually _worked_ most of the time, because the entries were defined as: struct cache_entry { struct cache_entry *next; ... }; meaning that interpreting a "struct cache_entry **" as a "struct cache_entry *" would yield an entry where all fields were totally bogus _except_ for the next pointer, which pointed to the actual cache entry. When walking the list, we would look at the bogus "name" field, which was unlikely to match our lookup, and then proceed to the "real" entry. The reading of bogus data was silently ignored most of the time, but could cause a segfault for some data (which seems to be more common on OS X). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-02-22gitweb: Better chopping in commit search resultsJunio C Hamano
When searching commit messages (commit search), if matched string is too long, the generated HTML was munged leading to an ill-formed XHTML document. Now gitweb chop leading, trailing and matched parts, HTML escapes those parts, then composes and marks up match info. HTML output is never chopped. Limiting matched info to 80 columns (with slop) is now done by dividing remaining characters after chopping match equally to leading and trailing part, not by chopping composed and HTML marked output. Noticed-by: Jean-Baptiste Quenot <> Signed-off-by: Junio C Hamano <> Signed-off-by: Jakub Narebski <> Signed-off-by: Junio C Hamano <>