summaryrefslogtreecommitdiff
path: root/builtin/commit.c
AgeCommit message (Collapse)AuthorFilesLines
2012-11-15ident: keep separate "explicit" flags for author and committerLibravatar Jeff King1-2/+2
We keep track of whether the user ident was given to us explicitly, or if we guessed at it from system parameters like username and hostname. However, we kept only a single variable. This covers the common cases (because the author and committer will usually come from the same explicit source), but can miss two cases: 1. GIT_COMMITTER_* is set explicitly, but we fallback for GIT_AUTHOR. We claim the ident is explicit, even though the author is not. 2. GIT_AUTHOR_* is set and we ask for author ident, but not committer ident. We will claim the ident is implicit, even though it is explicit. This patch uses two variables instead of one, updates both when we set the "fallback" values, and updates them individually when we read from the environment. Rather than keep user_ident_sufficiently_given as a compatibility wrapper, we update the only two callers to check the committer_ident, which matches their intent and what was happening already. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-18status: add --long output format optionLibravatar Jeff King1-6/+23
You can currently set the output format to --short or --porcelain. There is no --long, because we default to it already. However, you may want to override an alias that uses "--short" to get back to the default. This requires a little bit of refactoring, because currently we use STATUS_FORMAT_LONG internally to mean the same as "the user did not specify anything". By expanding the enum to include STATUS_FORMAT_NONE, we can distinguish between the implicit and explicit cases. This effects these conditions: 1. The user has asked for NUL termination. With NONE, we currently default to turning on the porcelain mode. With an explicit --long, we would in theory use NUL termination with the long mode, but it does not support it. So we can just complain and die. 2. When an output format is given to "git commit", we default to "--dry-run". This behavior would now kick in when "--long" is given, too. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-01Merge branch 'os/commit-submodule-ignore'Libravatar Junio C Hamano1-0/+1
"git status" honored the ignore=dirty settings in .gitmodules but "git commit" didn't. * os/commit-submodule-ignore: commit: pay attention to submodule.$name.ignore in .gitmodules
2012-09-24commit: pay attention to submodule.$name.ignore in .gitmodulesLibravatar Orgad Shaneh1-0/+1
"git status" does not list a submodule with uncommitted working tree files as modified when "submodule.$name.ignore" is set to "dirty" in in-tree ".gitmodules" file. Both status and commit honor the setting in $GIT_DIR/config, but "commit" does not pick it up from .gitmodules, which is inconsistent. Teach "git commit" to pay attention to the setting in .gitmodules as well. Signed-off-by: Orgad Shaneh <orgads@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-14cherry-pick: don't forget -s on failureLibravatar Miklos Vajna1-57/+24
In case 'git cherry-pick -s <commit>' failed, the user had to use 'git commit -s' (i.e. state the -s option again), which is easy to forget about. Instead, write the signed-off-by line early, so plain 'git commit' will have the same result. Also update 'git commit -s', so that in case there is already a relevant Signed-off-by line before the Conflicts: line, it won't add one more at the end of the message. If there is no such line, then add it before the the Conflicts: line. Signed-off-by: Miklos Vajna <vmiklos@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-11Merge branch 'jc/maint-ident-missing-human-name'Libravatar Junio C Hamano1-1/+16
"git show --format='%ci'" did not give timestamp correctly for commits created without human readable name on "committer" line. * jc/maint-ident-missing-human-name: split_ident_line(): make best effort when parsing author/committer line
2012-08-31split_ident_line(): make best effort when parsing author/committer lineLibravatar Junio C Hamano1-1/+16
Commits made by ancient version of Git allowed committer without human readable name, like this (00213b17c in the kernel history): tree 6947dba41f8b0e7fe7bccd41a4840d6de6a27079 parent 352dd1df32e672be4cff71132eb9c06a257872fe author Petr Baudis <pasky@ucw.cz> 1135223044 +0100 committer <sam@mars.ravnborg.org> 1136151043 +0100 kconfig: Remove support for lxdialog --checklist ... Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> When fed such a commit, --format='%ci' fails to parse it, and gives back an empty string. Update the split_ident_line() to be a bit more lenient when parsing, but make sure the caller that wants to pick up sane value from its return value does its own validation. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-24Merge branch 'jk/maint-commit-check-committer-early' into maint-1.7.11Libravatar Junio C Hamano1-1/+1
* jk/maint-commit-check-committer-early: commit: check committer identity more strictly
2012-08-20i18n: status: mark parseopt strings for translationLibravatar Nguyễn Thái Ngọc Duy1-11/+11
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-20i18n: commit: mark parseopt strings for translationLibravatar Nguyễn Thái Ngọc Duy1-39/+39
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-24Merge branch 'jk/maint-commit-check-committer-early'Libravatar Junio C Hamano1-1/+1
"git commit --amend" let the user edit the log message and then died when the human-readable committer name was given insufficiently by getpwent(3). * jk/maint-commit-check-committer-early: commit: check committer identity more strictly
2012-07-23commit: check committer identity more strictlyLibravatar Jeff King1-1/+1
The identity of the committer will ultimately be pulled from the ident code by commit_tree(). However, we make an attempt to check the author and committer identity early, before the user has done any manual work like inputting a commit message. That lets us abort without them having to worry about salvaging the work from .git/COMMIT_EDITMSG. The early check for committer ident does not use the IDENT_STRICT flag, meaning that it would not find an empty name field. The motivation was presumably because we did not want to be too restrictive, as later calls might be more lax (for example, when we create the reflog entry, we do not care too much about a real name). However, because commit_tree will always get a strict identity to put in the commit object itself, there is no point in being lax only to die later (and in fact it is harmful, because the user will have wasted time typing their commit message). Incidentally, this bug was masked prior to 060d4bb, as the initial loose call would taint the later strict call. So the commit would succeed (albeit with a bogus committer line in the commit object), and nobody noticed that our early check did not match the later one. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22Merge branch 'cw/amend-commit-without-message' into maintLibravatar Junio C Hamano1-1/+1
"commit --amend" used to refuse amending a commit with an empty log message, with or without "--allow-empty-message". * cw/amend-commit-without-message: Allow edit of empty message with commit --amend
2012-07-22Merge branch 'jk/maint-commit-amend-only-no-paths' into maintLibravatar Junio C Hamano1-1/+4
"git commit --amend --only --" was meant to allow "Clever" people to rewrite the commit message without making any change even when they have already changes for the next commit added to their index, but it never worked as advertised since it was introduced in 1.3.0 era. * jk/maint-commit-amend-only-no-paths: commit: fix "--amend --only" with no pathspec
2012-07-15Merge branch 'jk/maint-commit-amend-only-no-paths'Libravatar Junio C Hamano1-1/+4
"git commit --amend --only --" was meant to allow "Clever" people to rewrite the commit message without making any change even when they have already changes for the next commit added to their index, but it never worked as advertised since it was introduced in 1.3.0 era. * jk/maint-commit-amend-only-no-paths: commit: fix "--amend --only" with no pathspec
2012-07-15Merge branch 'cw/amend-commit-without-message'Libravatar Junio C Hamano1-1/+1
"commit --amend" used to refuse amending a commit with an empty log message, with or without "--allow-empty-message". * cw/amend-commit-without-message: Allow edit of empty message with commit --amend
2012-07-09Allow edit of empty message with commit --amendLibravatar Chris Webb1-1/+1
"git commit --amend" used on a commit with an empty message fails unless -m is given, whether or not --allow-empty-message is specified. Allow it to proceed to the editor with an empty commit message. Unless --allow-empty-message is in force, it will still abort later if an empty message is saved from the editor (this check was already necessary to prevent a non-empty commit message being edited to an empty one). Add a test for --amend --edit of an empty commit message which fails without this fix, as it's a rare case that won't get frequently tested otherwise. Signed-off-by: Chris Webb <chris@arachsys.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-24ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICTLibravatar Jeff King1-2/+1
Callers who ask for ERROR_ON_NO_NAME are not so much concerned that the name will be blank (because, after all, we will fall back to using the username), but rather it is a check to make sure that low-quality identities do not end up in things like commit messages or emails (whereas it is OK for them to end up in things like reflogs). When future commits add more quality checks on the identity, each of these callers would want to use those checks, too. Rather than modify each of them later to add a new flag, let's refactor the flag. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-08status: refactor colopts handlingLibravatar Jeff King1-5/+4
The current code reads the config and command-line options into a separate "colopts" variable, and then copies the contents of that variable into the "struct wt_status". We can eliminate the extra variable and copy just write straight into the wt_status struct. This simplifies the "status" code a little bit. Unfortunately, it makes the "commit" code one line more complex; a side effect of the separate variable was that "commit" did not copy the colopts variable, so any column.status configuration had no effect. The result still ends up cleaner, though. In the previous version, it was unclear whether commit simply forgot to copy the colopt variable, or whether it was intentional. Now it explicitly turns off column options. Furthermore, if commit later learns to respect column.status, this will make the end result simpler. I punted on just adding that feature now, because it was sufficiently non-obvious that it should not go into a refactoring patch. Signed-off-by: Jeff King <peff@peff.net>
2012-05-08Merge branch 'jk/maint-status-porcelain-z-b' into HEADLibravatar Jeff King1-68/+67
* jk/maint-status-porcelain-z-b: status: respect "-b" for porcelain format status: fix null termination with "-b" status: refactor null_termination option commit: refactor option parsing Conflicts: wt-status.h
2012-05-08status: respect "-b" for porcelain formatLibravatar Jeff King1-5/+4
There is no reason not to, as the user has to explicitly ask for it, so we are not breaking compatibility by doing so. We can do this simply by moving the "show_branch" flag into the wt_status struct. As a bonus, this saves us from passing it explicitly, simplifying the code. Signed-off-by: Jeff King <peff@peff.net>
2012-05-08status: refactor null_termination optionLibravatar Jeff King1-9/+8
This option is passed separately to the wt_status printing functions, whereas every other formatting option is contained in the wt_status struct itself. Let's do the same here, so we can avoid passing it around through the call stack. Signed-off-by: Jeff King <peff@peff.net>
2012-05-08commit: refactor option parsingLibravatar Jeff King1-58/+59
The options are declared as a static global, but really they need only be accessible from cmd_commit. Additionally, declare the "struct wt_status" in cmd_commit and cmd_status as static at the top of each function; this will let the options lists reference them directly, which will facilitate further cleanups. Signed-off-by: Jeff King <peff@peff.net>
2012-05-03Merge branch 'nd/columns'Libravatar Junio C Hamano1-0/+7
A couple of commands learn --column option to produce columnar output. By Nguyễn Thái Ngọc Duy (9) and Zbigniew Jędrzejewski-Szmek (1) * nd/columns: tag: add --column column: support piping stdout to external git-column process status: add --column branch: add --column help: reuse print_columns() for help -a column: add dense layout support t9002: work around shells that are unable to set COLUMNS to 1 column: add columnar layout Stop starting pager recursively Add column layout skeleton and git-column
2012-04-30git-commit: remove lego in i18n messagesLibravatar Ævar Arnfjörð Bjarmason1-7/+6
Change the "Please enter the commit message for your changes." and the subsequent blurb of text not to be split up. This makes translating it much easier. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30git-commit: remove lego in i18n messagesLibravatar Ævar Arnfjörð Bjarmason1-29/+23
Remove the whence_s() function and messages that depend on it, in favor of messages that use either "merge" or "cherry-pick" directly. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-27status: add --columnLibravatar Nguyễn Thái Ngọc Duy1-0/+7
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26Merge branch 'jc/commit-unedited-template' into maintLibravatar Junio C Hamano1-19/+43
When "git commit --template F" errors out because the user did not touch the message, it claimed that it aborts due to "empty message", which was utterly wrong. By Junio C Hamano (4) and Adam Monsen (1) * jc/commit-unedited-template: Documentation/git-commit: rephrase the "initial-ness" of templates git-commit.txt: clarify -t requires editing message commit: rephrase the error when user did not touch templated log message commit: do not trigger bogus "has templated message edited" check t7501: test the right kind of breakage
2012-04-26Merge branch 'jc/commit-hook-authorship' into maintLibravatar Junio C Hamano1-3/+19
"git commit --author=$name" did not tell the name that was being recorded in the resulting commit to hooks, even though it does do so when the end user overrode the authorship via the "GIT_AUTHOR_NAME" environment variable. * jc/commit-hook-authorship: commit: pass author/committer info to hooks t7503: does pre-commit-hook learn authorship? ident.c: add split_ident_line() to parse formatted ident line
2012-04-16Merge branch 'jc/commit-unedited-template'Libravatar Junio C Hamano1-19/+43
When "git commit --template F" errors out because the user did not touch the message, it claimed that it aborts due to "empty message", which was utterly wrong. By Junio C Hamano (4) and Adam Monsen (1) * jc/commit-unedited-template: Documentation/git-commit: rephrase the "initial-ness" of templates git-commit.txt: clarify -t requires editing message commit: rephrase the error when user did not touch templated log message commit: do not trigger bogus "has templated message edited" check t7501: test the right kind of breakage
2012-04-15Merge branch 'jc/commit-hook-authorship'Libravatar Junio C Hamano1-3/+19
"git commit --author=$name" did not tell the name that was being recorded in the resulting commit to hooks, even though it does do so when the end user overrode the authorship via the "GIT_AUTHOR_NAME" environment variable. * jc/commit-hook-authorship: commit: pass author/committer info to hooks t7503: does pre-commit-hook learn authorship? ident.c: add split_ident_line() to parse formatted ident line
2012-03-30commit: rephrase the error when user did not touch templated log messageLibravatar Junio C Hamano1-19/+41
When the user exited editor without editing the commit log template given by "git commit -t <template>", the commit was aborted (correct) with an error message that said "due to empty commit message" (incorrect). This was because the original template support was done by piggybacking on the check to detect an empty log message. Split the codepaths into two independent checks to clarify the error. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-30commit: do not trigger bogus "has templated message edited" checkLibravatar Junio C Hamano1-0/+2
When "-t template" and "-F msg" options are both given (or worse yet, there is "commit.template" configuration but a message is given in some other way), the documentation says that template is ignored. However, the "has the user edited the message?" check still used the contents of the template file as the basis of the emptyness check. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-11commit: pass author/committer info to hooksLibravatar Junio C Hamano1-3/+19
When lying the author name via GIT_AUTHOR_NAME environment variable to "git commit", the hooks run by the command saw it and could act on the name that will be recorded in the final commit. When the user uses the "--author" option from the command line, the command should give the same information to the hook, and back when "git command" was a scripted Porcelain, it did set the environment variable and hooks can learn the author name from it. However, when the command was reimplemented in C, the rewritten code was not very faithful to the original, and hooks stopped getting the authorship information given with "--author". Fix this by exporting the necessary environment variables. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-16Merge branch 'jx/i18n-more-marking' into maintLibravatar Junio C Hamano1-3/+3
* jx/i18n-more-marking: i18n: format_tracking_info "Your branch is behind" message i18n: git-commit whence_s "merge/cherry-pick" message
2012-02-13Merge branch 'jc/parse-date-raw' into maintLibravatar Junio C Hamano1-0/+6
* jc/parse-date-raw: parse_date(): '@' prefix forces git-timestamp parse_date(): allow ancient git-timestamp
2012-02-12Merge branch 'nd/cache-tree-api-refactor'Libravatar Junio C Hamano1-2/+2
* nd/cache-tree-api-refactor: cache-tree: update API to take abitrary flags
2012-02-10Merge branch 'jc/parse-date-raw'Libravatar Junio C Hamano1-0/+6
* jc/parse-date-raw: parse_date(): '@' prefix forces git-timestamp parse_date(): allow ancient git-timestamp
2012-02-07cache-tree: update API to take abitrary flagsLibravatar Nguyễn Thái Ngọc Duy1-2/+2
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-03parse_date(): '@' prefix forces git-timestampLibravatar Junio C Hamano1-0/+6
The only place that the issue this series addresses was observed where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE in order to replay a commit with an ancient timestamp. With the previous patch alone, "git commit --date='20100917 +0900'" can be misinterpreted to mean an ancient timestamp, not September in year 2010. Guard this codepath by requring an extra '@' in front of the raw git timestamp on the parsing side. This of course needs to be compensated by updating get_author_ident_from_commit and the code for "git commit --amend" to prepend '@' to the string read from the existing commit in the GIT_AUTHOR_DATE environment variable. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-01i18n: git-commit whence_s "merge/cherry-pick" messageLibravatar Jiang Xin1-3/+3
Mark the "merge/cherry-pick" messages in whence_s for translation. These messages returned from whence_s function are used as argument to build other messages. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-06Merge branch 'jc/show-sig'Libravatar Junio C Hamano1-2/+12
* jc/show-sig: log --show-signature: reword the common two-head merge case log-tree: show mergetag in log --show-signature output log-tree.c: small refactor in show_signature() commit --amend -S: strip existing gpgsig headers verify_signed_buffer: fix stale comment gpg-interface: allow use of a custom GPG binary pretty: %G[?GS] placeholders test "commit -S" and "log --show-signature" log: --show-signature commit: teach --gpg-sign option Conflicts: builtin/commit-tree.c builtin/commit.c builtin/merge.c notes-cache.c pretty.c
2012-01-05commit --amend -S: strip existing gpgsig headersLibravatar Junio C Hamano1-1/+2
Any existing commit signature was made against the contents of the old commit, including its committer date that is about to change, and will become invalid by amending it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-05Merge branch 'jc/signed-commit' and 'jc/pull-signed-tag'Libravatar Junio C Hamano1-1/+10
They both use the extended headers in commit objects, and the former has necessary infrastructure to show them that is useful to view the result of the latter. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-22Merge branch 'jk/maint-strbuf-missing-init'Libravatar Junio C Hamano1-1/+1
* jk/maint-strbuf-missing-init: commit, merge: initialize static strbuf Conflicts: builtin/merge.c
2011-12-22Merge branch 'nd/war-on-nul-in-commit'Libravatar Junio C Hamano1-1/+1
* nd/war-on-nul-in-commit: commit_tree(): refuse commit messages that contain NULs Convert commit_tree() to take strbuf as message merge: abort if fails to commit Conflicts: builtin/commit.c commit.c commit.h
2011-12-21Sync with v1.7.8.1Libravatar Junio C Hamano1-1/+1
2011-12-21Merge branch 'ms/commit-cc-option-helpstring' into maintLibravatar Junio C Hamano1-1/+1
* ms/commit-cc-option-helpstring: builtin/commit: add missing '/' in help message
2011-12-20Merge branch 'jc/pull-signed-tag'Libravatar Junio C Hamano1-1/+5
* jc/pull-signed-tag: commit: do not lose mergetag header when not amending
2011-12-20commit: do not lose mergetag header when not amendingLibravatar Junio C Hamano1-1/+5
The earlier ed7a42a (commit: teach --amend to carry forward extra headers, 2011-11-08) broke "git merge/pull; edit to fix conflict; git commit" workflow by forgetting that commit_tree_extended() takes the whole extra header list. Signed-off-by: Junio C Hamano <gitster@pobox.com>