all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* diff-mode reports offsets incorrectly
@ 2008-02-05  5:04 Nick Roberts
  2008-02-05 16:08 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Roberts @ 2008-02-05  5:04 UTC (permalink / raw)
  To: emacs-devel


diff-mode reports offsets if the first hunk replaces code with a different
number of lines.

Consider the patch below.  The first hunk removes four lines and adds one.
When the second hunk is applied Emacs reports:

Hunk applied at offset 3 lines

but this is only because 4 - 1 = 3, and Emacs is presumably looking at the
line numbering before the first hunk was applied.

This didn't happen in Emacs 21.4, but happens in EMACS_22_BASE and trunk.
I don't know about Emacs 22.1


--- breakpoint.c	05 Feb 2008 13:46:40 +1300	
*************** print_one_breakpoint_location (struct br
*** 3425,3434 ****
    /* 4 */
    annotate_field (3);
    if (part_of_multiple)
!     ui_out_field_string (uiout, "enabled", 
! 			 loc->shlib_disabled 
! 			 ? (loc->enabled ? "y(p)" : "n(p)")
! 			 : (loc->enabled ? "y" : "n"));
    else
      {
        int pending = (b->loc == NULL || b->loc->shlib_disabled);
--- 3425,3431 ----
    /* 4 */
    annotate_field (3);
    if (part_of_multiple)
!     ui_out_field_string (uiout, "enabled", loc->enabled ? "y" : "n");
    else
      {
        int pending = (b->loc == NULL || b->loc->shlib_disabled);
*************** print_one_breakpoint_location (struct br
*** 3436,3446 ****
...


-- 
Nick                                           http://www.inet.net.nz/~nickrob




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

* Re: diff-mode reports offsets incorrectly
  2008-02-05  5:04 diff-mode reports offsets incorrectly Nick Roberts
@ 2008-02-05 16:08 ` Stefan Monnier
  2008-02-05 21:03   ` Nick Roberts
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-02-05 16:08 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel

> diff-mode reports offsets if the first hunk replaces code with a different
> number of lines.

> Consider the patch below.  The first hunk removes four lines and adds one.
> When the second hunk is applied Emacs reports:

> Hunk applied at offset 3 lines

> but this is only because 4 - 1 = 3, and Emacs is presumably looking at the
> line numbering before the first hunk was applied.

> This didn't happen in Emacs 21.4, but happens in EMACS_22_BASE and trunk.
> I don't know about Emacs 22.1

Are you sure this changed?  I can't remember changing anything in
this area.  Not that it's terribly important since hunk can be applied
in any order (and don't need to all be applied), so offsets are
a completely normal occurrence.


        Stefan


> --- breakpoint.c	05 Feb 2008 13:46:40 +1300	
> *************** print_one_breakpoint_location (struct br
> *** 3425,3434 ****
>     /* 4 */
>     annotate_field (3);
>     if (part_of_multiple)
> !     ui_out_field_string (uiout, "enabled", 
> ! 			 loc->shlib_disabled 
> ! 			 ? (loc->enabled ? "y(p)" : "n(p)")
> ! 			 : (loc->enabled ? "y" : "n"));
>     else
>       {
>         int pending = (b->loc == NULL || b->loc->shlib_disabled);
> --- 3425,3431 ----
>     /* 4 */
>     annotate_field (3);
>     if (part_of_multiple)
> !     ui_out_field_string (uiout, "enabled", loc->enabled ? "y" : "n");
>     else
>       {
>         int pending = (b->loc == NULL || b->loc->shlib_disabled);
> *************** print_one_breakpoint_location (struct br
> *** 3436,3446 ****
> ...


> -- 
> Nick                                           http://www.inet.net.nz/~nickrob





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

* Re: diff-mode reports offsets incorrectly
  2008-02-05 16:08 ` Stefan Monnier
@ 2008-02-05 21:03   ` Nick Roberts
  2008-02-05 22:23     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Roberts @ 2008-02-05 21:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

 > > This didn't happen in Emacs 21.4, but happens in EMACS_22_BASE and trunk.
 > > I don't know about Emacs 22.1
 > 
 > Are you sure this changed?  

I tried it once and it appeared to be the case.  It's quite easy to test:

1) Visit a file under CVS control.
2) Remove a couple of lines in a couple of places and save it.
3) Do cvs-diff, C-x v =, and save the diff-buffer.
4) Revert the file, C-x v u.
5) Apply the hunks from the diff buffer but don't save them.

Hunks after the first report an offset.

6) If you have Emacs 21, just do 5)

No offsets are reported.

 >                            I can't remember changing anything in
 > this area.  Not that it's terribly important since hunk can be applied
 > in any order (and don't need to all be applied), so offsets are
 > a completely normal occurrence.

I agree that offsets aren't really important but they suggest to me that the
file to which the patch is being applied is a bit different to the one from
which it was created.  It just seems tidy to not report offsets in such
cases, in the same way that "patch <patchfile" doesn't.

-- 
Nick                                           http://www.inet.net.nz/~nickrob




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

* Re: diff-mode reports offsets incorrectly
  2008-02-05 21:03   ` Nick Roberts
@ 2008-02-05 22:23     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2008-02-05 22:23 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel

> I tried it once and it appeared to be the case.  It's quite easy to test:

> 1) Visit a file under CVS control.
> 2) Remove a couple of lines in a couple of places and save it.
> 3) Do cvs-diff, C-x v =, and save the diff-buffer.
> 4) Revert the file, C-x v u.
> 5) Apply the hunks from the diff buffer but don't save them.

> Hunks after the first report an offset.

> 6) If you have Emacs 21, just do 5)

> No offsets are reported.

Hmm... I guess we looked at the other line number in the hunk header.

> I agree that offsets aren't really important but they suggest to me that the
> file to which the patch is being applied is a bit different to the one from
> which it was created.  It just seems tidy to not report offsets in such
> cases, in the same way that "patch <patchfile" doesn't.

Agreed.


        Stefan




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

end of thread, other threads:[~2008-02-05 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-05  5:04 diff-mode reports offsets incorrectly Nick Roberts
2008-02-05 16:08 ` Stefan Monnier
2008-02-05 21:03   ` Nick Roberts
2008-02-05 22:23     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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.