summaryrefslogtreecommitdiff
path: root/builtin-commit.c
AgeCommit message (Collapse)Author
2009-12-12status/commit: do not suggest "reset HEAD <path>" while mergingJunio C Hamano
Suggesting "'reset HEAD <path>' to unstage" is dead wrong if we are about to record a merge commit. For either an unmerged path (i.e. with unresolved conflicts), or an updated path, it would result in discarding what the other branch did. Note that we do not do anything special in a case where we are amending a merge. The user is making an evil merge starting from an already committed merge, and running "reset HEAD <path>" is the right way to get rid of the local edit that has been added to the index. Once "reset --unresolve <path>" becomes available, we might want to suggest it for a merged path that has unresolve information, but until then, just remove the incorrect advice. We might also want to suggest "checkout --conflict <path>" to revert the file in the work tree to the state of failed automerge for an unmerged path, but we never did that, and this commit does not change that. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-12commit/status: check $GIT_DIR/MERGE_HEAD only onceJunio C Hamano
The code checked for the MERGE_HEAD file to see if we were about to commit a merge twice in the codepath; also one of them used a variable merge_head_sha1[] which was set but was never used. Just check it once, but do so also in "git status", too, as we will be using this for status generation in the next patch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-07status: reduce duplicated setup codeJeff King
We have three output formats: short, porcelain, and long. The short and long formats respect user-config, and the porcelain one does not. This led to us repeating config-related setup code for the short and long formats. Since the last commit, color config is explicitly cleared when showing the porcelain format. Let's do the same with relative-path configuration, which enables us to hoist the duplicated code from the switch statement in cmd_status. As a bonus, this fixes "commit --dry-run --porcelain", which was unconditionally setting up that configuration, anyway. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-07status: disable color for porcelain formatJeff King
The porcelain format is identical to the shortstatus format, except that it should not respect any user configuration, including color. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-05status -s: obey color.statusMichael J Gruber
Make the short version of status obey the color.status boolean. We color the status letters only, because they carry the state information and are potentially colored differently, such as for a file with staged changes as well as changes in the worktree against the index. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-05builtin-commit: refactor short-status code into wt-status.cMichael J Gruber
Currently, builtin-commit.c contains most code producing the short-status output, whereas wt-status.c contains most of the code for the long format. Refactor so that most of the long and short format producing code resides in wt-status.c and is named analogously. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-27status -s: respect the status.relativePaths optionMichael J Gruber
Otherwise, 'status' and 'status -s' in a subdir would produce different names. This change is all the more important because status.relativePaths is on by default. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-06commit: support alternate status formatsJeff King
The status command recently grew "short" and "porcelain" options for alternate output formats. Since status is no longer "commit --dry-run", these formats are inaccessible to people who do want to see a dry-run in a parseable form. This patch makes those formats available to "git commit", implying the "dry-run" option when they are used. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-06status: add --porcelain output formatJeff King
The "short" format was added to "git status" recently to provide a less verbose way of looking at the same information. This has two practical uses: 1. Users who want a more dense display of the information. 2. Scripts which want to parse the information and need a stable, easy-to-parse interface. For now, the "--short" format covers both of those uses. However, as time goes on, users of (1) may want additional format tweaks, or for "git status" to change its behavior based on configuration variables. Those wishes will be at odds with (2), which wants to stability for scripts. This patch introduces a separate --porcelain option early to avoid problems later on. Right now the --short and --porcelain outputs are identical. However, as time goes on, we will have the freedom to customize --short for human consumption while keeping --porcelain stable. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-06status: refactor format option parsingJeff King
This makes it possible to have more than two formats. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-06status: refactor short-mode printing to its own functionJeff King
We want to be able to call it from multiple places. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-06status: typo fix in usageJeff King
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-22git status: not "commit --dry-run" anymoreJunio C Hamano
This removes tentative "git stat" and make it take over "git status". There are some tests that expect "git status" to exit with non-zero status when there is something staged. Some tests expect "git status path..." to show the status for a partial commit. For these, replace "git status" with "git commit --dry-run". For the ones that do not attempt a dry-run of a partial commit that check the output from the command, check the output from "git status" as well, as they should be identical. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-22git stat -s: short status outputJunio C Hamano
Give -s(hort) option to "git stat" that shows the status of paths in a more concise way. XY PATH1 -> PATH2 format to be more machine readable than output from "git status", which is about previewing of "git commit" with the same arguments. PATH1 is the path in the HEAD, and " -> PATH2" part is shown only when PATH1 corresponds to a different path in the index/worktree. For unmerged entries, X shows the status of stage #2 (i.e. ours) and Y shows the status of stage #3 (i.e. theirs). For entries that do not have conflicts, X shows the status of the index, and Y shows the status of the work tree. For untracked paths, XY are "??". X Y Meaning ------------------------------------------------- [MD] not updated M [ MD] updated in index A [ MD] added to index D [ MD] deleted from index R [ MD] renamed in index C [ MD] copied in index [MARC] index and work tree matches [ MARC] M work tree changed since index [ MARC] D deleted in work tree D D unmerged, both deleted A U unmerged, added by us U D unmerged, deleted by them U A unmerged, added by them D U unmerged, deleted by us A A unmerged, both added U U unmerged, both modified ? ? untracked When given -z option, the records are terminated by NUL characters for better machine readability. Because the traditional long format is designed for human consumption, NUL termination does not make sense. For this reason, -z option implies -s (short output). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-22git stat: the beginning of "status that is not a dry-run of commit"Junio C Hamano
Tentatively add "git stat" as a new command. This is not "preview of commit with the same arguments"; the path parameters are not paths to be added to the pristine index (aka "--only" option), but are taken as pathspecs to limit the output. Later in 1.7.0 release, it will take over "git status". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15git commit --dry-run -v: show diff in color when askedJunio C Hamano
The earlier implementation of --dry-run didn't duplicate the use of color "git status -v" set up for diff output. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-10Make git_status_config() file scope static to builtin-commit.cJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-10wt-status: move many global settings to wt_status structureJunio C Hamano
Turn four global variables (wt_status_use_color, show_tracked_files, wt_status_relative_paths, and wt_status_submodule_summary) into fields of wt_status structure. They can also lose "wt_status_" prefix. Get rid of "untracked" field that was used only to keep track of otherwise available information redundantly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-08commit: --dry-runJunio C Hamano
This teaches --dry-run option to "git commit". It is the same as "git status", but in the longer term we would want to change the semantics of "git status" not to be the preview of commit, and this is the first step for doing so. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-06wt-status.c: rework the way changes to the index and work tree are summarizedJunio C Hamano
Introduce a new infrastructure to find and summarize changes in a single string list, and rewrite wt_status_print_{updated,changed} functions using it. The goal of this change is to give more information on conflicted paths in the status output. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-27Use die_errno() instead of die() when checking syscallsThomas Rast
Lots of die() calls did not actually report the kind of error, which can leave the user confused as to the real problem. Use die_errno() where we check a system/library call that sets errno on failure, or one of the following that wrap such calls: Function Passes on error from -------- -------------------- odb_pack_keep open read_ancestry fopen read_in_full xread strbuf_read xread strbuf_read_file open or strbuf_read_file strbuf_readlink readlink write_in_full xwrite Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-27Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast
Change calls to die(..., strerror(errno)) to use the new die_errno(). In the process, also make slight style adjustments: at least state _something_ about the function that failed (instead of just printing the pathname), and put paths in single quotes. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-25parse-opts: add OPT_FILENAME and transition builtinsStephen Boyd
Commit dbd0f5c (Files given on the command line are relative to $cwd, 2008-08-06) introduced parse_options_fix_filename() as a minimal fix. OPT_FILENAME is intended to be a more robust fix for the same issue. OPT_FILENAME and its associated enum OPTION_FILENAME are used to represent filename options within the parse options API. This option is similar to OPTION_STRING. If --no is prefixed to the option the filename is unset. If no argument is given and the default value is set, the filename is set to the default value. The difference is that the filename is prefixed with the prefix passed to parse_options() (or parse_options_start()). Update git-apply, git-commit, git-fmt-merge-msg, and git-tag to use OPT_FILENAME with their filename options. Also, rename parse_options_fix_filename() to fix_filename() as it is no longer extern. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-25parse-opts: prepare for OPT_FILENAMEStephen Boyd
To give OPT_FILENAME the prefix, we pass the prefix to parse_options() which passes the prefix to parse_options_start() which sets the prefix member of parse_opts_ctx accordingly. If there isn't a prefix in the calling context, passing NULL will suffice. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-23commit: -F overrides -tStephen Boyd
Commit dbd0f5c7 (Files given on the command line are relative to $cwd, 2008-08-06) introduced parse_options_fix_filename() as a quick fix for filename arguments used in the parse options API. git-commit was still broken. This means git commit -F log -t temp in a subdirectory would make git think the log message should be taken from temp instead of log. This is because parse_options_fix_filename() calls prefix_filename() which uses a single static char buffer to do its work. Making two calls with two char pointers causes the pointers to alias. To prevent aliasing, we duplicate the string returned by parse_options_fix_filename(). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-05Merge branch 'maint-1.6.1' into maintJunio C Hamano
* maint-1.6.1: commit: abort commit if interactive add failed git-repack: use non-dashed update-server-info
2009-04-05Merge branch 'maint-1.6.0' into maint-1.6.1Junio C Hamano
* maint-1.6.0: commit: abort commit if interactive add failed git-repack: use non-dashed update-server-info Conflicts: builtin-commit.c
2009-04-05commit: abort commit if interactive add failedJeff King
Previously we ignored the result of calling add_interactive, which meant that if an error occurred we simply committed whatever happened to be in the index. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-11Generalize and libify index_is_dirty() to index_differs_from(...)Stephan Beyer
index_is_dirty() in builtin-revert.c checks if the index is dirty. This patch generalizes this function to check if the index differs from a revision, i.e. the former index_is_dirty() behavior can now be achieved by index_differs_from("HEAD", 0). The second argument "diff_flags" allows to set further diff option flags like DIFF_OPT_IGNORE_SUBMODULES. See DIFF_OPT_* macros in diff.h for a list. index_differs_from() seems to be useful for more than builtin-revert.c, so it is moved into diff-lib.c and also used in builtin-commit.c. Yet to mention: - "rev.abbrev = 0;" can be safely removed. This has no impact on performance or functioning of neither setup_revisions() nor run_diff_index(). - rev.pending.objects is free()d because this fixes a leak. (Also see 295dd2ad "Fix memory leak in traverse_commit_list") Mentored-by: Daniel Barkalow <barkalow@iabervon.org> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-29Merge branch 'mh/maint-commit-color-status' into maintJunio C Hamano
* mh/maint-commit-color-status: git-status -v: color diff output when color.ui is set git-commit: color status output when color.ui is set
2009-01-26Merge branch 'cb/add-pathspec'Junio C Hamano
* cb/add-pathspec: remove pathspec_match, use match_pathspec instead clean up pathspec matching
2009-01-22Merge branch 'sb/hook-cleanup'Junio C Hamano
* sb/hook-cleanup: run_hook(): allow more than 9 hook arguments run_hook(): check the executability of the hook before filling argv api-run-command.txt: talk about run_hook() Move run_hook() from builtin-commit.c into run-command.c (libgit) checkout: don't crash on file checkout before running post-checkout hook
2009-01-20commit: more compact summary and without extra quotesSanti Béjar
Update the report format again to save the screen real estates, while avoiding from enclosing the one-line summary of the commit log inside double quotes pair, which looks awkward when the message begins or ends with a double quote. The old format looked like this: [master]: created d9a5491: "foo:bar" Simply removing the double quotes were found to be confusing as a message often begins with a short-word (area of the system) and a colon. The new format looks like this: [master d9a5491] foo:bar As discussed in the git mailing list: http://thread.gmane.org/gmane.comp.version-control.git/101687/focus=101735 Signed-off-by: Santi Béjar <santi@agolina.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-18Merge branch 'mh/maint-commit-color-status'Junio C Hamano
* mh/maint-commit-color-status: git-status -v: color diff output when color.ui is set git-commit: color status output when color.ui is set
2009-01-18Merge branch 'maint-1.6.0' into maintJunio C Hamano
* maint-1.6.0: builtin-fsck: fix off by one head count Documentation: let asciidoc align related options githooks.txt: add missing word builtin-commit.c: do not remove COMMIT_EDITMSG
2009-01-18builtin-commit.c: do not remove COMMIT_EDITMSGStephan Beyer
git-commit tries to remove the file ./COMMIT_EDITMSG instead of $GIT_DIR/COMMIT_EDITMSG after commit preparation (e.g. running hooks, launching editor). This behavior exists since f5bbc3225c4b07 "Port git commit to C". Some test cases (e.g. t/t7502-commit.sh) rely on the existence of $GIT_DIR/COMMIT_EDITMSG after committing and, I guess, many people are used to it. So it is best not to remove it. This patch just removes the removal of COMMIT_EDITMSG. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-18Move run_hook() from builtin-commit.c into run-command.c (libgit)Stephan Beyer
A function that runs a hook is used in several Git commands. builtin-commit.c has the one that is most general for cases without piping. The one in builtin-gc.c prints some useful warnings. This patch moves a merged version of these variants into libgit and lets the other builtins use this libified run_hook(). The run_hook() function used in receive-pack.c feeds the standard input of the pre-receive or post-receive hooks. This function is renamed to run_receive_hook() because the libified run_hook() cannot handle this. Mentored-by: Daniel Barkalow <barkalow@iabervon.org> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-15remove pathspec_match, use match_pathspec insteadClemens Buchacher
Both versions have the same functionality. This removes any redundancy. This also adds makes two extensions to match_pathspec: - If pathspec is NULL, return 1. This reflects the behavior of git commands, for which no paths usually means "match all paths". - If seen is NULL, do not use it. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-09git-status -v: color diff output when color.ui is setMarkus Heidelberg
When using "git status -v", the diff output wasn't colored, even though color.ui was set. Only when setting color.diff it worked. Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-09git-commit: color status output when color.ui is setMarkus Heidelberg
When using "git commit" and there was nothing to commit (the editor wasn't launched), the status output wasn't colored, even though color.ui was set. Only when setting color.status it worked. Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-13builtin-commit: remove unused message variableMarkus Heidelberg
builtin-commit uses commit_tree() from builtin-commit-tree since 6bb6b03 (builtin-commit: use commit_tree(), 2008-09-10), where the same message is used. Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-01git add --intent-to-add: do not let an empty blob be committed by accidentJunio C Hamano
Writing a tree out of an index with an "intent to add" entry is blocked. This implies that you cannot "git commit" from such a state; however you can still do "git commit -a" or "git commit $that_path". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-15Add cache preload facilityLinus Torvalds
This can do the lstat() storm in parallel, giving potentially much improved performance for cold-cache cases or things like NFS that have weak metadata caching. Just use "read_cache_preload()" instead of "read_cache()" to force an optimistic preload of the index stat data. The function takes a pathspec as its argument, allowing us to preload only the relevant portion of the index. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-13Merge branch 'jk/maint-commit-v-strip'Junio C Hamano
* jk/maint-commit-v-strip: commit: Fix stripping of patch in verbose mode.
2008-11-12commit: Fix stripping of patch in verbose mode.Jeff King
When the "-v" option is given, we put diff of what is to be committed into the commit template, and then strip it back out again after the user has edited it. We used to look for the diff by searching for the "diff --git a/" header. With diff.mnemonicprefix set in the configuration, however, this pattern does not match. The pattern is loosened to cover this case. Also, if the user puts their own diff in the message (e.g., as a sample output), then we will accidentally trigger the pattern, removing part of their output. We can avoid doing this stripping altogether if the user didn't use "-v" in the first place, so we know that any match we find will be a false positive. [jc: this fix was split out of a series originally meant for master.] Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-22Merge branch 'jc/maint-co-track'Junio C Hamano
* jc/maint-co-track: Enhance hold_lock_file_for_{update,append}() API demonstrate breakage of detached checkout with symbolic link HEAD Fix "checkout --track -b newbranch" on detached HEAD Conflicts: builtin-commit.c
2008-10-19Merge branch 'mv/merge-noff'Junio C Hamano
* mv/merge-noff: builtin-commit: use reduce_heads() only when appropriate Conflicts: builtin-commit.c t/t7600-merge.sh
2008-10-19Enhance hold_lock_file_for_{update,append}() APIJunio C Hamano
This changes the "die_on_error" boolean parameter to a mere "flags", and changes the existing callers of hold_lock_file_for_update/append() functions to pass LOCK_DIE_ON_ERROR. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-18Merge branch 'pb/commit-where'Junio C Hamano
* pb/commit-where: tutorial: update output of git commit reformat informational commit message git commit: Reformat output somewhat builtin-commit.c: show on which branch a commit was added
2008-10-12Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerBrandon Casey
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>