bug-diffutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-diffutils] diff -u: start chunk actually even /before/ the first di


From: Jan-Benedict Glaw
Subject: [bug-diffutils] diff -u: start chunk actually even /before/ the first different line
Date: Tue, 22 May 2012 12:51:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3

Hi!

(Please Cc: me, I'm not on this list.)

Since years, I dislike the behavior of `diff -u' when you add
entries to an array of structs. The chunk is aligned so that it
starts with the first line that actually differs (plus context).
That isn't exactly wrong and will perfectly apply, but is a bit
awkward to read. Consider this patch:

--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -747,6 +747,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
        },
        {
                .callback = intel_no_lvds_dmi_callback,
+               .ident = "Hewlett-Packard HP t5740e Thin Client",
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "HP t5740e Thin Client"),
+               },
+       },
+       {
+               .callback = intel_no_lvds_dmi_callback,
                .ident = "Hewlett-Packard t5745",
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),


I added another entry to some table.  It could have looked like
this:


--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -747,6 +747,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
                },

        },
+       {
+               .callback = intel_no_lvds_dmi_callback,
+               .ident = "Hewlett-Packard HP t5740e Thin Client",
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "HP t5740e Thin Client"),
+               },
+       },
        {
                .callback = intel_no_lvds_dmi_callback,
                .ident = "Hewlett-Packard t5745",

(I edited this manually.) For a simple insertion, I moved up the whole chunk by
two lines of context; in this case, it would visually represent what I actually
did.  I've not thought this to an end and this mail is ment to start a
discussion about it, but a proposed change could be to move a chunk up by two
lines (which would be typical for a C source file I guess) if the resulting
patch still "does the same".  I'm not sure on how much stuff would need to be
shifted up, and I'm probably already used to look at a patch and recognize the
pattern of an insertion to a C'ish table, but nontheless: If it isn't too hard
to move the chunk window a bit up, that would improve readability of patches
like this.

Thanks a lot,
Jan-Benedict

--
Getslash GmbH, Bahnhofstraße 16, 59302 Oelde
Tel: +49-2522-834349-5    Fax: +49-2522-834349-1
http://www.getslash.de
Sitz der Gesellschaft: Oelde
Handelsregister: Amtsgericht Münster, HRB 11911
Ust-Id-Nr.: DE 815060326
Geschäftsführung: Andre Peitz, Tobias Hanisch



reply via email to

[Prev in Thread] Current Thread [Next in Thread]