* patches in context format ?
@ 2009-01-12 9:00 Christian MICHON
2009-01-12 9:28 ` Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Christian MICHON @ 2009-01-12 9:00 UTC (permalink / raw)
To: git list
I'm maintaining a git tree of the vim project: this work can be seen
at http://github.com/cmichon/vim
vim patches do not come as unified format, but only as context format
instead (from a "diff -c").
The current solution I have is to use the original patch command,
stage modifications and add new files. I do not like this solution,
because I have to work out the commit messages out of the mbox and I
lose reproducibility. I'm basically maintaining a subset of shell
scripts, the original patches and an artificial way (ugly) to get
timestamps of modifications (for the commit dates).
Instead of this complicated procedure, I'd like to use "git apply" or
"git am", provided I can get git to support "context output format" as
input for patches ?
I guess the answer is no, but has anyone on the list been working on
this ? is there another way to translate from "context" to "unified"
format ?
TIA
--
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:00 patches in context format ? Christian MICHON
@ 2009-01-12 9:28 ` Junio C Hamano
2009-01-12 9:52 ` Christian MICHON
2009-01-12 9:34 ` Teemu Likonen
2009-01-12 9:52 ` Jeff King
2 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2009-01-12 9:28 UTC (permalink / raw)
To: Christian MICHON; +Cc: git list
"Christian MICHON" <christian.michon@gmail.com> writes:
> I'm maintaining a git tree of the vim project: this work can be seen
> at http://github.com/cmichon/vim
>
> vim patches do not come as unified format, but only as context format
> instead (from a "diff -c").
> ...
> I guess the answer is no, but has anyone on the list been working on
> this ? is there another way to translate from "context" to "unified"
> format ?
Not that I know of.
If you want to add support for the copied context format patches to your
workflow, I think the first step (and easiest one) would be to find an
external program that lets you convert from the copied context format to
the unified context format. Perhaps "interdiff /dev/null copied >unified"
would suffice (but I haven't tested this).
Then find the place that feeds "git apply" with a patch, and add an option
to "git am" to instead do something like this:
- git apply --index "$dotest/patch"
+ case "$input_is_in_the_copied_context_format"
+ yes)
+ interdiff /dev/null "$dotest/patch" | git apply --index
+ ;;
+ *)
+ # unified context as before...
+ git apply --index "$dotest/patch"
+ ;;
+ esac
In the longer term, if we were to update "git-apply" to support the copied
context format, I think we should take the same approach.
Inside read_patch_file(), you detect that the patch is in the copied
context format, and convert it to the unified context format and return
the result. All the rest of the program can then be left alone and you
will have little chance of regression.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:00 patches in context format ? Christian MICHON
2009-01-12 9:28 ` Junio C Hamano
@ 2009-01-12 9:34 ` Teemu Likonen
2009-01-12 9:53 ` Christian MICHON
2009-01-12 9:52 ` Jeff King
2 siblings, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2009-01-12 9:34 UTC (permalink / raw)
To: Christian MICHON; +Cc: git list
Christian MICHON (2009-01-12 10:00 +0100) wrote:
> is there another way to translate from "context" to "unified" format ?
Well, this is not exactly the best solution for a Vim user but this is
the only way I know. Emacs can convert diffs between the formats. You
don't even need to launch Emacs, just run it in batch mode:
$ emacs --batch -Q --file input.diff \
--eval '(diff-context->unified (point-min) (point-max))' \
--eval '(save-buffer)'
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:28 ` Junio C Hamano
@ 2009-01-12 9:52 ` Christian MICHON
0 siblings, 0 replies; 7+ messages in thread
From: Christian MICHON @ 2009-01-12 9:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git list
On Mon, Jan 12, 2009 at 10:28 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> I guess the answer is no, but has anyone on the list been working on
>> this ? is there another way to translate from "context" to "unified"
>> format ?
>
> Not that I know of.
>
> If you want to add support for the copied context format patches to your
> workflow, I think the first step (and easiest one) would be to find an
> external program that lets you convert from the copied context format to
> the unified context format. Perhaps "interdiff /dev/null copied >unified"
> would suffice (but I haven't tested this).
>
interdiff is exactly what I needed (I used -p and -q switches, plus a
substitution for the path).
Thanks for this! I guess there's not really a need to add this now in
git-am, since I've seldom seen such context patches.
--
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:00 patches in context format ? Christian MICHON
2009-01-12 9:28 ` Junio C Hamano
2009-01-12 9:34 ` Teemu Likonen
@ 2009-01-12 9:52 ` Jeff King
2009-01-12 9:57 ` Christian MICHON
2 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-01-12 9:52 UTC (permalink / raw)
To: Christian MICHON; +Cc: git list
On Mon, Jan 12, 2009 at 10:00:11AM +0100, Christian MICHON wrote:
> The current solution I have is to use the original patch command,
> stage modifications and add new files. I do not like this solution,
> because I have to work out the commit messages out of the mbox and I
> lose reproducibility. I'm basically maintaining a subset of shell
> scripts, the original patches and an artificial way (ugly) to get
> timestamps of modifications (for the commit dates).
>
> Instead of this complicated procedure, I'd like to use "git apply" or
> "git am", provided I can get git to support "context output format" as
> input for patches ?
Maybe this is not the nicest solution if you are going to apply a lot of
these patches, but you can pick up where git-am fails, run patch, and
ask it to resume:
$ git am mbox-with-context-diff
Applying: a minor change
error: No changes
Patch failed at 0001.
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
$ patch <.git/rebase-apply/patch ;# or whatever
$ git add -u
$ git am -r
Applying: a minor change
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:34 ` Teemu Likonen
@ 2009-01-12 9:53 ` Christian MICHON
0 siblings, 0 replies; 7+ messages in thread
From: Christian MICHON @ 2009-01-12 9:53 UTC (permalink / raw)
To: Teemu Likonen; +Cc: git list
On Mon, Jan 12, 2009 at 10:34 AM, Teemu Likonen <tlikonen@iki.fi> wrote:
> Christian MICHON (2009-01-12 10:00 +0100) wrote:
>
>> is there another way to translate from "context" to "unified" format ?
>
> Well, this is not exactly the best solution for a Vim user but this is
> the only way I know. Emacs can convert diffs between the formats. You
> don't even need to launch Emacs, just run it in batch mode:
>
> $ emacs --batch -Q --file input.diff \
> --eval '(diff-context->unified (point-min) (point-max))' \
> --eval '(save-buffer)'
>
you're asking a vim user to use emacs ? ;-)
thanks for the suggestion: I'll try it at least, but I think I'll
stick to interdiff.
--
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: patches in context format ?
2009-01-12 9:52 ` Jeff King
@ 2009-01-12 9:57 ` Christian MICHON
0 siblings, 0 replies; 7+ messages in thread
From: Christian MICHON @ 2009-01-12 9:57 UTC (permalink / raw)
To: Jeff King; +Cc: git list
On Mon, Jan 12, 2009 at 10:52 AM, Jeff King <peff@peff.net> wrote:
> On Mon, Jan 12, 2009 at 10:00:11AM +0100, Christian MICHON wrote:
>
>> The current solution I have is to use the original patch command,
>> stage modifications and add new files. I do not like this solution,
>> because I have to work out the commit messages out of the mbox and I
>> lose reproducibility. I'm basically maintaining a subset of shell
>> scripts, the original patches and an artificial way (ugly) to get
>> timestamps of modifications (for the commit dates).
>>
>> Instead of this complicated procedure, I'd like to use "git apply" or
>> "git am", provided I can get git to support "context output format" as
>> input for patches ?
>
> Maybe this is not the nicest solution if you are going to apply a lot of
> these patches, but you can pick up where git-am fails, run patch, and
> ask it to resume:
>
> $ git am mbox-with-context-diff
> Applying: a minor change
> error: No changes
> Patch failed at 0001.
> When you have resolved this problem run "git am --resolved".
> If you would prefer to skip this patch, instead run "git am --skip".
> To restore the original branch and stop patching run "git am --abort".
>
> $ patch <.git/rebase-apply/patch ;# or whatever
> $ git add -u
> $ git am -r
> Applying: a minor change
>
> -Peff
>
vim patches are in hundredth... so I guess this is too manual.
Thanks for the suggestion!
--
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-01-12 9:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-12 9:00 patches in context format ? Christian MICHON
2009-01-12 9:28 ` Junio C Hamano
2009-01-12 9:52 ` Christian MICHON
2009-01-12 9:34 ` Teemu Likonen
2009-01-12 9:53 ` Christian MICHON
2009-01-12 9:52 ` Jeff King
2009-01-12 9:57 ` Christian MICHON
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).