All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Mason <slash.tmp@free.fr>
Cc: git <git@vger.kernel.org>
Subject: Re: Salvaging borked project history
Date: Mon, 23 Feb 2015 11:36:21 -0800	[thread overview]
Message-ID: <xmqq7fv8to7e.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <54EB5DD7.7050202@free.fr> (Mason's message of "Mon, 23 Feb 2015 18:05:27 +0100")

Mason <slash.tmp@free.fr> writes:

> But 'git am' just gave up. Small sample of errors:
>
> error: patch failed: drivers/block/Kconfig:411
> error: drivers/block/Kconfig: patch does not apply
> error: drivers/tty/serial/8250/8250.c: does not exist in index
> error: patch failed: drivers/tty/serial/8250/8250_early.c:121
> error: drivers/tty/serial/8250/8250_early.c: patch does not apply
> error: patch failed: drivers/video/Kconfig:101
> error: drivers/video/Kconfig: patch does not apply
> ...
> Patch failed at 0001 Commit for supporting Sigma Designs' SoCs.
> The copy of the patch that failed is found in:
>    .git/rebase-apply/patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
> How do I "resolve this problem".

You look at .git/rebase-apply/patch and drivers/block/Kconfig in
your editor, and edit the former to make it apply (i.e. adjust the
common context lines that begin with SP and preimage lines that
begin with '-' to match what you see in the drivers/block/Kconfig
where the change wants to go).  You do so for all the other files.

And then run "git am" again without any argument, until the patch
applies.

One way to "edit .git/rebase-apply/patch and make it apply" that is
often necessary when you are applying to codebase that is way more
ahead than where you took the original patches is to hand-edit the
working tree files (e.g. drivers/block/Kconfig) that the patch wants
to touch and change it in the way the patch wants to, while viewing
the original .git/rebase-apply/patch in your pager (you do not
directly edit this original patch---you only use it as a guide to
discern what the patch wants to do).  Once the working tree files
are in a state that the patch would have wanted to make if it were
taken based on the new codebase, overwrite .git/rebase-apply/patch
with the output from "git diff HEAD".  After that (i.e. you have
"edited" .git/rebase-apply/patch, with the help with your editor,
the working tree files and "git diff"), do "git reset --hard".

Which brings you to the same state just after "git am" gave up and
you correctly edited ".git/rebase-apply/patch:" to make it apply.

So you run "git am" again without any argument.  This time the patch
would apply and continue.

But I personally think "git am -3" may be easier to handle.

  reply	other threads:[~2015-02-23 19:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23 17:05 Salvaging borked project history Mason
2015-02-23 19:36 ` Junio C Hamano [this message]
2015-02-26 11:54   ` Mason
2015-02-26 18:56     ` Junio C Hamano
2015-02-26 20:25       ` Mason
2015-02-26 21:28         ` Junio C Hamano
2015-02-26 23:47           ` Mason
2015-02-26 23:54             ` Junio C Hamano
2015-03-04 14:49         ` Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7fv8to7e.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=slash.tmp@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.