git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git diff woes
@ 2007-11-12  9:44 Andreas Ericsson
  2007-11-12 10:01 ` Johannes Schindelin
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Ericsson @ 2007-11-12  9:44 UTC (permalink / raw)
  To: Git Mailing List

I recently ran into an oddity with the excellent git diff output
format. When a function declaration changes in the same patch as
something else in a function, the old declaration is used with the
diff hunk-headers.

Consider this hunk:
---%<---%<---%<---
@@ -583,75 +346,100 @@ double jitter_request(const char *host, int *status){
        if(verbose) printf("%d candiate peers available\n", num_candidates);
        if(verbose && syncsource_found) printf("synchronization source found\n")
        if(! syncsource_found){
-               *status = STATE_UNKNOWN;
+               status = STATE_WARNING;
                if(verbose) printf("warning: no synchronization source found\n")
        }
---%<---%<---%<---

It definitely looks like a bug, but really isn't, since an earlier hunk
(pasted below) changes the declaration. There were several hunks between
these two, so it was far from obvious when I saw it first.

---%<---%<---%<---
@@ -517,19 +276,22 @@ setup_control_request(ntp_control_message *p, uint8_t opco
 }
 
 /* XXX handle responses with the error bit set */
-double jitter_request(const char *host, int *status){
-       int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
-       int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
+int ntp_request(const char *host, double *offset, int *offset_result, double *j
+       int conn=-1, i, npeers=0, num_candidates=0;
+       int min_peer_sel=PEER_INCLUDED;
        int peers_size=0, peer_offset=0;
+       int status;
---%<---%<---%<--- 
 
This makes it impossible to trust the hunk-header info if the declaration
changes. It might be better to not write it out when the header-line is
also part of the patch. That would at least force one to go back and find
the real declaration. Best would probably be to write the new declaration,
but I'm unsure if that could cause some other confusion.

I haven't started looking into it yet, and as I'm sure there are others
who are much more familiar with the xdiff code I'm shamelessly hoping
someone will beat me to a fix.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

end of thread, other threads:[~2007-11-13 10:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-12  9:44 git diff woes Andreas Ericsson
2007-11-12 10:01 ` Johannes Schindelin
2007-11-12 10:35   ` Andreas Ericsson
2007-11-12 10:50     ` Johannes Schindelin
2007-11-12 11:19       ` Andreas Ericsson
2007-11-12 21:30     ` Junio C Hamano
2007-11-13  0:03       ` Andreas Ericsson
2007-11-13  0:59         ` Johannes Schindelin
2007-11-13  2:53         ` Miles Bader
2007-11-13  7:40           ` Andreas Ericsson
2007-11-13  9:15             ` [PATCH] diffcore: Allow users to decide what funcname to use Andreas Ericsson
2007-11-13 10:03               ` Jakub Narebski
2007-11-13 10:07                 ` Andreas Ericsson

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).