Commit graph

77 commits

Author SHA1 Message Date
Junio C Hamano 23913dc713 honor GIT_REFLOG_ACTION in git-commit
This allows git-cherry-pick and git-revert to properly identify
themselves in the resulting reflog entries.  Earlier they were
recorded as what git-commit has done.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-03 15:17:49 -08:00
Junio C Hamano dbaa06a2b0 git-commit -s: no extra space when sign-offs appear at the end already.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-29 01:06:27 -08:00
Tom Prince e0d10e1c63 [PATCH] Rename git-repo-config to git-config.
Signed-off-by: Tom Prince <tom.prince@ualberta.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-28 16:16:53 -08:00
Peter Eriksen 497171e765 Documentation: --amend cannot be combined with -c/-C/-F.
We used to get the following confusing error message:

    $ git commit --amend -a -m foo
    Option -m cannot be combined with -c/-C/-F

This is because --amend cannot be combined with -c/-C/-F, which makes
sense, because they try to handle the same log message in different ways.
So update the documentation to reflect this.

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-24 15:32:52 -08:00
Junio C Hamano 83e24dce14 [PATCH] honor --author even with --amend, -C, and -c.
Earlier code discarded GIT_AUTHOR_DATE taken from the base
commit when --author was specified.  This was often wrong as
that use is likely to fix the spelling of author's name.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-22 19:40:57 -08:00
Junio C Hamano f4b6c6b90f Merge branch 'jc/int'
* jc/int:
  More tests in t3901.
  Consistent message encoding while reusing log from an existing commit.
  t3901: test "format-patch | am" pipe with i18n
  Use log output encoding in --pretty=email headers.
2007-01-14 12:04:25 -08:00
Junio C Hamano 5ac2715f2e Consistent message encoding while reusing log from an existing commit.
The following commands can reuse log message from an existing
commit while creating a new commit:

	git-cherry-pick
	git-rebase (both with and without --merge)
	git-commit (-c and -C)

When the original commit was made in a different encoding from
the current i18n.commitencoding, "cat-file commit" would give a
string that is inconsistent with what the resulting commit will
claim to be in.  Replace them with "git show -s --encoding".

"git-rebase" without --merge is "git format-patch" piped to "git
am" in essence, and has been taken care of before this commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-13 13:33:07 -08:00
Junio C Hamano 514c09fdcf Use cd_to_toplevel in scripts that implement it by hand.
This converts scripts that do "cd $(rev-parse --show-cdup)" by
hand to use cd_to_toplevel.

I think git-fetch does not have to go to the toplevel, but that
should be dealt with in a separate patch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-12 16:54:38 -08:00
Junio C Hamano e861ce1692 Merge branch 'jc/bare'
* jc/bare:
  Disallow working directory commands in a bare repository.
  git-fetch: allow updating the current branch in a bare repository.
  Introduce is_bare_repository() and core.bare configuration variable
  Move initialization of log_all_ref_updates
2007-01-11 16:50:36 -08:00
Shawn O. Pearce 7eff28a9b4 Disallow working directory commands in a bare repository.
If the user tries to run a porcelainish command which requires
a working directory in a bare repository they may get unexpected
results which are difficult to predict and may differ from command
to command.

Instead we should detect that the current repository is a bare
repository and refuse to run the command there, as there is no
working directory associated with it.

[jc: updated Shawn's original somewhat -- bugs are mine.]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-10 15:03:09 -08:00
Michael Loeffler 521f9c4def git-commit: do not fail to print the diffstat even if there is a file named HEAD
Signed-off-by: Michael Loeffler <zvpunry@zvpunry.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08 14:45:59 -08:00
Junio C Hamano 96a738c0dd Remove unused variable (git-commit.sh)
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-01 23:42:53 -08:00
Shawn O. Pearce aeb80c70ec Suggest use of "git add file1 file2" when there is nothing to commit.
If a user modifies files and runs 'git commit' (without the very
useful -a option) and they have not yet updated the index they
are probably coming from another SCM-like tool which would perform
the same as 'git commit -a' in this case.  Showing the user their
current status and a final line of "nothing to commit" is not very
reassuring, as the user might believe that Git did not recognize
their files were modified.

Instead we can suggest as part of the 'nothing to commit' message
that the user invoke 'git add' to add files to their next commit.

Suggested by Andy Parkins' Git 'niggles' list
(<200612132237.10051.andyparkins@gmail.com>).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-15 22:31:01 -08:00
Nicolas Pitre ebd124c678 make commit message a little more consistent and conforting
It is nicer to let the user know when a commit succeeded all the time,
not only the first time.  Also the commit sha1 is much more useful than
the tree sha1 in this case.

This patch also introduces a -q switch to supress this message as well
as the summary of created/deleted files.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-15 22:29:54 -08:00
Junio C Hamano 78ba00407c Merge branch 'np/addcommit'
* np/addcommit:
  git-commit: allow --only to lose what was staged earlier.
  Documentation/git-commit: rewrite to make it more end-user friendly.
  make 'git add' a first class user friendly interface to the index
2006-12-13 11:08:20 -08:00
Junio C Hamano 158d057789 git-commit: allow --only to lose what was staged earlier.
The command used to have a safety valve to prevent this sequence:

	edit foo
	git update-index foo
	edit foo
	git diff foo
	git commit --only foo

The reason for this was because an inexperienced user might
mistakenly think what is shown with the last-minute diff
contains all the change that is being committed (instead, what
the user asked to check was an incremental diff since what has
been staged so far).  However, this turns out to only annoy
people who know what they are doing.  Inexperienced people
would not be using the first "update-index" anyway, in which
case they would see the full changes in the "git diff".

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-10 14:50:40 -08:00
Junio C Hamano 61f5cb7f0d git-commit: show --summary after successful commit.
Sometimes people accidentally commit files in wrong mode bits.
Show --summary output for the HEAD commit after successful commit
as a final sanity check.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-25 00:20:01 -08:00
Junio C Hamano 58a1e0e83b Merge branch 'lj/refs'
* lj/refs: (63 commits)
  Fix show-ref usagestring
  t3200: git-branch testsuite update
  sha1_name.c: avoid compilation warnings.
  Make git-branch a builtin
  ref-log: fix D/F conflict coming from deleted refs.
  git-revert with conflicts to behave as git-merge with conflicts
  core.logallrefupdates thinko-fix
  git-pack-refs --all
  core.logallrefupdates create new log file only for branch heads.
  Remove bashism from t3210-pack-refs.sh
  ref-log: allow ref@{count} syntax.
  pack-refs: call fflush before fsync.
  pack-refs: use lockfile as everybody else does.
  git-fetch: do not look into $GIT_DIR/refs to see if a tag exists.
  lock_ref_sha1_basic does not remove empty directories on BSD
  Do not create tag leading directories since git update-ref does it.
  Check that a tag exists using show-ref instead of looking for the ref file.
  Use git-update-ref to delete a tag instead of rm()ing the ref file.
  Fix refs.c;:repack_without_ref() clean-up path
  Clean up "git-branch.sh" and add remove recursive dir test cases.
  ...
2006-11-01 08:48:50 -08:00
Luben Tuikov a9cb3c6ecb git-revert with conflicts to behave as git-merge with conflicts
In a busy project, reverting a commit almost always results
in a conflict between one or more files (depending on the
commit being reverted).  It is useful to record this
conflict in the commit-to-be message of the resulting commit
(after the resolve).  The process now becomes:

git-revert <SHA-1>
<git complains and prints failed automatic>
<user manually resolves>
git-update-index <resolved files>
git-commit -s

And the commit message is now a merge of the revert commit
message and the conflict commit message, giving the user a
chance to edit it or add more information:

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-15 23:06:31 -07:00
Martin Waitz 3de63c3f9f git-commit: fix coding style.
git-commit.sh was using a mixture of spaces and tabs for indentation.
This is changed to one tab per indentation level.
No code changes.

Signed-off-by: Martin Waitz <tali@admingilde.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-07 21:28:17 -07:00
Martin Waitz c065b6e429 git-commit: cleanup unused function.
The report() function is not used anymore. Kill it.

Signed-off-by: Martin Waitz <tali@admingilde.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-03 23:58:38 -07:00
Junio C Hamano cede752653 update a few Porcelain-ish for ref lock safety.
This updates the use of git-update-ref in git-branch, git-tag
and git-commit to make them safer in a few corner cases as
demonstration.

 - git-tag makes sure that the named tag does not exist, allows
   you to edit tag message and then creates the tag.  If a tag
   with the same name was created by somebody else in the
   meantime, it used to happily overwrote it.  Now it notices
   the situation.

 - git-branch -d and git-commit (for the initial commit) had the
   same issue but with smaller race window, which is plugged
   with this.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-27 02:06:31 -07:00
Johannes Schindelin 2074cb0af3 Teach runstatus about --untracked
Actually, teach runstatus what to do if it is not passed; it should not list
the contents of completely untracked directories, but only the name of that
directory (plus a trailing '/').

[jc: with comments by Jeff King to match hide-empty-directories
 behaviour of the original.]

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-12 23:20:17 -07:00
Jeff King c91f0d92ef git-commit.sh: convert run_status to a C builtin
This creates a new git-runstatus which should do roughly the same thing
as the run_status function from git-commit.sh. Except for color support,
the main focus has been to keep the output identical, so that it can be
verified as correct and then used as a C platform for other improvements to
the status printing code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-08 16:46:35 -07:00
Alex Riesen 3dffd2c828 Do not use perl in git-commit.sh
git-commit.sh has the only one place where perl is used
and there it can quite trivially be done in sh.

git-ls-files without "-z" produces quoted output, even if
is different from that produced by perl code it is good
enough.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 22:00:16 -07:00
Shawn Pearce a3a733e63b Record the type of commit operation in the reflog.
If committing a merge (.git/MERGE_HEAD exists), an initial tree
(no HEAD) or using --amend to amend the prior commit then denote
the subtype of commit in the reflog.  This helps to distinguish
amended or merge commits from normal commits.

In the case of --amend the prior sha1 is probably the commit which
is being thrown away in favor of the new commit.  Since it is likely
that the old commit doesn't have any ref pointing to it anymore
it can be interesting to know why that the commit was replaced
and orphaned.

In the case of a merge the prior sha1 is probably the first parent
of the new merge commit.  Consequently having its prior sha1 in the
reflog is slightly less interesting but its still informative to
know the commit was the result of a merge which had to be completed
by hand.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-10 21:21:16 -07:00
Pavel Roskin 82e5a82fd7 Fix more typos, primarily in the code
The only visible change is that git-blame doesn't understand
"--compability" anymore, but it does accept "--compatibility" instead,
which is already documented.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-10 00:36:44 -07:00
Michal Rokos d9bffc08fd Using 'perl' in *.sh
Some GIT's shell script are using bare 'perl' for perl invocation.
Use @@PERL@@ symbol and replace it with PERL_PATH_SQ everywhere.

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-08 11:35:20 -07:00
Junio C Hamano cc7d5bcf00 Racy GIT (part #3)
Commit 29e4d36357 fixed the
underlying update-index races but git-commit was not careful
enough to preserve the index file timestamp when copying the
index file.  This caused t3402 test to occasionally fail.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-29 14:48:22 -07:00
Dennis Stosberg 8096fae726 Fix expr usage for FreeBSD
Some implementations of "expr" (e.g. FreeBSD's) fail, if an
argument starts with a dash.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-27 10:56:05 -07:00
Junio C Hamano 1ef9e05dbf Merge branch 'jc/squash'
* jc/squash:
  git-merge --squash
2006-06-26 14:36:10 -07:00
Yann Dirson 29f4ad867c git-commit: filter out log message lines only when editor was run.
The current behaviour strips out lines starting with a # even when fed
through stdin or -m.  This is particularly bad when importing history from
another SCM (tailor 0.9.23 uses git-commit).  In the best cases all lines
are stripped and the commit fails with a confusing "empty log message"
error, but in many cases the commit is done, with loss of information.

Note that it is quite peculiar to just have "#" handled as a leading
comment char here.  One commonly meet CVS: or CG: or STG: as prefixes, and
using GIT: would be more robust as well as consistent with other commit
tools.  However, that would break any tool relying on the # (if any).

Signed-off-by: Yann Dirson <ydirson@altern.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25 00:35:52 -07:00
Junio C Hamano 7d0c68871a git-merge --squash
Some people tend to do many little commits on a topic branch,
recording all the trials and errors, and when the topic is
reasonably cooked well, would want to record the net effect of
the series as one commit on top of the mainline, removing the
cruft from the history.  The topic is then abandoned or forked
off again from that point at the mainline.

The barebone porcelainish that comes with core git tools does
not officially support such operation, but you can fake it by
using "git pull --no-merge" when such a topic branch is not a
strict superset of the mainline, like this:

	git checkout mainline
	git pull --no-commit . that-topic-branch
	: fix conflicts if any
	rm -f .git/MERGE_HEAD
        git commit -a -m 'consolidated commit log message'
	git branch -f that-topic-branch ;# now fully merged

This however does not work when the topic branch is a fast
forward of the mainline, because normal "git pull" will never
create a merge commit in such a case, and there is nothing
special --no-commit could do to begin with.

This patch introduces a new option, --squash, to support such a
workflow officially in both fast-forward case and true merge
case.  The user-level operation would be the same in both cases:

	git checkout mainline
        git pull --squash . that-topic-branch
        : fix conflicts if any -- naturally, there would be
        : no conflict if fast forward.
	git commit -a -m  'consolidated commit log message'
	git branch -f that-topic-branch ;# now fully merged

When the current branch is already up-to-date with respect to
the other branch, there truly is nothing to do, so the new
option does not have any effect.

This was brought up in #git IRC channel recently.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-24 01:11:19 -07:00
Jeff King cda8ab59bb git-commit: allow -e option anywhere on command line
Previously, the command 'git-commit -e -m foo' would ignore the '-e' option
because the '-m' option overwrites the no_edit flag during sequential
option parsing. Now we cause -e to reset the no_edit flag after all
options are parsed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-23 16:55:51 -07:00
Junio C Hamano 5f625247ee Merge branch 'master' into next
* master:
  send-email: only 'require' instead of 'use' Net::SMTP
  Allow multiple -m options to git-commit.
2006-05-31 18:24:45 -07:00
Shawn Pearce 6891281cfa Allow multiple -m options to git-commit.
I find it very convenient to be able to supply multiple paragraphs
of text on the command line with a single git-commit call.  This
change permits multiple -m/--message type options to be supplied
to git-commit with each message being added as its own paragraph
of text in the commit message.

The -m option is still not permitted with -c/-C/-F nor are multiple
occurrences of these options permitted.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-31 15:40:47 -07:00
Junio C Hamano 2a0a1398ff Merge branch 'master' into next
* master:
  Call builtin ls-tree in git-cat-file -p
  built-in format-patch: various fixups.
  Add instructions to commit template.
2006-05-26 16:36:20 -07:00
Martin Waitz 88a1531435 Add instructions to commit template.
New users can be irritated by the git status text in their editor.
Let's give them a short help.

Signed-off-by: Martin Waitz <tali@admingilde.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-26 01:55:01 -07:00
Junio C Hamano dcaad49c92 Merge branch 'sp/reflog' into next
* sp/reflog:
  Enable ref log creation in git checkout -b.
  Create/delete branch ref logs.
  Include ref log detail in commit, reset, etc.
  Change order of -m option to update-ref.
  Correct force_write bug in refs.c
  Change 'master@noon' syntax to 'master@{noon}'.
  Log ref updates made by fetch.
  Force writing ref if it doesn't exist.
  Added logs/ directory to repository layout.
  General ref log reading improvements.
  Fix ref log parsing so it works properly.
  Support 'master@2 hours ago' syntax
  Log ref updates to logs/refs/<ref>
  Convert update-ref to use ref_lock API.
  Improve abstraction of ref lock/write.
2006-05-23 15:07:47 -07:00
Matthias Lederhofer 443f8338b9 git status: skip empty directories, and add -u to show all untracked files
By default, we use --others --directory to show uninteresting
directories (to get user's attention) without their contents (to
unclutter output).  Showing empty directories do not make sense,
so pass --no-empty-directory when we do so.

Giving -u (or --untracked) disables this uncluttering to let the
user get all untracked files.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-23 00:36:51 -07:00
Shawn Pearce 67644a4d77 Include ref log detail in commit, reset, etc.
When updating a ref at the direction of the user include a reason why
head was changed as part of the ref log (assuming it was enabled).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-19 15:03:21 -07:00
Sean ec4e69c06a Ensure author & committer before asking for commit message.
It's better to find out you need to fix your author and
committer information before you enter a long commit message.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-14 16:27:03 -07:00
Junio C Hamano 6a74642c50 git-commit --amend: two fixes.
When running "git commit --amend" only to fix the commit log
message without any content change, we mistakenly showed the
git-status output that says "nothing to commit" without
commenting it out.

If you have already run update-index but you want to amend the
top commit, "git commit --amend --only" without any paths should
have worked, because --only means "starting from the base
commit, update-index these paths only to prepare the index to
commit, and perform the commit".  However, we refused -o without
paths.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-20 02:51:12 -07:00
Mark Wooding f327dbced2 Shell utilities: Guard against expr' magic tokens.
Some words, e.g., `match', are special to expr(1), and cause strange
parsing effects.  Track down all uses of expr and mangle the arguments
so that this isn't a problem.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-13 16:45:48 -07:00
Junio C Hamano 475443c848 git-commit: do not muck with commit message when no_edit is set.
Spotted by Linus and Darrin Thompson.  When we took a commit
message from -F <file> with an incomplete line, we appended "git
status" output, which ended up attaching a lone "#" at the end.

We still need the "do we have anything to commit?" check by
running "status" (which has to know what to do in different
cases with -i/-o/-a), but there is no point appending its output
to the proposed commit message given by the user.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-12 11:45:18 -07:00
Yasushi SHOJI 1fa7a68f4b Be verbose when !initial commit
verbose option in git-commit.sh lead us to run git-diff-index, which
needs a commit-ish we are making diff against.  When we are commiting
the fist set, we obviously don't have any commit-ish in the repo.  So
we just skip the git-diff-index run.

It might be possible to produce diff against empty but do we need
that?

Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-20 14:37:59 -08:00
Junio C Hamano 8588452ceb git-commit --amend: allow empty commit.
When amending a commit only to update the commit log message, git-status
would rightly say "Nothing to commit."  Do not let this prevent commit to
be made.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-05 00:57:01 -08:00
Junio C Hamano b8310152bc git-commit: make sure we protect against races.
An earlier commit 8098a178b2
accidentally lost race protection from git-commit command.
This commit reinstates it.  When something else updates HEAD
pointer while you were editing your commit message, the command
would notice and abort the commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-02 21:13:24 -08:00
Junio C Hamano b4019f0456 git-commit --amend
The new flag is used to amend the tip of the current branch.  Prepare
the tree object you would want to replace the latest commit as usual
(this includes the usual -i/-o and explicit paths), and the commit log
editor is seeded with the commit message from the tip of the current
branch.  The commit you create replaces the current tip -- if it was a
merge, it will have the parents of the current tip as parents -- so the
current top commit is discarded.

It is a rough equivalent for:

	$ git reset --soft HEAD^
	$ ... do something else to come up with the right tree ...
	$ git commit -c ORIG_HEAD

but can be used to amend a merge commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-02 21:08:33 -08:00
Junio C Hamano 756e3ee0c6 Merge branch 'jc/commit'
* jc/commit:
  commit: detect misspelled pathspec while making a partial commit.
  combine-diff: diff-files fix (#2)
  combine-diff: diff-files fix.
2006-02-14 17:51:02 -08:00