summaryrefslogtreecommitdiff
path: root/builtin-commit.c
AgeCommit message (Collapse)AuthorFilesLines
2008-05-11Merge branch 'maint'Libravatar Junio C Hamano1-1/+1
* maint: wt-status.h: declare global variables as extern builtin-commit.c: add -u as short name for --untracked-files git-repack: re-enable parsing of -n command line option
2008-05-11Merge branch 'maint-1.5.4' into maintLibravatar Junio C Hamano1-1/+1
* maint-1.5.4: wt-status.h: declare global variables as extern builtin-commit.c: add -u as short name for --untracked-files git-repack: re-enable parsing of -n command line option
2008-05-11builtin-commit.c: add -u as short name for --untracked-filesLibravatar Sitaram Chamarty1-1/+1
This makes the C code consistent with the documentation and the old shell code. Signed-off-by: Sitaram Chamarty <sitaramc@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-10Avoid some unnecessary lstat() callsLibravatar Linus Torvalds1-2/+4
The commit sequence used to do if (file_exists(p->path)) add_file_to_cache(p->path, 0); where both "file_exists()" and "add_file_to_cache()" needed to do a lstat() on the path to do their work. This cuts down 'lstat()' calls for the partial commit case by two for each path we know about (because we do this twice per path). Just move the lstat() to the caller instead (that's all that "file_exists()" really does), and pass the stat information down to the add_to_cache() function. This essentially makes 'add_to_index()' the core function that adds a path to the index, getting the index pointer, the pathname and the stat information as arguments. There are then shorthand helper functions that use this core function: - 'add_to_cache()' is just 'add_to_index()' with the default index - 'add_file_to_cache/index()' is the same, but does the lstat() call itself, so you can pass just the pathname if you don't already have the stat information available. So old users of the 'add_file_to_xyzzy()' are essentially left unchanged, and this just exposes the more generic helper function that can take existing stat information into account. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-27Merge branch 'maint'Libravatar Junio C Hamano1-1/+1
* maint: clone: detect and fail on excess parameters Remove 'header' from --signoff option description
2008-04-27Merge branch 'maint-1.5.4' into maintLibravatar Junio C Hamano1-1/+1
* maint-1.5.4: Remove 'header' from --signoff option description
2008-04-27Remove 'header' from --signoff option descriptionLibravatar Dan McGee1-1/+1
Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-19Merge branch 'jc/terminator-separator'Libravatar Junio C Hamano1-1/+1
* jc/terminator-separator: log: teach "terminator" vs "separator" mode to "--pretty=format"
2008-04-11Merge branch 'maint'Libravatar Junio C Hamano1-1/+1
* maint: bisect: fix bad rev checking in "git bisect good" revision.c: make --date-order overriddable git-submodule: Avoid 'fatal: cannot describe' message Force the medium pretty format on calls to git log Fix section about backdating tags in the git-tag docs Document option --only of git commit Documentation/git-request-pull: Fixed a typo ("send" -> "end")
2008-04-11Merge branch 'maint-1.5.4' into maintLibravatar Junio C Hamano1-1/+1
* maint-1.5.4: bisect: fix bad rev checking in "git bisect good" revision.c: make --date-order overriddable Fix section about backdating tags in the git-tag docs Document option --only of git commit Documentation/git-request-pull: Fixed a typo ("send" -> "end")
2008-04-11builtin-commit.c: Remove a redundant assignment.Libravatar Johannes Sixt1-3/+1
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-11Document option --only of git commitLibravatar Johannes Sixt1-1/+1
Its documentation was removed by 6c96753 (Documentation/git-commit: rewrite to make it more end-user friendly, 2006-12-08), even though it is referenced from a few places, including builtin-commit.c (as part of the commentary in the commit message template). Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-10log: teach "terminator" vs "separator" mode to "--pretty=format"Libravatar Junio C Hamano1-1/+1
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 <gitster@pobox.com>
2008-03-09Make 'unpack_trees()' have a separate source and destination indexLibravatar Linus Torvalds1-1/+2
We will always unpack into our own internal index, but we will take the source from wherever specified, and we will optionally write the result to a specified index (optionally, because not everybody even _wants_ any result: the index diffing really wants to just walk the tree and index in parallel). This ends up removing a fair number more lines than it adds, for the simple reason that we can now skip all the crud that tried to be oh-so-careful about maintaining our position in the index as we were traversing and modifying it. Since we don't actually modify the source index any more, we can just update the 'o->pos' pointer without worrying about whether an index entry got removed or replaced or added to. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-09Make 'unpack_trees()' take the index to work on as an argumentLibravatar Linus Torvalds1-0/+1
This is just a very mechanical conversion, and makes everybody set it to '&the_index' before calling, but at least it makes it more explicit where we work with the index. The next stage would be to split that index usage up into a 'source' and a 'destination' index, so that we can unpack into a different index than we started out from. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-27Merge branch 'db/checkout'Libravatar Junio C Hamano1-1/+2
* db/checkout: (21 commits) checkout: error out when index is unmerged even with -m checkout: show progress when checkout takes long time while switching branches Add merge-subtree back checkout: updates to tracking report builtin-checkout.c: Remove unused prefix arguments in switch_branches path checkout: work from a subdirectory checkout: tone down the "forked status" diagnostic messages Clean up reporting differences on branch switch builtin-checkout.c: fix possible usage segfault checkout: notice when the switched branch is behind or forked Build in checkout Move code to clean up after a branch change to branch.c Library function to check for unmerged index entries Use diff -u instead of diff in t7201 Move create_branch into a library file Build-in merge-recursive Add "skip_unmerged" option to unpack_trees. Discard "deleted" cache entries after using them to update the working tree Send unpack-trees debugging output to stderr Add flag to make unpack_trees() not print errors. ... Conflicts: Makefile
2008-02-18Add color.ui variable which globally enables colorization if setLibravatar Matthias Kestenholz1-0/+4
Signed-off-by: Matthias Kestenholz <mk@spinlock.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-16Merge branch 'pb/prepare-commit-msg'Libravatar Junio C Hamano1-108/+145
* pb/prepare-commit-msg: git-commit: add a prepare-commit-msg hook git-commit: Refactor creation of log message. git-commit: set GIT_EDITOR=: if editor will not be launched git-commit: support variable number of hook arguments
2008-02-16Merge branch 'maint'Libravatar Junio C Hamano1-0/+4
* maint: commit: discard index after setting up partial commit filter-branch: handle filenames that need quoting diff: Fix miscounting of --check output hg-to-git: fix parent analysis mailinfo: feed only one line to handle_filter() for QP input diff.c: add "const" qualifier to "char *cmd" member of "struct ll_diff_driver" Add "const" qualifier to "char *excludes_file". Add "const" qualifier to "char *editor_program". Add "const" qualifier to "char *pager_program". config: add 'git_config_string' to refactor string config variables. diff.c: remove useless check for value != NULL fast-import: check return value from unpack_entry() Validate nicknames of remote branches to prohibit confusing ones diff.c: replace a 'strdup' with 'xstrdup'. diff.c: fixup garding of config parser from value=NULL
2008-02-16commit: discard index after setting up partial commitLibravatar Jeff King1-0/+4
There may still be some entries from the original index that should be discarded before we show the status. In particular, if a file was added in the index but not included in the partial commit, it would still show up in the status listing as staged for commit. Ultimately the correct fix is to keep the two states in separate index_state variables. Then we can avoid having to reload the cache from the temporary file altogether, and just point wt_status_print at the correct index. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11Merge branch 'lt/in-core-index'Libravatar Junio C Hamano1-1/+1
* lt/in-core-index: lazy index hashing Create pathname-based hash-table lookup into index read-cache.c: introduce is_racy_timestamp() helper read-cache.c: fix a couple more CE_REMOVE conversion Also use unpack_trees() in do_diff_cache() Make run_diff_index() use unpack_trees(), not read_tree() Avoid running lstat(2) on the same cache entry. index: be careful when handling long names Make on-disk index representation separate from in-core one
2008-02-11builtin-commit.c: guard config parser from value=NULLLibravatar Junio C Hamano1-0/+2
commit.template configuration expects a string value. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11builtin-commit: remove .git/SQUASH_MSG upon successful commitLibravatar Gerrit Pape1-0/+1
After doing a merge --squash, and commit afterwards, the commit message template SQUASH_MSG in the git directory is not removed, which means that the content of SQUASH_MSG is used as default commit message for all subsequent commits. So have git commit remove the file SQUASH_MSG from the git directory upon a successful commit. The problem was discovered by Frédéric Brière, reported through http://bugs.debian.org/464656 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-09Allow callers of unpack_trees() to handle failureLibravatar Daniel Barkalow1-1/+2
Return an error from unpack_trees() instead of calling die(), and exit with an error in read-tree, builtin-commit, and diff-lib. merge-recursive already expected an error return from unpack_trees, so it doesn't need to be changed. The merge function can return negative to abort. This will be used in builtin-checkout -m. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
2008-02-06git-commit: add a prepare-commit-msg hookLibravatar Paolo Bonzini1-0/+21
The prepare-commit-msg hook is run whenever a "fresh" commit message is prepared, just before it is shown in the editor (if it is). Its purpose is to modify the commit message in-place. It takes one to three parameters. The first is the name of the file that the commit log message. The second is the source of the commit message, and can be: "message" (if a -m or -F option was given); "template" (if a -t option was given or the configuration option commit.template is set); "merge" (if the commit is a merge or a .git/MERGE_MSG file exists); "squash" (if a .git/SQUASH_MSG file exists); or "commit", followed by a commit SHA1 as the third parameter (if a -c, -C or --amend option was given). If its exit status is non-zero, git-commit will abort. The hook is not suppressed by the --no-verify option, so it should not be used as a replacement for the pre-commit hook. The sample prepare-commit-msg comments out the `Conflicts:` part of a merge's commit message; other examples are commented out, including adding a Signed-off-by line at the bottom of the commit messsage, that the user can then edit or discard altogether. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06git-commit: Refactor creation of log message.Libravatar Paolo Bonzini1-83/+88
This patch moves the code of run_commit, up to writing the trees, editing the message and running the commit-msg hook to prepare_log_message. It also renames the latter to prepare_to_commit. This simplifies a little the code for the next patch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06git-commit: set GIT_EDITOR=: if editor will not be launchedLibravatar Paolo Bonzini1-0/+2
This is a preparatory patch that provides a simple way for the future prepare-commit-msg hook to discover if the editor will be launched. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06git-commit: support variable number of hook argumentsLibravatar Paolo Bonzini1-26/+35
This is a preparatory patch to allow using run_hook for the prepare-commit-msg hook. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-03Fix "git-commit -C $tag"Libravatar Junio C Hamano1-1/+1
The scripted version might not have handled this correctly either, but the version rewritten in C definitely does not grok this and complains $tag is not a commit object. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-23git-commit: exit non-zero if we fail to commit the indexLibravatar Brandon Casey1-4/+11
In certain rare cases, the creation of the commit object and update of HEAD can succeed, but then installing the updated index will fail. This is most likely caused by a full disk or exceeded disk quota. When this happens the new index file will be removed, and the repository will be left with the original now-out-of-sync index. The user can recover with a "git reset HEAD" once the disk space issue is resolved. We should detect this failure and offer the user some helpful guidance. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-21Make on-disk index representation separate from in-core oneLibravatar Linus Torvalds1-1/+1
This converts the index explicitly on read and write to its on-disk format, allowing the in-core format to contain more flags, and be simpler. In particular, the in-core format is now host-endian (as opposed to the on-disk one that is network endian in order to be able to be shared across machines) and as a result we can dispense with all the htonl/ntohl on accesses to the cache_entry fields. This will make it easier to make use of various temporary flags that do not exist in the on-disk format. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-16Improve use of lockfile APILibravatar Brandon Casey1-3/+6
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-16Make builtin-commit.c more careful about parenthoodLibravatar Linus Torvalds1-5/+19
When creating the commit object, be a whole lot more careful about making sure that the parent lines really are valid parent lines. Check things like MERGE_HEAD having proper SHA1 lines in it, and double-check that all the parents exist and are actually commits. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-15git-commit: fix double close(2) that can close a wrong file descriptorLibravatar Kristian Høgsberg1-4/+4
The codepath to prepare index files for the temporary and next index file was closing file descriptor it obtained from the lockfile API by hand, without letting the API know that the fd should not be doubly closed. This is not usually a problem (except it may get EBADFD) but if we opened another fd for an entirely unrelated purpose (say, an fd used to mmap a packfile) between the time we close the fd to the index file and the time we commit or rollback the lockfile (causing it to also try closing the recorded fd), the lockfile API will close an incorrect file descriptor that is still used for an entirely unrelated purpose. There's four close(fd) calls in prepare_index() and they're all incorrect. The open fd's are cleaned up in rollback_index_files() and shouldn't be closed manually. The patch below gets rid of the extra close() calls and should fix the problem. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-14Revert "builtin-commit.c: remove useless check added by faulty cut and paste"Libravatar Junio C Hamano1-0/+2
This reverts commit 16335fdd7ace78a8285ba25fd7a81177a48e7c9b. We are calling overlay_tree_on_cache() which does use CE_UPDATE flag to mark duplicated entries, which is the same as the codepath in git-ls-files with its --with-tree option. Because the pathname ce->name is given to path_list_insert() which does not allow duplicates, there is no breakage either way from the correctness point of view in this codepath, unlike the one in ls-files. But avoiding unnecessary processing with a single bit check is certainly better.
2008-01-13builtin-commit.c: remove useless check added by faulty cut and pasteLibravatar Junio C Hamano1-2/+0
2888605c649ccd423232161186d72c0e6c458a48 (builtin-commit: fix partial-commit support) mindlessly cut and pasted from builtin-ls-files.c, and included a part that was meant to exclude redundant path after "ls-files --with-tree" overlayed the HEAD commit on top of the index. This logic does not apply to what git-commit does and should not have been copied, even though it would not hurt. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-13Fix performance regression for partial commitsLibravatar Linus Torvalds1-9/+28
When running "git commit paths" to create a partial commit, we used to carefully build the temporary index so that we do not lose the cached stat information. The rewrite of the command in C lost it by carelessly using read_tree(). This resurrects the earlier behaviour to keep the cached stat information as much as possible by using one-tree merge logic. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22Allow selection of different cleanup modes for commit messagesLibravatar Alex Riesen1-4/+38
Although we traditionally stripped away excess blank lines, trailing whitespaces and lines that begin with "#" from the commit log message, sometimes the message just has to be the way user wants it. For instance, a commit message template can contain lines that begin with "#", the message must be kept as close to its original source as possible if you are converting from a foreign SCM, or maybe the message has a shell script including its comments for future reference. The cleanup modes are default, verbatim, whitespace and strip. The default mode depends on if the message is being edited and will either strip whitespace and comments (if editor active) or just strip the whitespace (for where the message is given explicitely). Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22builtin-commit: avoid double-negation in the code.Libravatar Junio C Hamano1-6/+6
The flag no_edit meant "we have got final message from the user and will not editing it any further", but there were quite a few places that needed to check !no_edit. Rename the variable to use_editor and reverse the logic everywhere. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22builtin-commit: fix amending of the initial commitLibravatar Junio C Hamano1-4/+4
When amending initial commit without editor, the command incorrectly barfed because the check to see if there is anything to commit referenced the non-existent HEAD^1. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-20fix git commit --amend -m "new message"Libravatar Junio C Hamano1-1/+5
The prepare_log_message() function serves two purposes: - Prepares the commit log message template, to be given to the end user; - Return true if there is something committable; 7168624c3530d8c7ee32f930f8fb2ba302b9801f (Do not generate full commit log message if it is not going to be used) cheated to omit the former when we know the log message template is not going to be used. However, its replacement logic to see if there is something committable was botched. When amending, it should compare the index with the parent of the HEAD, not the current HEAD. Otherwise you cannot run --amend to fix only the message without changing the tree. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16builtin-commit: make summary output consistent with statusLibravatar Junio C Hamano1-0/+3
This enables -B -M to the summary output after a commit is made so that it is in line with what is shown in git-status and commit log template. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16builtin-commit: fix summary output.Libravatar Junio C Hamano1-0/+1
Because print_summary() forgot to call diff_setup_done() after futzing with diff output options, it failed to activate recursive diff, which resulted in an incorrect summary. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14commit: allow --amend to reuse message from another commitLibravatar Junio C Hamano1-1/+1
After tentatively applying a patch from a contributor, you can get a replacement patch with corrected code and unusable commit log message. In such a case, this sequence ought to give you an editor based on the message in the earlier commit, to let you describe an incremental improvement: git reset --hard HEAD^ ;# discard the earlier one git am <corrected-patch git commit --amend -c HEAD@{1} Unfortunately, --amend insisted reusing the message from the commit being amended, ignoring the -c option. This corrects it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-12git-commit: squelch needless message during an empty mergeLibravatar Junio C Hamano1-4/+5
When recording a merge that conflicted and ends up in no changes after manual resolution, commit callchain looked like this: cmd_commit() -> prepare_log_message() -> run_status() -> wt_status_print() This invocation of run_status() is asked to find out if there is a committable change, but it unconditionally gave instructions such as "use git-add" at the same time. When in merge, we do allow an empty change to be recorded, so after showing this message the code still went ahead and made a commit. This introduces "nowarn" parameter to run_status() to avoid these useless messages. If we are not allowed to create an empty commit, we already call run_status() again in the original codepath, and the message will be shown from that call anyway. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-11commit: do not add extra LF at the end of the summary.Libravatar Junio C Hamano1-3/+7
The scripted version relied on the nice "auto-strip the terminating LF" behaviour shell gives to "var=$(cmd)" construct, but we have to roll that ourselves. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09Re-fix "builtin-commit: fix --signoff"Libravatar Junio C Hamano1-2/+2
An earlier fix to the said commit was incomplete; it mixed up the meaning of the flag parameter passed to the internal fmt_ident() function, so this corrects it. git_author_info() and git_committer_info() can be told to issue a warning when no usable user information is found, and optionally can be told to error out. Operations that actually use the information to record a new commit or a tag will still error out, but the caller to leave reflog record will just silently use bogus user information. Not warning on misconfigured user information while writing a reflog entry is somewhat debatable, but it is probably nicer to the users to silently let it pass, because the only information you are losing is who checked out the branch. * git_author_info() and git_committer_info() used to take 1 (positive int) to error out with a warning on misconfiguration; this is now signalled with a symbolic constant IDENT_ERROR_ON_NO_NAME. * These functions used to take -1 (negative int) to warn but continue; this is now signalled with a symbolic constant IDENT_WARN_ON_NO_NAME. * fmt_ident() function implements the above error reporting behaviour common to git_author_info() and git_committer_info(). A symbolic constant IDENT_NO_DATE can be or'ed in to the flag parameter to make it return only the "Name <email@address.xz>". * fmt_name() is a thin wrapper around fmt_ident() that always passes IDENT_ERROR_ON_NO_NAME and IDENT_NO_DATE. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09Fix commit-msg hook to allow editingLibravatar Junio C Hamano1-4/+5
The old git-commit.sh script allowed the commit-msg hook to not only prevent a commit from proceding, but also to edit the commit message on the fly and allow it to proceed. So here we teach builtin-commit to do the same. This is based on Wincent's patch, but redone with a clarified logic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09Allow --no-verify to bypass commit-msg hookLibravatar Wincent Colaiuta1-1/+2
At the moment the --no-verify switch to "git commit" instructs it to skip over the pre-commit hook. Here we teach "git commit --no-verify" to skip over the commit-msg hook as well. This brings the behaviour of builtin-commit back in line with git-commit.sh. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-08add status.relativePaths config variableLibravatar Jeff King1-1/+2
The output of git-status was recently changed to output relative paths. Setting this variable to false restores the old behavior for any old-timers that prefer it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>