>Number:         6489
>Category:       user
>Synopsis:       opencvs diff exit status discrepancy
>Confidential:   yes
>Severity:       serious
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Fri Oct 15 12:40:01 GMT 2010
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        
>Organization:
>Environment:
        System      : OpenBSD 4.7
        Details     : OpenBSD 4.7 (GENERIC) #112: Wed Mar 17 20:43:49 MDT 2010
                                    
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
                                
        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:

In terms of exit status, both cvs implementations behave identically for a file 
that has not changed.

box:~/sandbox.openbsd/src/usr.bin/cvs$ cvs diff README 
box:~/sandbox.openbsd/src/usr.bin/cvs$ echo $?
0
box:~/sandbox.openbsd/src/usr.bin/cvs$ opencvs diff README 
box:~/sandbox.openbsd/src/usr.bin/cvs$ echo $?
0

GNU cvs uses exit status of one when a file has been modified; opencvs does not.
The difference in exit status is necessary as this would allow calling scripts 
to know if a file has changed. The problem applies for both local and remote 
repositories.

>How-To-Repeat:

box:~/sandbox.openbsd/src/usr.bin/cvs$ cvs diff README 
Index: README
===================================================================
RCS file: /cvs/src/usr.bin/cvs/README,v
retrieving revision 1.6
diff -r1.6 README
8c8
< CVS.  It is currently in development and thus is not yet suited to replace
---
> CVS.  It is currently in development and so is not yet suited to replace
box:~/sandbox.openbsd/src/usr.bin/cvs$ echo $?
1
box:~/sandbox.openbsd/src/usr.bin/cvs$ opencvs diff README 
Index: README
===================================================================
RCS file: /cvs/src/usr.bin/cvs/README,v
retrieving revision 1.6
diff -r1.6 README
8c8
< CVS.  It is currently in development and thus is not yet suited to replace
---
> CVS.  It is currently in development and so is not yet suited to replace
box:~/sandbox.openbsd/src/usr.bin/cvs$ echo $?
0

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
 >From what I can see this needs to be changed in two places, for local and 
 remote files. For remote files, server_response will be SERVER_ERROR when 
 there is a difference to report. For local files, the following patch 
 introduces a new global to keep track of whether any files have been modified. 
 
 The fix seems to work correctly for arbitrary file arguments, e.g.
  opencvs diff MODIFIED_FILE UNMODIFIED_FILE...
 
 Index: cvs.c
 ===================================================================
 RCS file: /cvs/src/usr.bin/cvs/cvs.c,v
 retrieving revision 1.151
 diff -u -r1.151 cvs.c
 --- cvs.c       23 Jul 2010 08:31:19 -0000      1.151
 +++ cvs.c       15 Oct 2010 12:12:40 -0000
 @@ -182,7 +182,7 @@
  main(int argc, char **argv)
  {
         char *envstr, **cmd_argv, **targv;
 -       int i, ret, cmd_argc;
 +       int i, ret, cmd_argc, cmd_ret;
         struct passwd *pw;
         struct stat st;
         char fpath[MAXPATHLEN];
 @@ -292,9 +292,9 @@
         }
  
         if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
 -               cmdp->cmd(cmd_argc, cmd_argv);
 +               cmd_ret = cmdp->cmd(cmd_argc, cmd_argv);
                 cvs_cleanup();
 -               return (0);
 +               return (cmd_ret);
         }
  
         (void)xsnprintf(fpath, sizeof(fpath), "%s/%s",
 @@ -318,10 +318,10 @@
                 cvs_parse_modules();
         }
  
 -       cmdp->cmd(cmd_argc, cmd_argv);
 +       cmd_ret = cmdp->cmd(cmd_argc, cmd_argv);
         cvs_cleanup();
  
 -       return (0);
 +       return (cmd_ret);
  }
  
  int
 Index: diff.c
 ===================================================================
 RCS file: /cvs/src/usr.bin/cvs/diff.c,v
 retrieving revision 1.159
 diff -u -r1.159 diff.c
 --- diff.c      30 Jul 2010 21:47:18 -0000      1.159
 +++ diff.c      15 Oct 2010 12:12:40 -0000
 @@ -283,6 +283,9 @@
                         cvs_file_run(argc, argv, &cr);
                 else
                         cvs_file_run(1, &arg, &cr);
 +
 +               if (file_modified != 0)
 +                       return (1);
         }
  
         if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
 @@ -293,6 +296,9 @@
                     "rdiff" : "diff");
  
                 cvs_client_get_responses();
 +
 +               if (server_response == SERVER_ERROR)
 +                       return (1);
         }
  
         return (0);
 Index: file.c
 ===================================================================
 RCS file: /cvs/src/usr.bin/cvs/file.c,v
 retrieving revision 1.261
 diff -u -r1.261 file.c
 --- file.c      27 Sep 2010 14:08:41 -0000      1.261
 +++ file.c      15 Oct 2010 12:12:40 -0000
 @@ -76,6 +76,7 @@
         "*$",
  };
  
 +int file_modified = 0;
  char *cvs_directory_tag = NULL;
  struct ignore_head cvs_ign_pats;
  struct ignore_head dir_ign_pats;
 @@ -969,6 +970,8 @@
         default:
                 break;
         }
 +
 +       file_modified |= ismodified;
  }
  
  void
 Index: diff.h
 ===================================================================
 RCS file: /cvs/src/usr.bin/cvs/diff.h,v
 retrieving revision 1.22
 diff -u -r1.22 diff.h
 --- diff.h      28 Jul 2010 21:19:30 -0000      1.22
 +++ diff.h      15 Oct 2010 12:12:40 -0000
 @@ -107,6 +107,7 @@
  int            diffreg(const char *, const char *, int, int, BUF *, int);
  int            ed_patch_lines(struct rcs_lines *, struct rcs_lines *);
  
 +extern int      file_modified;
  extern int       diff_format;
  extern int      diff_context;
  extern int      diff3_conflicts;
 
 
 
 dmesg:
 OpenBSD 4.7 (GENERIC) #112: Wed Mar 17 20:43:49 MDT 2010
     [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
 real mem = 804192256 (766MB)
 avail mem = 770875392 (735MB)
 mainbus0 at root
 bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xfbd3f (10 entries)
 bios0: vendor QEMU version "QEMU" date 01/01/2007
 acpi0 at bios0: rev 0
 acpi0: tables DSDT FACP APIC
 acpi0: wakeup devices
 acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
 acpiprt0 at acpi0: bus 0 (PCI0)
 acpicpu0 at acpi0
 mpbios at bios0 not configured
 cpu0 at mainbus0: (uniprocessor)
 cpu0: QEMU Virtual CPU version 0.9.1, 2667.25 MHz
 cpu0: 
FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,NXE,LONG
 cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 
16-way L2 cache
 cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 pci0 at mainbus0 bus 0
 pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
 pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
 pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0 
wired to compatibility, channel 1 wired to compatibility
 wd0 at pciide0 channel 0 drive 0: <QEMU HARDDISK>
 wd0: 16-sector PIO, LBA48, 20480MB, 41943040 sectors
 atapiscsi0 at pciide0 channel 0 drive 1
 scsibus0 at atapiscsi0: 2 targets
 cd0 at scsibus0 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 0.9.> ATAPI 5/cdrom 
removable
 wd0(pciide0:0:0): using PIO mode 0, DMA mode 2
 cd0(pciide0:0:1): using PIO mode 0
 atapiscsi1 at pciide0 channel 1 drive 0
 scsibus1 at atapiscsi1: 2 targets
 cd1 at scsibus1 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 0.9.> ATAPI 5/cdrom 
removable
 cd1(pciide0:1:0): using PIO mode 0
 uhci0 at pci0 dev 1 function 2 "Intel 82371SB USB" rev 0x01: irq 11
 piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: irq 10
 iic0 at piixpm0
 iic0: addr 0x18 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x1a 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x29 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x2b 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x48 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x49 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4a 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4b 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4c 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 48=00 
words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x4d 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4e 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 48=00 
words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 vga1 at pci0 dev 2 function 0 "Cirrus Logic CL-GD5446" rev 0x00
 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
 wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
 em0 at pci0 dev 3 function 0 "Intel PRO/1000MT (82540EM)" rev 0x03: irq 11, 
address 52:54:00:27:21:96
 "Qumranet Virtio Memory" rev 0x00 at pci0 dev 4 function 0 not configured
 "Qumranet Virtio Console" rev 0x00 at pci0 dev 5 function 0 not configured
 isa0 at pcib0
 isadma0 at isa0
 com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
 com0: probed fifo depth: 0 bytes
 pckbc0 at isa0 port 0x60/5
 pckbd0 at pckbc0 (kbd slot)
 pckbc0: using irq 1 for kbd slot
 wskbd0 at pckbd0: console keyboard, using wsdisplay0
 pmsi0 at pckbc0 (aux slot)
 pckbc0: using irq 12 for aux slot
 wsmouse0 at pmsi0 mux 0
 pcppi0 at isa0 port 0x61
 midi0 at pcppi0: <PC speaker>
 spkr0 at pcppi0
 fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
 fd0 at fdc0 drive 0: density unknown
 fd1 at fdc0 drive 1: density unknown
 usb0 at uhci0: USB revision 1.0
 uhub0 at usb0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
 nvram: invalid checksum
 mtrr: Pentium Pro MTRR support
 vscsi0 at root
 scsibus2 at vscsi0: 256 targets
 softraid0 at root
 root on wd0a swap on wd0b dump on wd0b
 clock: unknown CMOS layout
 syncing disks... done
 rebooting...
 OpenBSD 4.7 (GENERIC) #112: Wed Mar 17 20:43:49 MDT 2010
     [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
 real mem = 804192256 (766MB)
 avail mem = 770875392 (735MB)
 mainbus0 at root
 bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xfbd3f (10 entries)
 bios0: vendor QEMU version "QEMU" date 01/01/2007
 acpi0 at bios0: rev 0
 acpi0: tables DSDT FACP APIC
 acpi0: wakeup devices
 acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
 acpiprt0 at acpi0: bus 0 (PCI0)
 acpicpu0 at acpi0
 mpbios at bios0 not configured
 cpu0 at mainbus0: (uniprocessor)
 cpu0: QEMU Virtual CPU version 0.9.1, 2665.99 MHz
 cpu0: 
FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,NXE,LONG
 cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 
16-way L2 cache
 cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 pci0 at mainbus0 bus 0
 pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
 pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
 pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0 
wired to compatibility, channel 1 wired to compatibility
 wd0 at pciide0 channel 0 drive 0: <QEMU HARDDISK>
 wd0: 16-sector PIO, LBA48, 20480MB, 41943040 sectors
 atapiscsi0 at pciide0 channel 0 drive 1
 scsibus0 at atapiscsi0: 2 targets
 cd0 at scsibus0 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 0.9.> ATAPI 5/cdrom 
removable
 wd0(pciide0:0:0): using PIO mode 0, DMA mode 2
 cd0(pciide0:0:1): using PIO mode 0
 atapiscsi1 at pciide0 channel 1 drive 0
 scsibus1 at atapiscsi1: 2 targets
 cd1 at scsibus1 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 0.9.> ATAPI 5/cdrom 
removable
 cd1(pciide0:1:0): using PIO mode 0
 uhci0 at pci0 dev 1 function 2 "Intel 82371SB USB" rev 0x01: irq 11
 piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: irq 10
 iic0 at piixpm0
 iic0: addr 0x18 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x1a 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x29 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x2b 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 words 
00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x48 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x49 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4a 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4b 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4c 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 48=00 
words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 iic0: addr 0x4d 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 
06=0000 07=0000
 iic0: addr 0x4e 00=00 01=00 02=00 03=00 04=00 05=00 06=00 07=00 08=00 48=00 
words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
 vga1 at pci0 dev 2 function 0 "Cirrus Logic CL-GD5446" rev 0x00
 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
 wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
 em0 at pci0 dev 3 function 0 "Intel PRO/1000MT (82540EM)" rev 0x03: irq 11, 
address 52:54:00:27:21:96
 "Qumranet Virtio Memory" rev 0x00 at pci0 dev 4 function 0 not configured
 "Qumranet Virtio Console" rev 0x00 at pci0 dev 5 function 0 not configured
 isa0 at pcib0
 isadma0 at isa0
 com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
 com0: probed fifo depth: 0 bytes
 pckbc0 at isa0 port 0x60/5
 pckbd0 at pckbc0 (kbd slot)
 pckbc0: using irq 1 for kbd slot
 wskbd0 at pckbd0: console keyboard, using wsdisplay0
 pmsi0 at pckbc0 (aux slot)
 pckbc0: using irq 12 for aux slot
 wsmouse0 at pmsi0 mux 0
 pcppi0 at isa0 port 0x61
 midi0 at pcppi0: <PC speaker>
 spkr0 at pcppi0
 fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
 fd0 at fdc0 drive 0: density unknown
 fd1 at fdc0 drive 1: density unknown
 usb0 at uhci0: USB revision 1.0
 uhub0 at usb0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
 nvram: invalid checksum
 mtrr: Pentium Pro MTRR support
 vscsi0 at root
 scsibus2 at vscsi0: 256 targets
 softraid0 at root
 root on wd0a swap on wd0b dump on wd0b
 clock: unknown CMOS layout

Reply via email to