Commit graph

35 commits

Author SHA1 Message Date
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
Junio C Hamano bba319b5ce commit: detect misspelled pathspec while making a partial commit.
When you say "git commit Documentaiton" to make partial commit
for the files only in that directory, we did not detect that as
a misspelled pathname and attempted to commit index without
change.  If nothing matched, there is no harm done, but if the
index gets modified otherwise by having another valid pathspec
or after an explicit update-index, a user will not notice
without paying attention to the "git status" preview.

This introduces --error-unmatch option to ls-files, and uses it
to detect this common user error.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-14 14:48:22 -08:00
Junio C Hamano 4170a19587 git-commit: Now --only semantics is the default.
This changes the "git commit paths..." to default to --only
semantics from traditional --include semantics, as agreed on the
list.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-12 23:55:07 -08:00
Junio C Hamano 1536dd9c61 Only call git-rerere if $GIT_DIR/rr-cache exists.
Johannes noticed that git-rerere depends on Digest.pm, and if
one does not use the command, one can live without it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-11 18:55:43 -08:00
Junio C Hamano 9ae6be8016 git-commit -v: have patch at the end.
It was pointed out that otherwise more important summary
information prefixed with '#' would become prone to be missed.

Also instead of chopping at the first '^---$' line, stop at the
first 'diff --git a/' line.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-10 18:44:31 -08:00
Junio C Hamano cf7bb589af git-status -v
This revamps the git-status command to take the same set of
parameters as git commit.  It gives a preview of what is being
committed with that command.  With -v flag, it shows the diff
output between the HEAD commit and the index that would be
committed if these flags were given to git-commit command.

git-commit also acquires -v flag (it used to mean "verify" but
that is the default anyway and there is --no-verify to turn it
off, so not much is lost), which uses the updated git-status -v
to seed the commit log buffer.  This is handy for writing a log
message while reviewing the changes one last time.

Now, git-commit and git-status are internally share the same
implementation.

Unlike previous git-commit change, this uses a temporary index
to prepare the index file that would become the real index file
after a successful commit, and moves it to the real index file
once the commit is actually made.  This makes it safer than the
previous scheme, which stashed away the original index file and
restored it after an aborted commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-10 00:54:49 -08:00
Junio C Hamano 5a798fb57f git-commit: finishing touches.
Introduce --only flag to allow the new "partial commit"
semantics when paths are specified.  The default is still the
traditional --include semantics.  Once peoples' fingers and
scripts that want the traditional behaviour are updated to
explicitly say --include, we could change it to either default
to --only, or refuse to operate without either --only/--include
when paths are specified.

This also fixes a couple of bugs in the previous round.  Namely:

 - forgot to save/restore index in some cases.

 - forgot to use the temporary index to show status when '--only
   paths...' semantics was used.

 - --author did not take precedence when reusing an existing
   commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06 23:20:32 -08:00
Junio C Hamano 130fcca63f git-commit: revamp the git-commit semantics.
- "git commit" without _any_ parameter keeps the traditional
   behaviour.  It commits the current index.

   We commit the whole index even when this form is run from a
   subdirectory.

 - "git commit --include paths..." (or "git commit -i paths...")
   is equivalent to:

   	git update-index --remove paths...
        git commit

 - "git commit paths..." acquires a new semantics.  This is an
   incompatible change that needs user training, which I am
   still a bit reluctant to swallow, but enough people seem to
   have complained that it is confusing to them.  It

   1. refuses to run if $GIT_DIR/MERGE_HEAD exists, and reminds
      trained git users that the traditional semantics now needs
      -i flag.

   2. refuses to run if named paths... are different in HEAD and
      the index (ditto about reminding).  Added paths are OK.

   3. reads HEAD commit into a temporary index file.

   4. updates named paths... from the working tree in this
      temporary index.

   5. does the same updates of the paths... from the working
      tree to the real index.

   6. makes a commit using the temporary index that has the
      current HEAD as the parent, and updates the HEAD with this
      new commit.

 - "git commit --all" can run from a subdirectory, but it updates
   the index with all the modified files and does a whole tree
   commit.

 - In all cases, when the command decides not to create a new
   commit, the index is left as it was before the command is
   run.  This means that the two "git diff" in the following
   sequence:

       $ git diff
       $ git commit -a
       $ git diff

   would show the same diff if you abort the commit process by
   making the commit log message empty.

This commit also introduces much requested --author option.

	$ git commit --author 'A U Thor <author@example.com>'

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06 23:20:32 -08:00
Junio C Hamano 8389b52b2a git-rerere: reuse recorded resolve.
In a workflow that employs relatively long lived topic branches,
the developer sometimes needs to resolve the same conflict over
and over again until the topic branches are done (either merged
to the "release" branch, or sent out and accepted upstream).

This commit introduces a new command, "git rerere", to help this
process by recording the conflicted automerge results and
corresponding hand-resolve results on the initial manual merge,
and later by noticing the same conflicted automerge and applying
the previously recorded hand resolution using three-way merge.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06 21:53:11 -08:00
Junio C Hamano 7334f06ce6 Do not fall back on vi on dumb terminals.
When TERM is set to 'dumb', do not start vi to edit the commit log
message.

Suggested by Amos Waterland.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-04 22:16:22 -08:00
Junio C Hamano aa66c7ec77 format-patch/commit: Quote single quote in the author name properly.
Noticed by Kyle McMartin.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-05 20:02:33 -08:00
Alex Riesen b6ae5409ea trivial: typo in git-commit.sh
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-05 17:23:16 -08:00
freku045@student.liu.se 806f36d4d7 Trivial usage string clean-up
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-14 02:53:43 -08:00
Junio C Hamano ae2b0f1518 git-sh-setup: die if outside git repository.
Now all the users of this script detect its exit status and die,
complaining that it is outside git repository.  So move the code
that dies from all callers to git-sh-setup script.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-25 13:49:17 -08:00
Junio C Hamano f678dd180a Prevent "git-commit -a path1 path2..."
When you want to create a partial commit, giving -a by mistake
would ignore the given path.  Prevent it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-25 13:33:14 -08:00
Junio C Hamano e3e291fc07 Do not lose author name information to locale gotchas.
I noticed format-patch loses authorship information of Lukas' patch
when I run git tools with LC_LANG set to ja_JP.  It turns out that
the sed script to set environment variables were not working on his
name (encoded in UTF-8), which is unfortunate but technically correct.

Force sed invocation under C locale because we always want literal byte
semantics.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-11 00:37:34 -08:00
Junio C Hamano e5215804de Do not put automatic merge message after signed-off-by line.
'git-commit -s' after a failed automerge inserted the automerge
message in a wrong place.  The signed-off-by line should come
last.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-01 22:01:28 -08:00
c.shoemaker@cox.net 0363ecf641 update usage string for git-commit.sh
Signed-off-by: Chris Shoemaker <c.shoemaker at cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-28 22:21:29 -07:00
Junio C Hamano 4bfe1199ea Teach git-add and git-commit to handle filenames starting with '-'.
Recent '--' fixes to "git diff" by Linus made it possible to specify
filenames that start with '-'.  But in order to do that, you need to
be able to add and commit such file to begin with.

Teach git-add and git-commit to honor the same '--' convention.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-18 00:27:50 -07:00
Santi_Béjar f8e2c54c9a Write .editmsg in GIT_DIR to avoid being in git-status.
It appears in the git-status output during a git-commit if you have
something in info/exclude.

Also for .cmitmsg and .cmitchk to make git-commit work
in read-only working trees.

[jc: while we are at it, I removed the use of .cmitchk temporary
     file which was not necessary, and renamed them -- they are out
     of way now and do not have to be dotfiles anymore.]

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-09 17:30:19 -07:00
Santi_Béjar df34297af1 [PATCH] Quote the missing GIT_DIR.
Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-05 11:23:23 -07:00
Junio C Hamano f6413391b1 Leave an empty line between log and sign-off.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-03 23:49:46 -07:00
Junio C Hamano 8098a178b2 Add git-symbolic-ref
This adds the counterpart of git-update-ref that lets you read
and create "symbolic refs".  By default it uses a symbolic link
to represent ".git/HEAD -> refs/heads/master", but it can be compiled
to use the textfile symbolic ref.

The places that did 'readlink .git/HEAD' and 'ln -s refs/heads/blah
.git/HEAD' have been converted to use new git-symbolic-ref command, so
that they can deal with either implementation.

Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-10-01 23:19:33 -07:00
Junio C Hamano bf7960eb51 Use git-update-ref in scripts.
This uses the git-update-ref command in scripts for safer updates.
Also places where we used to read HEAD ref by using "cat" were fixed
to use git-rev-parse.  This will matter when we start using symbolic
references.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-28 16:42:44 -07:00
Junio C Hamano 148ccbb038 git-commit: use update-index --stdin, instead of xargs.
Now update-index supports '-z --stdin', we do not have to rely on
platform xargs to support -0 option.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-27 16:59:45 -07:00
Junio C Hamano deca7e8c59 Give default merge message after failed automerge.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-26 18:04:17 -07:00
Junio C Hamano 91063bbc6c Multi-backend merge driver.
The new command 'git merge' takes the current head and one or more
remote heads, with the commit log message for the automated case.

If the heads being merged are simple fast-forwards, it acts the
same way as the current 'git resolve'.  Otherwise, it tries
different merge strategies and takes the result from the one that
succeeded auto-merging, if there is any.

If no merge strategy succeeds auto-merging, their results are
evaluated for number of paths needed for hand resolving, and the
one with the least number of such paths is left in the working
tree.  The user is asked to resolve them by hand and make a
commit manually.

The calling convention from the 'git merge' driver to merge
strategy programs is very simple:

 - A strategy program is to be called 'git-merge-<strategy>'.

 - They take input of this form:

	<common1> <common2> ... '--' <head> <remote1> <remote2>...

   That is, one or more the common ancestors, double dash, the
   current head, and one or more remote heads being merged into
   the current branch.

 - Before a strategy program is called, the working tree is
   matched to the current <head>.

 - The strategy program exits with status code 0 when it
   successfully auto-merges the given heads.  It should do
   update-cache for all the merged paths when it does so -- the
   index file will be used to record the merge result as a
   commit by the driver.

 - The strategy program exits with status code 1 when it leaves
   conflicts behind.  It should do update-cache for all the
   merged paths that it successfully auto-merged, and leave the
   cache entry in the index file as the same as <head> for paths
   it could not auto-merge, and leave its best-effort result
   with conflict markers in the working tree when it does so.

 - The strategy program exists with status code other than 0 or
   1 if it does not handle the given merge at all.

As examples, this commit comes with merge strategies based on
'git resolve' and 'git octopus'.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-10 18:30:41 -07:00
Junio C Hamano 215a7ad1ef Big tool rename.
As promised, this is the "big tool rename" patch.  The primary differences
since 0.99.6 are:

  (1) git-*-script are no more.  The commands installed do not
      have any such suffix so users do not have to remember if
      something is implemented as a shell script or not.

  (2) Many command names with 'cache' in them are renamed with
      'index' if that is what they mean.

There are backward compatibility symblic links so that you and
Porcelains can keep using the old names, but the backward
compatibility support  is expected to be removed in the near
future.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-07 17:45:20 -07:00
Renamed from git-commit-script (Browse further)