path: root/commit.h
AgeCommit message (Collapse)Author
2010-08-18Merge branch 'cc/find-commit-subject'Junio C Hamano
* cc/find-commit-subject: blame: use find_commit_subject() instead of custom code merge-recursive: use find_commit_subject() instead of custom code bisect: use find_commit_subject() instead of custom code revert: rename variables related to subject in get_message() revert: refactor code to find commit subject in find_commit_subject() revert: fix off by one read when searching the end of a commit subject
2010-07-23revert: refactor code to find commit subject in find_commit_subject()Christian Couder
Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
2010-06-30Merge branch 'ar/decorate-color'Junio C Hamano
* ar/decorate-color: Add test for correct coloring of git log --decoration Allow customizable commit decorations colors log --decorate: Colorize commit decorations log-tree.c: Use struct name_decoration's type for classifying decoration commit.h: add 'type' to struct name_decoration
2010-06-21Merge branch 'gv/portable'Junio C Hamano
* gv/portable: test-lib: use DIFF definition from GIT-BUILD-OPTIONS build: propagate $DIFF to scripts Makefile: Tru64 portability fix Makefile: HP-UX 10.20 portability fixes Makefile: HPUX11 portability fixes Makefile: SunOS 5.6 portability fix inline declaration does not work on AIX Allow disabling "inline" Some platforms lack socklen_t type Make NO_{INET_NTOP,INET_PTON} configured independently Makefile: some platforms do not have hstrerror anywhere git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition test_cmp: do not use "diff -u" on platforms that lack one fixup: do not unconditionally disable "diff -u" tests: use "test_cmp", not "diff", when verifying the result Do not use "diff" found on PATH while building and installing enums: omit trailing comma for portability Makefile: -lpthread may still be necessary when libc has only pthread stubs Rewrite dynamic structure initializations to runtime assignment Makefile: pass CPPFLAGS through to fllow customization Conflicts: Makefile wt-status.h
2010-06-21commit.h: add 'type' to struct name_decorationNazri Ramliy
This allows for semantically better handling of decoration type. Signed-off-by: Nazri Ramliy <> Signed-off-by: Junio C Hamano <>
2010-05-31enums: omit trailing comma for portabilityGary V. Vaughan
Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX 5.1 fails to compile git. enum style is inconsistent already, with some enums declared on one line, some over 3 lines with the enum values all on the middle line, sometimes with 1 enum value per line... and independently of that the trailing comma is sometimes present and other times absent, often mixing with/without trailing comma styles in a single file, and sometimes in consecutive enum declarations. Clearly, omitting the comma is the more portable style, and this patch changes all enum declarations to use the portable omitted dangling comma style consistently. Signed-off-by: Gary V. Vaughan <> Signed-off-by: Junio C Hamano <>
2010-05-09Merge branch 'jk/cached-textconv'Junio C Hamano
* jk/cached-textconv: diff: avoid useless filespec population diff: cache textconv output textconv: refactor calls to run_textconv introduce notes-cache interface make commit_tree a library function
2010-04-14pretty: Initialize notes if %N is usedJohannes Gilger
When using git log --pretty='%N' without an explicit --show-notes, git would segfault. This patches fixes this behaviour by loading the needed notes datastructures if --pretty is used and the format contains %N. When --pretty='%N' is used together with --no-notes, %N won't be expanded. This is an extension to a proposed patch by Jeff King. Signed-off-by: Johannes Gilger <> Signed-off-by: Junio C Hamano <>
2010-04-02make commit_tree a library functionJeff King
Until now, this has been part of the commit-tree builtin. However, it is already used by other builtins (like commit, merge, and notes), and it would be useful to access it from library code. The check_valid helper has to come along, too, but is given a more library-ish name of "assert_sha1_type". Otherwise, the code is unchanged. There are still a few rough edges for a library function, like printing the utf8 warning to stderr, but we can address those if and when they come up as inappropriate. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2010-01-23Merge branch 'jc/maint-limit-note-output'Junio C Hamano
* jc/maint-limit-note-output: Fix "log --oneline" not to show notes Fix "log" family not to be too agressive about showing notes
2010-01-21Fix "log" family not to be too agressive about showing notesJunio C Hamano
Giving "Notes" information in the default output format of "log" and "show" is a sensible progress (the user has asked for it by having the notes), but for some commands (e.g. "format-patch") spewing notes into the formatted commit log message without being asked is too aggressive. Enable notes output only for "log", "show", "whatchanged" by default and only when the user didn't ask any specific --pretty/--format from the command line; users can explicitly override this default with --show-notes and --no-notes option. Parts of tests are taken from Jeff King's fix. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2010-01-12pretty.c: mark file-local function staticJunio C Hamano
Signed-off-by: Junio C Hamano <>
2009-11-21Merge branch 'sp/smart-http'Junio C Hamano
* sp/smart-http: (37 commits) http-backend: Let gcc check the format of more printf-type functions. http-backend: Fix access beyond end of string. http-backend: Fix bad treatment of uintmax_t in Content-Length t5551-http-fetch: Work around broken Accept header in libcurl t5551-http-fetch: Work around some libcurl versions http-backend: Protect GIT_PROJECT_ROOT from /../ requests Git-aware CGI to provide dumb HTTP transport http-backend: Test configuration options http-backend: Use http.getanyfile to disable dumb HTTP serving test smart http fetch and push http tests: use /dumb/ URL prefix set httpd port before sourcing lib-httpd t5540-http-push: remove redundant fetches Smart HTTP fetch: gzip requests Smart fetch over HTTP: client side Smart push over HTTP: client side Discover refs via smart HTTP server when available http-backend: more explict LocationMatch http-backend: add example for gitweb on same URL http-backend: use mod_alias instead of mod_rewrite ... Conflicts: .gitignore remote-curl.c
2009-10-31fixup tr/stash-format mergeJunio C Hamano
2009-10-31fetch-pack: Use a strbuf to compose the want listShawn O. Pearce
This change is being offered as a refactoring to make later commits in the smart HTTP series easier. By changing the enabled capabilities to be formatted in a strbuf it is easier to add a new capability to the set of supported capabilities. By formatting the want portion of the request into a strbuf and writing it as a whole block we can later decide to hold onto the req_buf (instead of releasing it) to recycle in stateless communications. Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
2009-10-20Introduce new pretty formats %g[sdD] for reflog informationThomas Rast
Add three new --pretty=format escapes: %gD long reflog descriptor (e.g. refs/stash@{0}) %gd short reflog descriptor (e.g. stash@{0}) %gs reflog message This is achieved by passing down the reflog info, if any, inside the pretty_print_context struct. We use the newly refactored get_reflog_selector(), and give it some extra functionality to extract a shortened ref. The shortening is cached inside the commit_reflogs struct; the only allocation of it happens in read_complete_reflog(), where it is initialised to 0. Also add another helper get_reflog_message() for the message extraction. Note that the --format="%h %gD: %gs" tests may not work in real repositories, as the --pretty formatter doesn't know to leave away the ": " on the last commit in an incomplete (because git-gc removed the old part) reflog. This equivalence is nevertheless the main goal of this patch. Thanks to Jeff King for reviews, the %gd testcase and documentation. Signed-off-by: Thomas Rast <> Signed-off-by: Junio C Hamano <>
2009-10-20Refactor pretty_print_commit arguments into a structThomas Rast
pretty_print_commit() has a bunch of rarely-used arguments, and introducing more of them requires yet another update of all the call sites. Refactor most of them into a struct to make future extensions easier. The ones that stay "plain" arguments were chosen on the grounds that all callers put real arguments there, whereas some callers have 0/NULL for all arguments that were factored into the struct. We declare the struct 'const' to ensure none of the callers are bitten by the changed (no longer call-by-value) semantics. Signed-off-by: Thomas Rast <> Signed-off-by: Junio C Hamano <>
2009-10-19format_commit_message(): fix function signatureJunio C Hamano
The format template string was declared as "const void *" for some unknown reason, even though it obviously is meant to be passed a string. Make it "const char *". Signed-off-by: Junio C Hamano <>
2009-09-07Merge branch 'tr/reset-checkout-patch'Junio C Hamano
* tr/reset-checkout-patch: stash: simplify defaulting to "save" and reject unknown options Make test case number unique tests: disable interactive hunk selection tests if perl is not available DWIM 'git stash save -p' for 'git stash -p' Implement 'git stash save --patch' Implement 'git checkout --patch' Implement 'git reset --patch' builtin-add: refactor the meat of interactive_add() Add a small patch-mode testing library git-apply--interactive: Refactor patch mode code Make 'git stash -k' a short form for 'git stash save --keep-index'
2009-08-22Merge branch 'cc/replace'Junio C Hamano
* cc/replace: t6050: check pushing something based on a replaced commit Documentation: add documentation for "git replace" Add git-replace to .gitignore builtin-replace: use "usage_msg_opt" to give better error messages parse-options: add new function "usage_msg_opt" builtin-replace: teach "git replace" to actually replace Add new "git replace" command environment: add global variable to disable replacement mktag: call "check_sha1_signature" with the replacement sha1 replace_object: add a test case object: call "check_sha1_signature" with the replacement sha1 sha1_file: add a "read_sha1_file_repl" function replace_object: add mechanism to replace objects found in "refs/replace/" refs: add a "for_each_replace_ref" function
2009-08-14builtin-add: refactor the meat of interactive_add()Thomas Rast
This moves the call setup for 'git add--interactive' to a separate function, as other users will call it without running validate_pathspec() first. Signed-off-by: Thomas Rast <> Signed-off-by: Junio C Hamano <>
2009-08-10Expose the has_non_ascii() functionJohannes Schindelin
This function is useful outside of log-tree.c, too. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
2009-06-01replace_object: add mechanism to replace objects found in "refs/replace/"Christian Couder
The code implementing this mechanism has been copied more-or-less from the commit graft code. This mechanism is used in "read_sha1_file". sha1 passed to this function that match a ref name in "refs/replace/" are replaced by the sha1 that has been read in the ref. We "die" if the replacement recursion depth is too high or if we can't read the replacement object. Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
2009-05-27bisect: drop unparse_commit() and use clear_commit_marks()Christian Couder
The goal of this patch series is to check if good revisions are ancestor of the bad revision without forking a process to launch "git rev-list $good ^$bad". This new version of this patch series does not use an "unparse_commit" function anymore, we use "clear_commit_marks" instead. Signed-off-by: Junio C Hamano <>
2009-05-18commit: add function to unparse a commit and its parentsChristian Couder
This patch adds the "unparse_commit" function that returns a commit into an unparsed state by freeing its data and resetting its fields to 0. Its parents are recursively unparsed too, because they might have been changed. But its tree is not unparsed as it should not have been modifed. Note that as the "flags" and "used" fields may be used even if the object is not parsed, we have to reset them anyway. Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
2009-01-28Make has_commit() non-staticJake Goulding
Move has_commit() from branch to a common location, in preparation for using it in "git-tag". Rename it to is_descendant_of() to make it more unique and descriptive. Signed-off-by: Jake Goulding <> Signed-off-by: Junio C Hamano <>
2008-10-21builtin-blame: Reencode commit messages according to git-log rules.Alexander Gavrilov
Currently git-blame outputs text from the commit messages (e.g. the author name and the summary string) as-is, without even providing any information about the encoding used for the data. It makes interpreting the data in multilingual environment very difficult. This commit changes the blame implementation to recode the messages using the rules used by other commands like git-log. Namely, the target encoding can be specified through the i18n.commitEncoding or i18n.logOutputEncoding options, or directly on the command line using the --encoding parameter. Converting the encoding before output seems to be more friendly to the porcelain tools than simply providing the value of the encoding header, and does not require changing the output format. If anybody needs the old behavior, it is possible to achieve it by specifying --encoding=none. Signed-off-by: Alexander Gavrilov <> Signed-off-by: Junio C Hamano <>
2008-10-03commit.c: make read_graft_file() staticNanako Shiraishi
This function is not called by any other file. Signed-off-by: Nanako Shiraishi <> Signed-off-by: Shawn O. Pearce <>
2008-08-29Merge branch 'maint'Junio C Hamano
* maint: tutorial: gentler illustration of Alice/Bob workflow using gitk pretty=format: respect date format options make git-shell paranoid about closed stdin/stdout/stderr Document gitk --argscmd flag. Fix '--dirstat' with cross-directory renaming for-each-ref: Allow a trailing slash in the patterns
2008-08-29pretty=format: respect date format optionsJeff King
When running a command like: git log --pretty=format:%ad --date=short the date option was ignored. This patch causes it to use whatever format was specified by --date (or by --relative-date, etc), just as the non-user formats would do. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2008-07-30merge-base: teach "git merge-base" to drive underlying merge_bases_many()Christian Couder
Even though the underlying function for get_merge_bases() can compute a merge base between one existing commit and another (possibly nonexistent) commit that would be created by merging many commits, the facility was not available to git-merge-base. Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
2008-07-16Merge branch 'mv/merge-in-c'Junio C Hamano
* mv/merge-in-c: reduce_heads(): protect from duplicate input reduce_heads(): thinkofix Add a new test for git-merge-resolve t6021: add a new test for git-merge-resolve Teach merge.log to "git-merge" again Build in merge Fix on AIX git-commit-tree: make it usable from other builtins Add new test case to ensure git-merge prepends the custom merge message Add new test case to ensure git-merge reduces octopus parents when possible Introduce reduce_heads() Introduce get_merge_bases_many() Add new test to ensure git-merge handles more than 25 refs. Introduce get_octopus_merge_bases() in commit.c git-fmt-merge-msg: make it usable from other builtins Move read_cache_unmerged() to read-cache.c Add new test to ensure git-merge handles pull.twohead and pull.octopus Move parse-options's skip_prefix() to git-compat-util.h Move commit_list_count() to commit.c Move split_cmdline() to alias.c Conflicts: Makefile parse-options.c
2008-07-10rerere: Separate libgit and builtin functionsStephan Beyer
This patch moves rerere()-related functions into a newly created rerere.c file. The setup_rerere() function is needed by both rerere() and cmd_rerere(), so this function is moved to rerere.c and declared non-static (and "extern") in newly created rerere.h file. Signed-off-by: Stephan Beyer <> Signed-off-by: Junio C Hamano <>
2008-07-01Introduce reduce_heads()Junio C Hamano
The new function reduce_heads() is given a list of commits, and removes ones that can be reached from other commits in the list. It is useful for reducing the commits randomly thrown at the git-merge command and remove redundant commits that the user shouldn't have given to it. The implementation uses the get_merge_bases_many() introduced in the previous commit. If the merge base between one commit taken from the list and the remaining commits is the commit itself, that means the commit is reachable from some of the other commits. Signed-off-by: Junio C Hamano <>
2008-07-01Introduce get_octopus_merge_bases() in commit.cMiklos Vajna
This is like get_merge_bases() but it works for multiple heads, like show-branch --merge-base. Signed-off-by: Miklos Vajna <> Signed-off-by: Junio C Hamano <>
2008-07-01Move commit_list_count() to commit.cMiklos Vajna
This function is useful outside builtin-merge-recursive, for example in builtin-merge. Signed-off-by: Miklos Vajna <> Signed-off-by: Junio C Hamano <>
2008-04-10log: teach "terminator" vs "separator" mode to "--pretty=format"Junio C Hamano
This attached patch introduces a single bit "use_terminator" in "struct rev_info", which is normally false (i.e. most formats use separator semantics) but by flipping it to true, you can ask for terminator semantics just like oneline format does. The function get_commit_format(), which is what parses "--pretty=" option, now takes a pointer to "struct rev_info" and updates its commit_format and use_terminator fields. It used to return the value of type "enum cmit_fmt", but all the callers assigned it to rev->commit_format. There are only two cases the code turns use_terminator on. Obviously, the traditional oneline format (--pretty=oneline) is one of them, and the new case is --pretty=tformat:... that acts like --pretty=format:... but flips the bit on. With this, "--pretty=tformat:%H %s" acts like --pretty=oneline. Signed-off-by: Junio C Hamano <>
2008-03-15Merge branch 'maint'Junio C Hamano
* maint: format-patch: generate MIME header as needed even when there is format.header
2008-03-15format-patch: generate MIME header as needed even when there is format.headerJunio C Hamano
Earlier, the callchain from pretty_print_commit() down to pp_title_line() had an unwarranted assumption that the presense of "after_subject" parameter, means the caller has already output MIME headers for attachments. The parameter's primary purpose is to give extra header lines the caller wants to place after pp_title_line() generates the "Subject: " line. This assumption does not hold when the user used the format.header configuration variable to pass extra headers, and caused a message with non-ASCII character to lack proper MIME headers (e.g. 8-bit CTE header). The earlier logic also failed to suppress duplicated MIME headers when "format-patch -s --attach" is asked for and the signer's name demanded 8-bit clean transport. This patch fixes the logic by introducing a separate need_8bit_cte parameter passed down the callchain. This can have one of these values: -1 : we've already done MIME crap and we do not want to add extra header to say this is 8bit in pp_title_line(); 0 : we haven't done MIME and we have not seen anything that is 8bit yet; 1 : we haven't done MIME and we have seen something that is 8bit; pp_title_line() must add MIME header. It adds two tests by Jeff King who independently diagnosed this issue. Signed-off-by: Junio C Hamano <>
2008-03-02Merge branch 'mk/maint-parse-careful'Junio C Hamano
* mk/maint-parse-careful: receive-pack: use strict mode for unpacking objects index-pack: introduce checking mode unpack-objects: prevent writing of inconsistent objects unpack-object: cache for non written objects add common fsck error printing function builtin-fsck: move common object checking code to fsck.c builtin-fsck: reports missing parent commits Remove unused object-ref code builtin-fsck: move away from object-refs to fsck_walk add generic, type aware object chain walker Conflicts: Makefile builtin-fsck.c
2008-02-26builtin-fsck: reports missing parent commitsMartin Koegler
parse_commit ignores parent commits with certain errors (eg. a non commit object is already loaded under the sha1 of the parent). To make fsck reports such errors, it has to compare the nummer of parent commits returned by parse commit with the number of parent commits in the object or in the graft/shallow file. Signed-off-by: Martin Koegler <> Signed-off-by: Junio C Hamano <>
2008-02-19Export some email and pretty-printing functionsDaniel Barkalow
These will be used for generating the cover letter in addition to the patch emails. Signed-off-by: Daniel Barkalow <> Signed-off-by: Junio C Hamano <>
2007-11-25add -i: Fix running from a subdirectoryJunio C Hamano
This fixes the pathspec interactive_add() passes to the underlying git-add--interactive helper. When the command was run from a subdirectory, cmd_add() already has gone up to the toplevel of the work tree, and the helper will be spawned from there. The pathspec given on the command line from the user needs to be adjusted for this. This adds "validate_pathspec()" function in the callchain, but it does not validate yet. The function can be changed to barf if there are unmatching pathspec given by the user, but that is not strictly necessary. Signed-off-by: Junio C Hamano <>
2007-11-25Merge branch 'kh/commit' into wc/add-iJunio C Hamano
This is to use a few functions refactored to use in the built-in commit series. * kh/commit: (28 commits) Add a few more tests for git-commit builtin-commit: Include the diff in the commit message when verbose. builtin-commit: fix partial-commit support Fix add_files_to_cache() to take pathspec, not user specified list of files Export three helper functions from ls-files builtin-commit: run commit-msg hook with correct message file builtin-commit: do not color status output shown in the message template file_exists(): dangling symlinks do exist Replace "runstatus" with "status" in the tests t7501-commit: Add test for git commit <file> with dirty index. builtin-commit: Clean up an unused variable and a debug fprintf(). Call refresh_cache() when updating the user index for --only commits. builtin-commit: Add newline when showing which commit was created builtin-commit: resurrect behavior for multiple -m options builtin-commit --s: add a newline if the last line was not a S-o-b builtin-commit: fix --signoff git status: show relative paths when run in a subdirectory builtin-commit: Refresh cache after adding files. builtin-commit: fix reflog message generation launch_editor(): read the file, even when EDITOR=: ...
2007-11-23Fix add_files_to_cache() to take pathspec, not user specified list of filesJunio C Hamano
This separates the logic to limit the extent of change to the index by where you are (controlled by "prefix") and what you specify from the command line (controlled by "pathspec"). Signed-off-by: Junio C Hamano <>
2007-11-22Teach builtin-add to pass multiple paths to git-add--interactiveWincent Colaiuta
Instead of just accepting a single file parameter, git-add now accepts any number of path parameters, fowarding them to git-add--interactive. Signed-off-by: Wincent Colaiuta <> Signed-off-by: Junio C Hamano <>
2007-11-06revision walker: mini clean-upLinus Torvalds
This removes the unnecessary indirection of "revs->prune_fn", since that function is always the same one (or NULL), and there is in fact not even an abstraction reason to make it a function (i.e. its not called from some other file and doesn't allow us to keep the function itself static or anything like that). It then just replaces it with a bit that says "prune or not", and if not pruning, every commit gets TREECHANGE. That in turn means that - if (!revs->prune_fn || (flags & TREECHANGE)) - if (revs->prune_fn && !(flags & TREECHANGE)) just become - if (flags & TREECHANGE) - if (!(flags & TREECHANGE)) respectively. Together with adding the "single_parent()" helper function, the "complex" conditional now becomes if (!(flags & TREECHANGE) && rev->dense && single_parent(commit)) continue; Also indirection of "revs->dense" checking is thrown away the same way, because TREECHANGE bit is set appropriately now. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
2007-11-04Simplify topo-sort logicLinus Torvalds
.. by not using quite so much indirection. This currently grows the "struct commit" a bit, which could be avoided by using a union for "util" and "indegree" (the topo-sort used to use "util" anyway, so you cannot use them together), but for now the goal of this was to simplify, not optimize. Signed-off-by: Linus Torvalds <>
2007-11-02format-patch -s: add MIME encoding header if signer's name requires soJunio C Hamano
When the body of the commit log message contains a non-ASCII character, format-patch correctly emitted the encoding header to mark the resulting message as such. However, if the original message was fully ASCII, the command line switch "-s" was given to add a new sign-off, and the signer's name was not ASCII only, the resulting message would have contained non-ASCII character but was not marked as such. Signed-off-by: Junio C Hamano <>
2007-09-27Export rerere() and launch_editor().Kristian Høgsberg
Signed-off-by: Kristian Høgsberg <> Signed-off-by: Junio C Hamano <>