All of lore.kernel.org
 help / color / mirror / Atom feed
* A question about using 'add -p' to split the patch
@ 2009-06-15  3:08 Ping Yin
  2009-06-15  6:12 ` David Aguilar
  0 siblings, 1 reply; 5+ messages in thread
From: Ping Yin @ 2009-06-15  3:08 UTC (permalink / raw)
  To: git mailing list

file bt.php in the HEAD:

function bt_add($path) {
 return;
}

file bt.php in the working directory:

function bt_move($path, $pos) {
  return;
}
function bt_add($path, $pos) {
  bt_move($path, $pos)
  return;
}

Now i want to split the change into two parts:
First introduce bt_move
Then add a param pos to bt_add and call bt_move

With the 'e' action of 'add -p', i got

-function bt_add($path) {
+function bt_move($path, $pos) {
+  return;
+}
+function bt_add($path, $pos) {
+  bt_move($path, $pos)
   return;
 }

Then, i want to edit the patch to get


function bt_move($path, $pos) {
  return;
}
function bt_add($path) {
  return;
}

However, whatever i do, the patch fails to apply. Any suggestion?

-


Ping Yin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about using 'add -p' to split the patch
  2009-06-15  3:08 A question about using 'add -p' to split the patch Ping Yin
@ 2009-06-15  6:12 ` David Aguilar
  2009-06-15  6:24   ` Ping Yin
  0 siblings, 1 reply; 5+ messages in thread
From: David Aguilar @ 2009-06-15  6:12 UTC (permalink / raw)
  To: Ping Yin; +Cc: git mailing list

On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:
> file bt.php in the HEAD:
> 
> function bt_add($path) {
>  return;
> }
> 
> file bt.php in the working directory:
> 
> function bt_move($path, $pos) {
>   return;
> }
> function bt_add($path, $pos) {
>   bt_move($path, $pos)
>   return;
> }
> 
> Now i want to split the change into two parts:
> First introduce bt_move
> Then add a param pos to bt_add and call bt_move
> 
> With the 'e' action of 'add -p', i got
> 
> -function bt_add($path) {
> +function bt_move($path, $pos) {
> +  return;
> +}
> +function bt_add($path, $pos) {
> +  bt_move($path, $pos)
>    return;
>  }
> 
> Then, i want to edit the patch to get
> 
> 
> function bt_move($path, $pos) {
>   return;
> }
> function bt_add($path) {
>   return;
> }
> 
> However, whatever i do, the patch fails to apply. Any suggestion?

Use git-gui or git-cola to select just bt_move() for addition.
You can stage specific lines.

After doing that it's often a good idea to git stash --keep-index
so you can test it before committing.

enjoy,

-- 
		David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about using 'add -p' to split the patch
  2009-06-15  6:12 ` David Aguilar
@ 2009-06-15  6:24   ` Ping Yin
  2009-06-15  7:36     ` David Aguilar
  0 siblings, 1 reply; 5+ messages in thread
From: Ping Yin @ 2009-06-15  6:24 UTC (permalink / raw)
  To: David Aguilar; +Cc: git mailing list

On Mon, Jun 15, 2009 at 2:12 PM, David Aguilar<davvid@gmail.com> wrote:
> On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:
>> file bt.php in the HEAD:
>>
>> function bt_add($path) {
>>  return;
>> }
>>
>> file bt.php in the working directory:
>>
>> function bt_move($path, $pos) {
>>   return;
>> }
>> function bt_add($path, $pos) {
>>   bt_move($path, $pos)
>>   return;
>> }
>>
>> Now i want to split the change into two parts:
>> First introduce bt_move
>> Then add a param pos to bt_add and call bt_move
>>
>> With the 'e' action of 'add -p', i got
>>
>> -function bt_add($path) {
>> +function bt_move($path, $pos) {
>> +  return;
>> +}
>> +function bt_add($path, $pos) {
>> +  bt_move($path, $pos)
>>    return;
>>  }
>>
>> Then, i want to edit the patch to get
>>
>>
>> function bt_move($path, $pos) {
>>   return;
>> }
>> function bt_add($path) {
>>   return;
>> }
>>
>> However, whatever i do, the patch fails to apply. Any suggestion?
>
> Use git-gui or git-cola to select just bt_move() for addition.
> You can stage specific lines.

Doesn't the 'e' action of 'add -p' do the same job with git-gui?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about using 'add -p' to split the patch
  2009-06-15  6:24   ` Ping Yin
@ 2009-06-15  7:36     ` David Aguilar
  2009-06-15  8:56       ` Ping Yin
  0 siblings, 1 reply; 5+ messages in thread
From: David Aguilar @ 2009-06-15  7:36 UTC (permalink / raw)
  To: Ping Yin; +Cc: git mailing list

On Mon, Jun 15, 2009 at 02:24:39PM +0800, Ping Yin wrote:
> On Mon, Jun 15, 2009 at 2:12 PM, David Aguilar<davvid@gmail.com> wrote:
> > On Mon, Jun 15, 2009 at 11:08:51AM +0800, Ping Yin wrote:
> >> file bt.php in the HEAD:
> >>
> >> function bt_add($path) {
> >>  return;
> >> }
> >>
> >> file bt.php in the working directory:
> >>
> >> function bt_move($path, $pos) {
> >>   return;
> >> }
> >> function bt_add($path, $pos) {
> >>   bt_move($path, $pos)
> >>   return;
> >> }
> >>
> >> Now i want to split the change into two parts:
> >> First introduce bt_move
> >> Then add a param pos to bt_add and call bt_move
> >>
> >> With the 'e' action of 'add -p', i got
> >>
> >> -function bt_add($path) {
> >> +function bt_move($path, $pos) {
> >> +  return;
> >> +}
> >> +function bt_add($path, $pos) {
> >> +  bt_move($path, $pos)
> >>    return;
> >>  }
> >>
> >> Then, i want to edit the patch to get
> >>
> >>
> >> function bt_move($path, $pos) {
> >>   return;
> >> }
> >> function bt_add($path) {
> >>   return;
> >> }
> >>
> >> However, whatever i do, the patch fails to apply. Any suggestion?
> >
> > Use git-gui or git-cola to select just bt_move() for addition.
> > You can stage specific lines.
> 
> Doesn't the 'e' action of 'add -p' do the same job with git-gui?

It should.

I tried it in git-{cola,gui} and I was able to do it by first staging
the +bt_add(a,b) line, and then staging only the -bt_add(a) line.

For add -e I got it to work by editing the patch to;

+function bt_move($path, $pos) {
+  return;
+}
 function bt_add($path) {
   return;
 }

The reason it's hard to get right is that you have to
reconstruct the context of the original content for the
adds/removes and remember to add the space before the
reconstructed bt_add($path).

Those kinda details are usually easier for software to get right
;-)

-- 
		David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about using 'add -p' to split the patch
  2009-06-15  7:36     ` David Aguilar
@ 2009-06-15  8:56       ` Ping Yin
  0 siblings, 0 replies; 5+ messages in thread
From: Ping Yin @ 2009-06-15  8:56 UTC (permalink / raw)
  To: David Aguilar; +Cc: git mailing list

>
> For add -e I got it to work by editing the patch to;
>
> +function bt_move($path, $pos) {
> +  return;
> +}
>  function bt_add($path) {
>    return;
>  }
>
> The reason it's hard to get right is that you have to
> reconstruct the context of the original content for the
> adds/removes and remember to add the space before the
> reconstructed bt_add($path).
>

Thanks very much, i forgot the space before the reconstructed bt_add($path) :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-15  8:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15  3:08 A question about using 'add -p' to split the patch Ping Yin
2009-06-15  6:12 ` David Aguilar
2009-06-15  6:24   ` Ping Yin
2009-06-15  7:36     ` David Aguilar
2009-06-15  8:56       ` Ping Yin

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.