Commit Graph

248 Commits

Author SHA1 Message Date
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
David Kågedal
6e598c326d Improved error message from git-rebase
If the index wasn't clean, git-rebase would simply show the output from
git-diff-index with no further comment to the user.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-31 13:16:52 -08:00
Junio C Hamano
bcf3161876 git-rebase: allow rebasing a detached HEAD.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-20 21:31:00 -08:00
Junio C Hamano
533b70390e Allow whole-tree operations to be started from a subdirectory
This updates five commands (merge, pull, rebase, revert and cherry-pick)
so that they can be started from a subdirectory.

This may not actually be what we want to do.  These commands are
inherently whole-tree operations, and an inexperienced user may
mistakenly expect a "git pull" from a subdirectory would merge
only the subdirectory the command started from.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-12 16:54:38 -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
Shawn O. Pearce
0bb733c91c Use branch names in 'git-rebase -m' conflict hunks.
If a three-way merge in git-rebase generates a conflict then we
should take advantage of git-merge-recursive's ability to include
the branch name of each side of the conflict hunk by setting the
GITHEAD_* environment variables.

In the case of rebase there aren't really two clear branches; we
have the branch we are rebasing onto, and we have the branch we are
currently rebasing.  Since most conflicts will be arising between
the user's current branch and the branch they are rebasing onto
we assume the stuff that isn't in the current commit is the "onto"
branch and the stuff in the current commit is the "current" branch.

This assumption may however come up wrong if the user resolves one
conflict in such a way that it conflicts again on a future commit
also being rebased.  In this case the user's prior resolution will
appear to be in the "onto" part of the hunk.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-28 01:07:32 -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
Junio C Hamano
228e2eb67e merge and reset: adjust for "reset --hard" messages
An earlier commit made "reset --hard" chattier but leaking its
message from "git rebase" (which calls it when first rewinding
the current branch to prepare replaying our own changes) without
explanation was confusing, so add an extra message to mention
it.  Inside restorestate in merge (which is rarely exercised
codepath, where more than one strategies are attempted),
resetting to the original state uses "reset --hard" -- this can
be squelched entirely.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-22 15:21:55 -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
7cdbff14d4 remove merge-recursive-old
This frees the Porcelain-ish that comes with the core Python-free.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-21 20:55:39 -08:00
Robert Shearman
b758789c20 git-rebase: Add a -v option to show a diffstat of the changes upstream at the start of a rebase.
Signed-off-by: Robert Shearman <rob@codeweavers.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-04 15:02:04 -07:00
Robert Shearman
91b489776c git-rebase: Use --ignore-if-in-upstream option when executing git-format-patch.
This reduces the number of conflicts when rebasing after a series of
patches to the same piece of code is committed upstream.

Signed-off-by: Robert Shearman <rob@codeweavers.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-04 15:02:04 -07:00
Junio C Hamano
a06f678eb9 Deprecate merge-recursive.py
This renames merge-recursive written in Python to merge-recursive-old,
and makes merge-recur as a synonym to merge-recursive.  We do not remove
merge-recur yet, but we will remove merge-recur and merge-recursive-old
in a few releases down the road.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-24 20:33:35 -07:00
Junio C Hamano
eed94a570e Merge branch 'master' into js/c-merge-recursive
Adjust to hold_lock_file_for_update() change on the master.
2006-08-12 18:35:14 -07:00
Robert Shearman
d587ed13bc rebase: Make the fast-fowarding message more user-friendly by using branch names instead of SHA1 IDs.
Signed-off-by: Robert Shearman <rob@codeweavers.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-31 00:15:59 -07:00
Robert Shearman
83c31614ce rebase: Fix the detection of fast-forwarding of the current branch to upstream.
Previously, a rebasing operation with on a branch that is just tracking
an upstream branch would output a confusing "Nothing to do" due to no
patches being given to git-am.

The test brings the behaviour back into line with that of just before
e646c9c8c0.

Signed-off-by: Robert Shearman <rob@codeweavers.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-31 00:15:59 -07:00
Junio C Hamano
c1a788acee Merge branch 'js/read-tree' into js/c-merge-recursive
* js/read-tree: (107 commits)
  read-tree: move merge functions to the library
  read-trees: refactor the unpack_trees() part
  tar-tree: illustrate an obscure feature better
  git.c: allow alias expansion without a git directory
  setup_git_directory_gently: do not barf when GIT_DIR is given.
  Build on Debian GNU/kFreeBSD
  Call setup_git_directory() much earlier
  Call setup_git_directory() early
  Display an error from update-ref if target ref name is invalid.
  Fix http-fetch
  t4103: fix binary patch application test.
  git-apply -R: binary patches are irreversible for now.
  Teach git-apply about '-R'
  Makefile: ssh-pull.o depends on ssh-fetch.c
  log and diff family: honor config even from subdirectories
  git-reset: detect update-ref error and report it.
  lost-found: use fsck-objects --full
  Teach git-http-fetch the --stdin switch
  Teach git-local-fetch the --stdin switch
  Make pull() support fetching multiple targets at once
  ...
2006-07-30 23:42:10 -07:00
Junio C Hamano
06d30f4f3e recur vs recursive: help testing without touching too many stuff.
During git-merge-recur development, you could set an environment
variable GIT_USE_RECUR_FOR_RECURSIVE to use WIP recur in place
of the recursive strategy.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:10:19 -07:00
Johannes Schindelin
6d297f8137 Status update on merge-recursive in C
This is just an update for people being interested. Alex and me were
busy with that project for a few days now. While it has progressed nicely,
there are quite a couple TODOs in merge-recursive.c, just search for "TODO".

For impatient people: yes, it passes all the tests, and yes, according
to the evil test Alex did, it is faster than the Python script.

But no, it is not yet finished. Biggest points are:

- there are still three external calls
- in the end, it should not be necessary to write the index more than once
  (just before exiting)
- a lot of things can be refactored to make the code easier and shorter

BTW we cannot just plug in git-merge-tree yet, because git-merge-tree
does not handle renames at all.

This patch is meant for testing, and as such,

- it compile the program to git-merge-recur
- it adjusts the scripts and tests to use git-merge-recur instead of
  git-merge-recursive
- it provides "TEST", a script to execute the tests regarding -recursive
- it inlines the changes to read-cache.c (read_cache_from(), discard_cache()
  and refresh_cache_entry())

Brought to you by Alex Riesen and Dscho

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:10:19 -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
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
Eric Wong
f0ef05967f rebase: check for errors from git-commit
commit does not always succeed, so we'll have to check for
it in the absence of set -e.  This fixes a regression
introduced in 9e4bc7dd1b

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-28 03:54:31 -07:00
Eric Wong
66eb64cba6 rebase: get rid of outdated MRESOLVEMSG
There was a time when rebase --skip didn't work when used with
--merge, but that is no more so we don't need that message
anymore.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-28 03:20:51 -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
Eric Wong
d5e673b60b rebase: allow --skip to work with --merge
Now that we control the merge base selection, we won't be forced
into rolling things in that we wanted to skip beforehand.

Also, add a test to ensure this all works as intended.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25 00:38:34 -07:00
Eric Wong
9e4bc7dd1b rebase: cleanup rebasing with --merge
We no longer have to recommit each patch to remove the parent
information we're rebasing since we're using the low-level merge
strategies directly instead of git-merge.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25 00:38:34 -07:00
Eric Wong
9a99c087da rebase: allow --merge option to handle patches merged upstream
Enhance t3401-rebase-partial to test with --merge as well as
the standard am -3 strategy.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25 00:38:34 -07:00
Junio C Hamano
5887ac821f rebase --merge: fix for rebasing more than 7 commits.
Instead of using 4-digit numbers to name commits being rebased,
just use "cmt.$msgnum" string, with $msgnum as a decimal number
without leading zero padding.  This makes it possible to rebase
more than 9999 commits, but of more practical importance is that
the earlier code used "printf" to format already formatted
$msgnum and barfed when it counted up to 0008.  In other words,
the old code was incapable of rebasing more than 7 commits, and
this fixes that problem.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-22 01:46:48 -07:00
Eric Wong
693c15dc28 rebase: error out for NO_PYTHON if they use recursive merge
recursive merge relies on Python, and we can't perform
rename-aware merges without the recursive merge.  So bail out
before trying it.

The test won't work w/o recursive merge, either, so skip that,
too.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-21 03:56:30 -07:00
Eric Wong
58634dbff8 rebase: Allow merge strategies to be used when rebasing
This solves the problem of rebasing local commits against an
upstream that has renamed files.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-21 03:56:29 -07:00
Junio C Hamano
efbff23609 git-rebase: use canonical A..B syntax to format-patch
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-21 03:16:38 -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
sean
031321c654 Add --continue and --abort options to git-rebase.
git rebase [--onto <newbase>] <upstream> [<branch>]
  git rebase --continue
  git rebase --abort

Add "--continue" to restart the rebase process after
manually resolving conflicts.  The user is warned if
there are still differences between the index and the
working files.

Add "--abort" to restore the original branch, and
remove the .dotest working files.

Some minor additions to the git-rebase documentation.

[jc: fix that applies to the maintenance track has been dealt
 with separately.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 17:10:33 -07:00
Junio C Hamano
b176e6ba5b rebase: typofix.
Noticed by Sean.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 12:16:19 -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
Jason Riedy
d0080b3cda Fix typo in git-rebase.sh.
s/upsteram/upstream in git-rebase.sh.

Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-21 18:25:34 -08:00
Carl Worth
69a60af5d0 git-rebase: Clarify usage statement and copy it into the actual documentation.
I found a paper thin man page for git-rebase, but was quite happy to
see something much more useful in the usage statement of the script
when I went there to find out how this thing worked. Here it is
cleaned up slightly and expanded a bit into the actual documentation.

Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-21 17:45:32 -08:00
Junio C Hamano
8fa40aa915 Merge branch 'jc/rebase-limit'
* jc/rebase-limit:
  rebase: allow rebasing onto different base.
2006-02-18 01:24:01 -08:00
Junio C Hamano
e646c9c8c0 rebase: allow rebasing onto different base.
This allows you to rewrite history a bit more flexibly, by
separating the other branch name and new branch point.  By
default, the new branch point is the same as the tip of the
other branch as before, but you can specify where you graft the
rebased branch onto.

When you have this ancestry graph:

          A---B---C topic
         /
    D---E---F---G master

	$ git rebase --onto master~1 master topic

would rewrite the history to look like this:

	      A'\''--B'\''--C'\'' topic
	     /
    D---E---F---G master

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-14 16:10:49 -08:00
Junio C Hamano
9a111c91b0 rebase: allow a hook to refuse rebasing.
This lets a hook to interfere a rebase and help prevent certain
branches from being rebased by mistake.  A sample hook to show
how to prevent a topic branch that has already been merged into
publish branch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-13 00:17:33 -08:00
Lukas Sandström
32d9954478 Bugfixes for git-rebase
Fix bugs in git-rebase wrt rebasing another branch than
the current HEAD, rebasing with a dirty working dir,
and rebasing a proper decendant of the target branch.

[jc: with a bit of hand-merging]

Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-14 17:02:03 -08:00
Junio C Hamano
2db8aaeca1 rebase: do not get confused in fast-forward situation.
When switching to another branch and rebasing it in a one-go, it
failed to update the variable that holds the branch head, and
did not detect fast-forward situation correctly.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-14 13:04:25 -08:00
freku045@student.liu.se
3ae39ab232 git-rebase: Usage string clean-up, emit usage string at incorrect invocation
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-14 02:53:44 -08:00
Junio C Hamano
7f4bd5d831 rebase: one safety net, one bugfix and one optimization.
When a .dotest from a previously failed rebase or patch
application exists, rebase got confused and tried to apply
mixture of what was already there and what is being rebased.
Check the existence of the directory and barf.

It failed with an mysterious "fatal: cannot read mbox" message
if the branch being rebased is fully in sync with the base.
Also if the branch is a proper descendant of the base, there is
no need to run rebase logic.  Prevent these from happening by
checking where the merge-base is.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-28 13:00:31 -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
7f59dbbb8f Rewrite rebase to use git-format-patch piped to git-am.
The current rebase implementation finds commits in our tree but
not in the upstream tree using git-cherry, and tries to apply
them using git-cherry-pick (i.e. always use 3-way) one by one.

Which is fine, but when some of the changes do not apply
cleanly, it punts, and punts badly.

Suppose you have commits A-B-C-D-E since you forked from the
upstream and submitted the changes for inclusion.  You fetch
from upstream head U and find that B has been picked up.  You
run git-rebase to update your branch, which tries to apply
changes contained in A-C-D-E, in this order, but replaying of C
fails, because the upstream got changes that touch the same area
from elsewhere.

Now what?

It notes that fact, and goes ahead to apply D and E, and at the
very end tells you to deal with C by hand.  Even if you somehow
managed to replay C on top of the result, you would now end up
with ...-B-...-U-A-D-E-C.

Breaking the order between B and others was the conscious
decision made by the upstream, so we would not worry about it,
and even if it were worrisome, it is too late for us to fix now.
What D and E do may well depend on having C applied before them,
which is a problem for us.

This rewrites rebase to use git-format-patch piped to git-am,
and when the patch does not apply, have git-am fall back on
3-way merge.  The updated diff/patch pair knows how to apply
trivial binary patches as long as the pre- and post-images are
locally available, so this should work on a repository with
binary files as well.

The primary benefit of this change is that it makes rebase
easier to use when some of the changes do not replay cleanly.
In the "unapplicable patch in the middle" case, this "rebase"
works like this:

 - A series of patches in e-mail form is created that records
   what A-C-D-E do, and is fed to git-am.  This is stored in
   .dotest/ directory, just like the case you tried to apply
   them from your mailbox.  Your branch is rewound to the tip of
   upstream U, and the original head is kept in .git/ORIG_HEAD,
   so you could "git reset --hard ORIG_HEAD" in case the end
   result is really messy.

 - Patch A applies cleanly.  This could either be a clean patch
   application on top of rewound head (i.e. same as upstream
   head), or git-am might have internally fell back on 3-way
   (i.e.  it would have done the same thing as git-cherry-pick).
   In either case, a rebased commit A is made on top of U.

 - Patch C does not apply.  git-am stops here, with conflicts to
   be resolved in the working tree.  Yet-to-be-applied D and E
   are still kept in .dotest/ directory at this point.  What the
   user does is exactly the same as fixing up unapplicable patch
   when running git-am:

   - Resolve conflict just like any merge conflicts.
   - "git am --resolved --3way" to continue applying the patches.

 - This applies the fixed-up patch so by definition it had
   better apply.  "git am" knows the patch after the fixed-up
   one is D and then E; it applies them, and you will get the
   changes from A-C-D-E commits on top of U, in this order.

I've been using this without noticing any problem, and as people
may know I do a lot of rebases.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-18 15:53:15 -08: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
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