Commit graph

67 commits

Author SHA1 Message Date
Shawn O. Pearce de61e42b53 Merge branch 'jc/am-quiet'
* jc/am-quiet:
  git-am: fix typo in the previous one.
  git-am: make the output quieter.
2007-10-18 03:45:05 -04:00
Junio C Hamano 0341091a9e Merge branch 'jc/autogc'
* jc/autogc:
  git-gc --auto: run "repack -A -d -l" as necessary.
  git-gc --auto: restructure the way "repack" command line is built.
  git-gc --auto: protect ourselves from accumulated cruft
  git-gc --auto: add documentation.
  git-gc --auto: move threshold check to need_to_gc() function.
  repack -A -d: use --keep-unreachable when repacking
  pack-objects --keep-unreachable
  Export matches_pack_name() and fix its return value
  Invoke "git gc --auto" from commit, merge, am and rebase.
  Implement git gc --auto
2007-10-03 03:05:32 -07:00
Junio C Hamano 076d7aa5d4 git-am: fix typo in the previous one.
Caught on #git by Ulrik Sverdrup

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-01 00:27:51 -07:00
Junio C Hamano 1f08819101 git-am: make the output quieter.
We used to say "Applying <patch subject>", "Wrote <tree
object>", and "Committed <commit object>".  Worse yet, with
extra blank lines around them.

Make the output more concise.  The object names are not so
useful nor interesting.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-29 20:45:33 -07:00
Junio C Hamano 52d5bc9a16 Merge branch 'js/apply-build-ancestor'
* js/apply-build-ancestor:
  apply: get rid of --index-info in favor of --build-fake-ancestor
2007-09-23 21:16:33 -07:00
David Kastrup 822f7c7349 Supplant the "while case ... break ;; esac" idiom
A lot of shell scripts contained stuff starting with

	while case "$#" in 0) break ;; esac

and similar.  I consider breaking out of the condition instead of the
body od the loop ugly, and the implied "true" value of the
non-matching case is not really obvious to humans at first glance.  It
happens not to be obvious to some BSD shells, either, but that's
because they are not POSIX-compliant.  In most cases, this has been
replaced by a straight condition using "test".  "case" has the
advantage of being faster than "test" on vintage shells where "test"
is not a builtin.  Since none of them is likely to run the git
scripts, anyway, the added readability should be worth the change.

A few loops have had their termination condition expressed
differently.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-23 16:12:00 -07:00
Johannes Schindelin 7a98869935 apply: get rid of --index-info in favor of --build-fake-ancestor
git-am used "git apply -z --index-info" to find the original versions
of the files touched by the diff, to be able to do an inexpensive
three-way merge.

This operation makes only sense in a repository, since the index
information in the diff refers to blobs, which have to be present in
the current repository.

Therefore, teach "git apply" a mode to write out the result as an
index file to begin with, obviating the need for scripts to do it
themselves.

The sole user for --index-info is "git am" is converted to
use --build-fake-ancestor in this patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-18 17:41:18 -07:00
Junio C Hamano d4bb43ee27 Invoke "git gc --auto" from commit, merge, am and rebase.
The point of auto gc is to pack new objects created in loose
format, so a good rule of thumb is where we do update-ref after
creating a new commit.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-06 00:08:56 -07:00
Brian Hetro 1560be16b9 Make usage documentation for git-am consistent.
The usage information in git-am.sh now matches that of the
documentation.

Signed-off-by: Brian Hetro <whee@smaertness.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-25 22:35:35 -07:00
Gerrit Pape 3f0a8f3c01 git-am: initialize variable $resume on startup
git-am expects the variable $resume to be empty or unset, which might not
be the case if $resume is set in the user's environment.  So initialize
it to an empty value on startup.

The problem was noticed by Pierre Habouzit and reported through
 http://bugs.debian.org/435807

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-06 16:16:27 -07:00
Johannes Schindelin ca193cf1ad git am: skip pine's internal folder data
Test if the From: line contains "Mail System Internal Data" and if
it is, skip this mail.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-24 20:48:04 -07:00
Adam Roben ef0c2abf3e Add GIT_EDITOR environment and core.editor configuration variables
These variables let you specify an editor that will be launched in
preference to the EDITOR and VISUAL environment variables. The order
of preference is GIT_EDITOR, core.editor, EDITOR, VISUAL.

[jc: added a test and config variable documentation]

Signed-off-by: Adam Roben <aroben@apple.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-20 00:46:34 -07:00
Johannes Schindelin b4372ef136 Enable "git rerere" by the config variable rerere.enabled
Earlier, "git rerere" was enabled by creating the directory
.git/rr-cache.  That is definitely not in line with most other
features, which are enabled by a config variable.

So, check the config variable "rerere.enabled". If it is set
to "false" explicitely, do not activate rerere, even if
.git/rr-cache exists. This should help when you want to disable
rerere temporarily.

If "rerere.enabled" is not set at all, fall back to detection
of the directory .git/rr-cache.

[jc: with minimum tweaks]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-06 22:39:15 -07:00
Junio C Hamano 5be60078c9 Rewrite "git-frotz" to "git frotz"
This uses the remove-dashes target to replace "git-frotz" to "git frotz".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-02 22:52:14 -07:00
Jeff King a23bfaed7d More echo "$user_message" fixes.
Here are fixes to more uses of 'echo "$msg"' where $msg could contain
backslashed sequence.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-26 00:33:03 -07:00
Jeff King 4b7cc26a74 git-am: use printf instead of echo on user-supplied strings
Under some implementations of echo (such as that provided by
dash), backslash escapes are recognized without any other
options. This means that echo-ing user-supplied strings may
cause any backslash sequences in them to be converted. Using
printf resolves the ambiguity.

This bug can be seen when using git-am to apply a patch
whose subject contains the character sequence "\n"; the
characters are converted to a literal newline. Noticed by
Szekeres Istvan.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-25 21:43:33 -07:00
Josh Triplett 6777c3806d Fix typo in git-am: s/Was is/Was it/
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-23 22:14:24 -07:00
Alex Riesen 06aff47b22 Use diff* with --exit-code in git-am, git-rebase and git-merge-ours
This simplifies the shell code, reduces its memory footprint, and
speeds things up. The performance improvements should be noticable
when git-rebase works on big commits.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-24 23:01:36 -07:00
Don Zickus 87ab799234 builtin-mailinfo.c infrastrcture changes
I am working on a project that required parsing through regular
mboxes that didn't necessarily have patches embedded in them.  I
started by creating my own modified copy of git-am and working
from there.  Very quickly, I noticed git-mailinfo wasn't able to
handle a big chunk of my email.

After hacking up numerous solutions and running into more
limitations, I decided it was just easier to rewrite a big chunk
of it.  The following patch has a bunch of fixes and features
that I needed in order for me do what I wanted.

Note: I'm didn't follow any email rfc papers but I don't think
any of the changes I did required much knowledge (besides the
boundary stuff).

List of major changes/fixes:
- can't create empty patch files fix
- empty patch files don't fail, this failure will come inside git-am
- multipart boundaries are now handled
- only output inbody headers if a patch exists otherwise assume those
headers are part of the reply and instead output the original headers
- decode and filter base64 patches correctly
- various other accidental fixes

I believe I didn't break any existing functionality or
compatibility (other than what I describe above, which is really
only the empty patch file).

I tested this through various mailing list archives and
everything seemed to parse correctly (a couple thousand emails).

[jc: squashed in another patch from Don's five patch series to
 fix the test case, as this patch exposes the bug in the test.]

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-12 23:33:41 -07:00
Junio C Hamano b1440cc806 Reword git-am 3-way fallback failure message.
When the blobs recorded on the index lines in the patch as pre-image
blobs are not found in the repository, "git-am" punted saying
that the index line does not record anything useful.  This was not
clear enough -- the index line does have something useful but the
problem was that it was not useful in _that_ repository.

Reword the message as Francis Moreau suggests.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-24 01:06:19 -08:00
Junio C Hamano 2092a1fefd Teach git-am to pass -p option down to git-apply
This is originally from Andy Parkins whose patch used --patchdepth; let's
use -p which is more in line with the underlying git-apply.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-11 22:05:36 -08:00
Michael S. Tsirkin 67dad687ad add -C[NUM] to git-am
Add -C[NUM] to git-am and git-rebase so that patches can be applied even
if context has changed a bit.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-08 15:23:52 -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
Junio C Hamano bb1091a475 -u is now default for 'git-mailinfo'.
Originally from David Woodhouse, but also adjusts the callers of
mailinfo to the new default.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-09 21:32:49 -08:00
Junio C Hamano 3cf167ba4b git-am: should work when "--no-utf8 --utf8" is given
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-09 21:16:45 -08:00
Junio C Hamano d84029b673 --utf8 is now default for 'git-am'
Since we are talking about allowing potentially incompatible UI
changes in v1.5.0 iff the change improves the general situation,
I would say why not.

There is --no-utf8 flag to avoid re-coding from botching the log
message just in case, but we may not even need it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08 14:45:59 -08:00
Shawn O. Pearce 579c9bb198 Use merge-recursive in git-am -3.
By switching from merge-resolve to merge-recursive in the 3-way
fallback behavior of git-am we gain a few benefits:

 * renames are automatically handled, like in rebase -m;
 * conflict hunks can reference the patch name;
 * its faster on Cygwin (less forks).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-28 19:06:16 -08:00
Shawn O. Pearce f94741324e Use GIT_REFLOG_ACTION environment variable instead.
Junio rightly pointed out that the --reflog-action parameter
was starting to get out of control, as most porcelain code
needed to hand it to other porcelain and plumbing alike to
ensure the reflog contained the top-level user action and
not the lower-level actions it invoked.

At Junio's suggestion we are introducing the new set_reflog_action
function to all shell scripts, allowing them to declare early on
what their default reflog name should be, but this setting only
takes effect if the caller has not already set the GIT_REFLOG_ACTION
environment variable.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-28 01:05:15 -08:00
Shawn O. Pearce 64646d1177 Suggest 'add' in am/revert/cherry-pick.
Now that we have decided to make 'add' behave like 'update-index'
(and therefore fully classify update-index as strictly plumbing)
the am/revert/cherry-pick family of commands should not steer the
user towards update-index.  Instead send them to the command they
probably already know, 'add'.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-21 20:33:49 -08:00
Eric Wong f131dd492f rerere: record (or avoid misrecording) resolved, skipped or aborted rebase/am
Data in rr-cache isn't valid after a patch application is
skipped or and aborted, so our next commit could be misrecorded
as a resolution of that skipped/failed commit, which is wrong.

git-am --skip, git-rebase --skip/--abort will automatically
invoke git-rerere clear to avoid this.

Also, since git-am --resolved indicates a resolution was
succesful, remember to run git-rerere to record the resolution
(and not surprise the user when the next commit is made).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-09 11:13:36 -08:00
Junio C Hamano c95b138985 Fix git-am safety checks
An earlier commit cbd64af added a check that prevents "git-am"
to run without its standard input connected to a terminal while
resuming operation.  This was to catch a user error to try
feeding a new patch from its standard input while recovery.

The assumption of the check was that it is an indication that a
new patch is being fed if the standard input is not connected to
a terminal.  It is however not quite correct (the standard input
can be /dev/null if the user knows the operation does not need
any input, for example).  This broke t3403 when the test was run
with its standard input connected to /dev/null.

When git-am is given an explicit command such as --skip, there
is no reason to insist that the standard input is a terminal; we
are not going to read a new patch anyway.

Credit goes to Gerrit Pape for noticing and reporting the
problem with t3403-rebase-skip test.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-16 02:23:04 -07:00
Junio C Hamano fd7bcfb524 git-am: give better diagnostics when the patch does not apply during --3way
If the user tries to apply a patch that was hand-edited in such
a way that it does not apply to the original file recorded on
its "index" line anymore, we did detect the situation but did
not issue an error message that is specific enough.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-12 17:08:07 -07:00
Lukas Sandström cbd64afbb3 git-am: Don't accept an mbox on stdin of we already have a .dotest directory
It makes no sense to accept an mbox via stdin when we
won't accept it on the commandline.

The patch helps the following scenario:

# git init-db
"add file1 with content"
# git checkout -b apply
"edit file1 && commit"

# git checkout -b conflict master
"edit file1 && commit"

# git checkout -b ok master
"add file2"

# git checkout apply
# git format-patch -k -3 master..conflict | git am -k -3
=> git-am fails with a conflict message
# git reset --hard

# git format-patch -k -3 master..ok | git am -k -3
=> git am fails with the same conflict message as above,
=> since it's trying to apply the old .dotest directory

With the patch it complains about an old .dotest
directory instead.

Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-23 23:58:40 -07:00
Shawn Pearce 8ef1c7c77d Record rebase changes as 'rebase' in the reflog.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:08:24 -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
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 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
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
Junio C Hamano 4cb0e688d8 Merge branch 'jc/apply' into next
* jc/apply:
  git-am: use apply --cached
  apply --cached: apply a patch without using working tree.
2006-05-15 17:58:02 -07:00
Junio C Hamano b7627278e2 git-am: use apply --cached
Now 'git apply' can apply patch without working tree, preparation
of pristine preimage and postimage trees that are done when falling
back on 3-way merge by "git am" can do so without temporary files.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-15 17:57:01 -07:00
Sean cc120056a8 Make git rebase interactive help match documentation.
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-14 16:28:32 -07:00
Robert Shearman ced9456a27 Give the user a hint for how to continue in the case that git-am fails because it requires user intervention
Give the user a hint for how to continue in the case that git-am fails
because it requires user intervention.

Signed-off-by: Robert Shearman <rob@codeweaves.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-02 12:42:12 -07:00
Junio C Hamano c1d1128bef git-am --resolved: more usable error message.
After doing the hard work of hand resolving the conflicts in the
working tree, if the user forgets to run update-index to mark
the paths that have been resolved, the command gave an
unfriendly "fatal: git-write-tree: not able to write tree" error
message.  Catch the situation early and give more meaningful
message and suggestion.

Noticed and suggested by Len Brown.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-28 02:32:44 -07:00
Junio C Hamano 8273c79ae2 war on whitespaces: documentation.
We were missing the --whitespace option in the usage string for
git-apply and git-am, so this commit adds them.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-02 00:52:59 -08:00
Junio C Hamano 8c31cb822f git-am: --whitespace=x option.
This is passed down to git-apply to override the built-in
default and per-repository configuration at runtime.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-28 22:34:57 -08:00
Junio C Hamano 6d28644d69 git-am: do not allow empty commits by mistake.
Running "git-am --resolved" without doing anything can create an empty
commit. Prevent it.

Thanks for Eric W. Biederman for spotting this.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-23 22:14:47 -08:00
Junio C Hamano d64e6b0429 Keep Porcelainish from failing by broken ident after making changes.
"empty ident not allowed" error makes commit-tree fail, so we
are already safer in that we would not end up with commit
objects that have bogus names on the author or committer fields.
However, before commit-tree is called there are already changes
made to the index file and the working tree.  The operation can
be resumed after fixing the environment problem, but when this
triggers to a newcomer with unusable gecos, the first question
becomes "what did I lose and how would I recover".

This patch modifies some Porcelainish commands to verify
GIT_COMMITTER_IDENT as soon as we know we are going to make some
commits before doing much damage to prevent confusion.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-22 13:14:57 -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 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