Fossil Forum

Diff behavior
Login

Diff behavior

Diff behavior

(1) By Michael Durian (durian) on 2022-04-28 16:56:47 [link] [source]

I'm new to fossil and have encountered something that is throwing me for a loop.

If I am in the top-level of my project and do a diff, I see what I would expect.

$ fossil diff src/libcommon/cqt.h
Index: src/libcommon/cqt.h
==================================================================
--- src/libcommon/cqt.h
+++ src/libcommon/cqt.h
@@ -1,7 +1,9 @@
 #ifndef CQT_H
 #define CQT_H

 void cqt_init(void);
+void cqt_alloc(void);
+void cqt_release(void);
 void cqt_compute(float *data_in, float *data_out, uint32_t count);

 #endif /* CQT_H */

But if I change to the libcommon directory and do a diff there, it reports the file as MISSING.

$ cd src/libcommon
$ fossil diff cqt.h
MISSING  src/libcommon/cqt.h

A verbose diff sheds a little light on what is happening.

$ fossil diff -v cqt.h
MISSING  src/libcommon/cqt.h
Index: src/libcommon/cqt.h
==================================================================
--- src/libcommon/cqt.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef CQT_H
-#define CQT_H
-
-void cqt_init(void);
-void cqt_compute(float *data_in, float *data_out, uint32_t count);
-
-#endif /* CQT_H */

Fossil is using the relative path based on the project's top-level (src/libcommon/cqt.h), even though it is being called from the src/libcommon subdirectory and should be using (./cqt.h).

Is this the intended behavior? I'm running version 2.18 on a Mac.

(2) By Stephan Beal (stephan) on 2022-04-28 17:05:00 in reply to 1 [link] [source]

But if I change to the libcommon directory and do a diff there, it reports the file as MISSING. ... I'm running version 2.18 on a Mac.

That's a feature i've used almost daily for years and have never seen what you're describing. This is presumably a bit of platform-specific weirdness. Perhaps one of our other Mac users can confirm whether they can reproduce this. On Linux it's working as expected (presumably how you expect it to)...

[stephan@nuc:~/fossil/libfossil/include/fossil-scm]$ echo '// test' >> vpath.h 
[stephan@nuc:~/fossil/libfossil/include/fossil-scm]$ f diff vpath.h 
Index: include/fossil-scm/vpath.h
==================================================================
--- include/fossil-scm/vpath.h
+++ include/fossil-scm/vpath.h
@@ -234,5 +234,6 @@
 #if defined(__cplusplus)
 } /*extern "C"*/
 #endif
 #endif
 /* ORG_FOSSIL_SCM_FSL_VPATH_H_INCLUDED */
+// test

(3) By Richard Hipp (drh) on 2022-04-28 17:07:34 in reply to 1 [link] [source]

I'm not able to reproduce the problem. When I try it, Fossil seems to behave as the OP suggests it should.

(4) By Michael Durian (durian) on 2022-04-28 17:29:43 in reply to 3 [link] [source]

I didn't think I was doing anything unusual. Any thoughts as to what I can check to see why my set up is behaving the way it is?

I checked another project I have and it too does not behave as expected. So whatever I've done, at least I'm consistent.

(5) By Richard Hipp (drh) on 2022-04-28 17:38:55 in reply to 4 [link] [source]

Are you using symbolic links? If so, that might be part of the confusion.

What does the output of "fossil changes" show?

Did you build Fossil yourself, or are you using somebody else's build that might have bootleg patches?

(6) By Michael Durian (durian) on 2022-04-28 18:00:28 in reply to 5 [link] [source]

I am not using symbolic links.

"fossil changes" seems correct. The following is from my src/libcommon directory.

$ fossil changes
EDITED     ../Astra/init.c
EDITED     cqt.c
EDITED     cqt.h
EDITED     fft.c
EDITED     fft.h
EDITED     hit_detect.c
EDITED     hit_detect.h
EDITED     ../libeffects/effect_bullets.c
EDITED     ../libeffects/effect_cqt.c
EDITED     ../libeffects/effect_fft.c
EDITED     ../libeffects/effect_layers.c
EDITED     ../libeffects/effect_midi_tracker.c
EDITED     ../libeffects/effect_missiles.c
EDITED     ../libeffects/effect_napalm.c
EDITED     ../libeffects/effect_rainbow.c

I installed fossil via MacPorts. It doesn't look like they added any local patches.

https://github.com/macports/macports-ports/tree/master/devel/fossil

(7) By Martin Gagnon (mgagnon) on 2022-04-28 18:09:41 in reply to 6 [link] [source]

May be their compilation flags ?


configure.args-append       --with-tcl=${prefix}/lib \
                            --with-openssl=[openssl::install_area] \
                            --with-zlib=${prefix}/lib \
                            --with-th1-docs \
                            --with-th1-hooks \
                            --with-exec-rel-paths \
                            --json

Specifically: "--with-exec-rel-paths"

(9) By Michael Durian (durian) on 2022-04-28 18:25:57 in reply to 7 [link] [source]

This might be it. If I run

fossil diff --with-exec-abs-paths

from my src/libcommon directory, I get the output I expect.

(8) By Richard Hipp (drh) on 2022-04-28 18:20:31 in reply to 6 [link] [source]

Does "fossil diff --webpage >out1.html && open out1.html" work for you?

What about "fossil diff --webpage -y >out2.html && open out2.html"?

(10) By Michael Durian (durian) on 2022-04-28 18:29:28 in reply to 8 [link] [source]

Neither of these work. They both diff against /dev/null.

If I add --exec-abs-paths to the diff commands, it does work.

(11) By Richard Hipp (drh) on 2022-04-28 18:35:25 in reply to 10 [link] [source]

I don't even know what --with-exec-rel-paths does. That's something somebody else has added.

(12) By Michael Durian (durian) on 2022-04-28 18:38:54 in reply to 11 [link] [source]

I'll report it as a bug to MacPorts. I'll ask them to remove that configuration option.

(13.1) By Martin Gagnon (mgagnon) on 2022-04-28 19:17:08 edited from 13.0 in reply to 11 [link] [source]

From common on auto.def

or from the equivalent setting

It seems to be to use relative path by default when calling external diff program.

(14) By Michael Durian (durian) on 2022-04-28 21:35:13 in reply to 13.1 [link] [source]

It looks like it comes down to this (from diff_against_disk in diffcmd.c):

const char *zPathname = db_column_text(&q,0);
int isDeleted = db_column_int(&q, 1);
int isChnged = db_column_int(&q,2);
int isNew = db_column_int(&q,3);
int srcid = db_column_int(&q, 4);
int isLink = db_column_int(&q, 5);
const char *zFullName;
int showDiff = 1;
Blob fname;

if( !file_dir_match(pFileDir, zPathname) ) continue;
if( determine_exec_relative_option(0) ){
  blob_zero(&fname);
  file_relative_name(zPathname, &fname, 1);
}else{
  blob_set(&fname, g.zLocalRoot);
  blob_append(&fname, zPathname, -1);
}

The --with-exec-rel-paths configuration option instructs determine_exec_relative_option() to default to returning 1. This looks reasonable to me. Maybe the diff is always relative to the top-level directory and not the current working directory? And if that's the case, I'm not sure how exec-rel-path would be useful.

Anyway, hopefully MacPorts will make the configuration change and it will be a moot issue.

(15) By Martin Gagnon (mgagnon) on 2022-04-28 21:42:21 in reply to 14 [source]

And if that's the case, I'm not sure how exec-rel-path would be useful.

I don't know either, I always use vimdiff as external diff tools, and I never had the need to use this --with-exec-rel-paths option. May be other tools require it ? I don't know.