Commit graph

93 commits

Author SHA1 Message Date
Junio C Hamano 08b51f51e6 Merge branch 'qq/maint'
* qq/maint:
  clone -q: honor "quiet" option over native transports.
  attribute documentation: keep EXAMPLE at end
  builtin-commit.c: Use 'git_config_string' to get 'commit.template'
  http.c: Use 'git_config_string' to clean up SSL config.
  diff.c: Use 'git_config_string' to get 'diff.external'
  convert.c: Use 'git_config_string' to get 'smudge' and 'clean'
  builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix'
  Documentation cvs: Clarify when a bare repository is needed
  Documentation: be precise about which date --pretty uses

Conflicts:

	Documentation/gitattributes.txt
2008-07-05 18:33:16 -07:00
Brian Hetro 984c6e7ec1 builtin-commit.c: Use 'git_config_string' to get 'commit.template'
Signed-off-by: Brian Hetro <whee@smaertness.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-05 17:42:54 -07:00
Junio C Hamano 1947bdbc31 Merge branch 'mo/status-untracked'
* mo/status-untracked:
  Add configuration option for default untracked files mode
  Add argument 'no' commit/status option -u|--untracked-files
  Add an optional <mode> argument to commit/status -u|--untracked-files option

Conflicts:

	Documentation/git-commit.txt
2008-06-22 14:32:27 -07:00
Cristian Peraferrer cdeaf10f7e Print errno upon failure to open the COMMIT_EDITMSG file
When the COMMIT_EDITMSG cannot be opened, give more information to the user
by giving the 'errno' information.

Signed-off-by: Cristian Peraferrer <corellian.c@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-21 00:01:37 -07:00
Marius Storm-Olsen 6c2ce048bb Add argument 'no' commit/status option -u|--untracked-files
This new argument teaches Git to not look for any untracked files,
saving cycles on slow file systems, or large repos.

Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
2008-06-09 15:48:19 -07:00
Marius Storm-Olsen 4bfee30a98 Add an optional <mode> argument to commit/status -u|--untracked-files option
This lets you specify how you want untracked files to be listed.
The possible options are:

    normal - Show untracked files and directories
    all    - Show all untracked files

The 'all' mode is used, if the mode is not specified.

Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
2008-06-09 15:47:36 -07:00
Junio C Hamano 67bfc030d7 commit: drop duplicated parents
The scripted version of git-commit internally used git-commit-tree which
omitted duplicated parents given from the command line.  This prevented a
nonsensical octopus merge from getting created even when you said "git
merge A B" while you are already on branch A.

However, when git-commit was rewritten in C, this sanity check was lost.
This resurrects it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-02 23:55:57 -07:00
Junio C Hamano b71ce7f3f1 Merge 1.5.5.3 in 2008-05-27 22:34:19 -07:00
Gerrit Pape d5350fd2b3 commit --interactive: properly update the index before commiting
When adding files through git commit --interactive, and 'quit'
afterwards, the message in the editor of the commit message indicates
that many (maybe all) files are deleted from the tree.  Dismissing that
and running git commit afterwards does the right thing.  This commit
fixes git commit --interactive to properly update the index before
commiting.

Reported by Jiří Paleček through
 http://bugs.debian.org/480429

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-27 22:32:47 -07:00
Junio C Hamano 9bd81e4249 Merge branch 'js/config-cb'
* js/config-cb:
  Provide git_config with a callback-data parameter

Conflicts:

	builtin-add.c
	builtin-cat-file.c
2008-05-25 14:25:02 -07:00
Junio C Hamano 9d880582ee Merge branch 'ar/add-unreadable'
* ar/add-unreadable:
  Add a config option to ignore errors for git-add
  Add a test for git-add --ignore-errors
  Add --ignore-errors to git-add to allow it to skip files with read errors
  Extend interface of add_files_to_cache to allow ignore indexing errors
  Make the exit code of add_file_to_index actually useful
2008-05-21 14:16:46 -07:00
Junio C Hamano b66ae7955c Merge branch 'sb/committer'
* sb/committer:
  commit: Show committer if automatic
  commit: Show author if different from committer
  Preparation to call determine_author_info from prepare_to_commit
2008-05-14 13:45:20 -07:00
Johannes Schindelin ef90d6d420 Provide git_config with a callback-data parameter
git_config() only had a function parameter, but no callback data
parameter.  This assumes that all callback functions only modify
global variables.

With this patch, every callback gets a void * parameter, and it is hoped
that this will help the libification effort.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-14 12:34:44 -07:00
Alex Riesen 7ae02a30e8 Extend interface of add_files_to_cache to allow ignore indexing errors
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-12 20:54:52 -07:00
Alex Riesen 960b8ad1b1 Make the exit code of add_file_to_index actually useful
Update the programs which used the function (as add_file_to_cache).

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-12 20:54:46 -07:00
Junio C Hamano 65ea3b8c6d Merge branch 'maint'
* 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-11 12:09:18 -07:00
Junio C Hamano 3e08f5db65 Merge branch 'maint-1.5.4' into maint
* 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-11 12:09:12 -07:00
Sitaram Chamarty e1645901ed builtin-commit.c: add -u as short name for --untracked-files
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-11 10:04:20 -07:00
Linus Torvalds d177cab048 Avoid some unnecessary lstat() calls
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-05-10 18:16:30 -07:00
Santi Béjar bb1ae3f6ff commit: Show committer if automatic
To warn the user in case he/she might be using an unintended
committer identity.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06 16:50:17 -07:00
Santi Béjar e83dbe802f commit: Show author if different from committer
That would help reassure anybody while committing other's changes.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06 16:43:52 -07:00
Santi Béjar a45d46ba72 Preparation to call determine_author_info from prepare_to_commit
Reorder functions definitions such that determine_author_info is
defined before prepare_to_commit. No code changes.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06 16:40:32 -07:00
Junio C Hamano 633d1fe9d0 Merge branch 'maint'
* maint:
  clone: detect and fail on excess parameters
  Remove 'header' from --signoff option description
2008-04-27 21:47:51 -07:00
Junio C Hamano 5736a37471 Merge branch 'maint-1.5.4' into maint
* maint-1.5.4:
  Remove 'header' from --signoff option description
2008-04-27 21:47:38 -07:00
Dan McGee 362b0dd523 Remove 'header' from --signoff option description
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-27 21:46:51 -07:00
Junio C Hamano d52301630f Merge branch 'jc/terminator-separator'
* jc/terminator-separator:
  log: teach "terminator" vs "separator" mode to "--pretty=format"
2008-04-19 21:10:54 -07:00
Junio C Hamano 4cdda2b895 Merge branch 'maint'
* 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-11 23:56:09 -07:00
Junio C Hamano eed81838f0 Merge branch 'maint-1.5.4' into maint
* 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-11 23:55:55 -07:00
Johannes Sixt 3c5283f8b1 builtin-commit.c: Remove a redundant assignment.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-11 23:03:50 -07:00
Johannes Sixt d4ba07cac5 Document option --only of git commit
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-11 12:54:15 -07:00
Junio C Hamano 4da45bef56 log: teach "terminator" vs "separator" mode to "--pretty=format"
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-04-10 03:25:03 -07:00
Linus Torvalds 34110cd4e3 Make 'unpack_trees()' have a separate source and destination index
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-09 01:03:38 -08:00
Linus Torvalds bc052d7f43 Make 'unpack_trees()' take the index to work on as an argument
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-03-09 00:43:48 -08:00
Junio C Hamano 5a4d707a6d Merge branch 'db/checkout'
* 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-27 12:53:26 -08:00
Matthias Kestenholz 6b2f2d9805 Add color.ui variable which globally enables colorization if set
Signed-off-by: Matthias Kestenholz <mk@spinlock.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-18 00:00:38 -08:00
Junio C Hamano 1ae419cb39 Merge branch 'pb/prepare-commit-msg'
* 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-16 17:56:59 -08:00
Junio C Hamano d5558581d2 Merge branch 'maint'
* 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-16 00:20:37 -08:00
Jeff King 959ba670ad commit: discard index after setting up partial commit
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-16 00:12:56 -08:00
Junio C Hamano e0197c9aae Merge branch 'lt/in-core-index'
* 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-11 16:46:20 -08:00
Junio C Hamano d865eb2a0d builtin-commit.c: guard config parser from value=NULL
commit.template configuration expects a string value.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11 13:11:36 -08:00
Gerrit Pape 5a95b85566 builtin-commit: remove .git/SQUASH_MSG upon successful commit
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-11 12:24:27 -08:00
Daniel Barkalow 203a2fe117 Allow callers of unpack_trees() to handle failure
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-09 23:16:51 -08:00
Paolo Bonzini 8089c85bcb git-commit: add a prepare-commit-msg hook
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-06 02:26:55 -08:00
Paolo Bonzini ec84bd000a git-commit: Refactor creation of log message.
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-06 02:26:02 -08:00
Paolo Bonzini 406400ce4f git-commit: set GIT_EDITOR=: if editor will not be launched
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-06 02:26:02 -08:00
Paolo Bonzini 3473f3035d git-commit: support variable number of hook arguments
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-06 02:26:02 -08:00
Junio C Hamano 8a2f87332b Fix "git-commit -C $tag"
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-02-03 00:56:35 -08:00
Brandon Casey 5a9dd3998f git-commit: exit non-zero if we fail to commit the index
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-23 10:10:11 -08:00
Linus Torvalds 7a51ed66f6 Make on-disk index representation separate from in-core one
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-21 12:44:31 -08:00
Brandon Casey 4ed7cd3ab0 Improve use of lockfile API
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-16 15:35:35 -08:00