git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git diff woes

From
Andreas Ericsson <ae@op5.se>
Date
Nov 12, 2007, 09:44 UTC
Message-ID
<4738208D.1080003@op5.se>

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
Next: Johannes Schindelin
Message 1 of 13 in “git diff woes”
  1. Andreas EricssonNov 12, 2007
  2. Johannes SchindelinNov 12, 2007
  3. Andreas EricssonNov 12, 2007
  4. Johannes SchindelinNov 12, 2007
  5. Andreas EricssonNov 12, 2007
  6. Junio C HamanoNov 12, 2007
  7. Andreas EricssonNov 13, 2007
  8. Johannes SchindelinNov 13, 2007
  9. Miles BaderNov 13, 2007
  10. Andreas EricssonNov 13, 2007
  11. diffcore: Allow users to decide what funcname to useAndreas Ericsson, Nov 13, 2007
  12. Jakub NarebskiNov 13, 2007
  13. Andreas EricssonNov 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.