Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
On Tue, Apr 3, 2018 at 11:07 PM, Eric Pruitt wrote: > On Tue, Apr 03, 2018 at 07:55:53PM +0200, Silvan Jegen wrote: >> I tried the attached patch and it didn't work either. After creating >> a patch in this repo myself (and googling the error) I realized that >> your patch didn't have the "a/", resp. "b/" string prefix in the diff >> filenames. After adding these prefixes by hand (attached), the patch >> applied for me. >> >> How did you generate these patches? It's the first time I had this issue. > > ericpruitt@sinister:~$ cd projects/dwm/ > ericpruitt@sinister:dwm$ git format-patch HEAD^ > 0001-Make-unset-property-fallback-strings-configurable.patch > > However I relatively recently added "noprefix = true" to my Git > configuration i.e. > > [diff] > noprefix = true I assume this is the culprit. Looking at https://stackoverflow.com/questions/6764953/what-is-the-reason-for-the-a-b-prefixes-of-git-diff this option seems to be useful if you use 'patch' instead of git to apply the patches. > algorithm = patience > > It seems odd to me that Git would create a broken (or perhaps > backward-incompatible) patch because of that option. What version of Git > are you using? I'm running 2.11.0. I am using 2.16.3 but that shouldn't matter. > Actually, the patch fails to apply for me, too, so I've completely axed > that option from my configuration. Yeah, seems sensible to me. It's good to keep in mind if I encounter a similar issue in the future though (who am I kidding. I will have forgotten and will have to look up everything again...) Cheers, Silvan
Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
On Tue, Apr 03, 2018 at 02:07:37PM -0700, Eric Pruitt wrote: > It seems odd to me that Git would create a broken (or perhaps > backward-incompatible) patch because of that option. What version of Git > are you using? I'm running 2.11.0. Actually, the patch fails to apply for me, too, so I've completely axed that option from my configuration. Eric
Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
On Tue, Apr 03, 2018 at 07:55:53PM +0200, Silvan Jegen wrote: > I tried the attached patch and it didn't work either. After creating > a patch in this repo myself (and googling the error) I realized that > your patch didn't have the "a/", resp. "b/" string prefix in the diff > filenames. After adding these prefixes by hand (attached), the patch > applied for me. > > How did you generate these patches? It's the first time I had this issue. ericpruitt@sinister:~$ cd projects/dwm/ ericpruitt@sinister:dwm$ git format-patch HEAD^ 0001-Make-unset-property-fallback-strings-configurable.patch However I relatively recently added "noprefix = true" to my Git configuration i.e. [diff] noprefix = true algorithm = patience It seems odd to me that Git would create a broken (or perhaps backward-incompatible) patch because of that option. What version of Git are you using? I'm running 2.11.0. Eric
Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
Hi Eric On Mon, Apr 02, 2018 at 08:59:57PM -0700, Eric Pruitt wrote: > On Mon, Apr 02, 2018 at 11:10:42AM +0200, Silvan Jegen wrote: > > error: git diff header lacks filename information when removing 1 > > leading pathname component (line 5) > > Please try the attached patch. I tried the attached patch and it didn't work either. After creating a patch in this repo myself (and googling the error) I realized that your patch didn't have the "a/", resp. "b/" string prefix in the diff filenames. After adding these prefixes by hand (attached), the patch applied for me. How did you generate these patches? It's the first time I had this issue. Anyways, I compiled the code and the code looks correct to me. I never encountered this issue myself so I am not sure if this patch is really needed or not. If it solves a real issue people are having, applying it makes sense. Cheers, Silvan >From 0b5c617c56f1c6a01034ae2dc5fc0cc114d590cd Mon Sep 17 00:00:00 2001 From: Eric Pruitt Date: Sun, 1 Apr 2018 14:35:01 -0700 Subject: [PATCH] Make unset property fallback strings configurable Since the default rule matching does substring comparisons, using the fixed string "broken" as a fallback value can complicate or make unambiguous matching impossible, so this change makes various fallback strings for unset properties configurable via config.h. --- config.def.h | 5 + dwm.c| 7 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index a9ac303..8dfc8b1 100644 --- config.def.h +++ config.def.h @@ -43,6 +43,11 @@ static const Layout layouts[] = { { "[M]", monocle }, }; +/* Fallback strings for unset window properties. */ +static const char unset_instance_fallback[] = "broken"; +static const char unset_class_fallback[] = "broken"; +static const char unset_name_fallback[] = "broken"; + /* key definitions */ #define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ diff --git a/dwm.c b/dwm.c index c98678d..9735e32 100644 --- dwm.c +++ dwm.c @@ -235,7 +235,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); /* variables */ -static const char broken[] = "broken"; static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ @@ -288,8 +287,8 @@ applyrules(Client *c) c->isfloating = 0; c->tags = 0; XGetClassHint(dpy, c->win, &ch); - class= ch.res_class ? ch.res_class : broken; - instance = ch.res_name ? ch.res_name : broken; + class= ch.res_class ? ch.res_class : unset_class_fallback; + instance = ch.res_name ? ch.res_name : unset_instance_fallback; for (i = 0; i < LENGTH(rules); i++) { r = &rules[i]; @@ -1998,7 +1997,7 @@ updatetitle(Client *c) if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name); if (c->name[0] == '\0') /* hack to mark broken clients */ - strcpy(c->name, broken); + strcpy(c->name, unset_name_fallback); } void -- 2.11.0
Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
On Mon, Apr 02, 2018 at 11:10:42AM +0200, Silvan Jegen wrote: > error: git diff header lacks filename information when removing 1 > leading pathname component (line 5) Please try the attached patch. Eric >From 0b5c617c56f1c6a01034ae2dc5fc0cc114d590cd Mon Sep 17 00:00:00 2001 From: Eric Pruitt Date: Sun, 1 Apr 2018 14:35:01 -0700 Subject: [PATCH] Make unset property fallback strings configurable Since the default rule matching does substring comparisons, using the fixed string "broken" as a fallback value can complicate or make unambiguous matching impossible, so this change makes various fallback strings for unset properties configurable via config.h. --- config.def.h | 5 + dwm.c| 7 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git config.def.h config.def.h index a9ac303..8dfc8b1 100644 --- config.def.h +++ config.def.h @@ -43,6 +43,11 @@ static const Layout layouts[] = { { "[M]", monocle }, }; +/* Fallback strings for unset window properties. */ +static const char unset_instance_fallback[] = "broken"; +static const char unset_class_fallback[] = "broken"; +static const char unset_name_fallback[] = "broken"; + /* key definitions */ #define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ diff --git dwm.c dwm.c index c98678d..9735e32 100644 --- dwm.c +++ dwm.c @@ -235,7 +235,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); /* variables */ -static const char broken[] = "broken"; static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ @@ -288,8 +287,8 @@ applyrules(Client *c) c->isfloating = 0; c->tags = 0; XGetClassHint(dpy, c->win, &ch); - class= ch.res_class ? ch.res_class : broken; - instance = ch.res_name ? ch.res_name : broken; + class= ch.res_class ? ch.res_class : unset_class_fallback; + instance = ch.res_name ? ch.res_name : unset_instance_fallback; for (i = 0; i < LENGTH(rules); i++) { r = &rules[i]; @@ -1998,7 +1997,7 @@ updatetitle(Client *c) if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name); if (c->name[0] == '\0') /* hack to mark broken clients */ - strcpy(c->name, broken); + strcpy(c->name, unset_name_fallback); } void -- 2.11.0
Re: [hackers] [PATCH] [dwm] Make unset property fallback strings configurable
Hi On Sun, Apr 01, 2018 at 02:45:23PM -0700, Eric Pruitt wrote: > > Since the default rule matching does substring comparisons, using the > fixed string "broken" as a fallback value can complicate or make > unambiguous matching impossible, so this change makes various fallback > strings for unset properties configurable via config.h. > --- > config.def.h | 5 + > dwm.c| 7 +++ > 2 files changed, 8 insertions(+), 4 deletions(-) The patch did not apply for me when saving the attached patch and applying it with "git apply" on dwm HEAD at 3bd8466e93b2c81be86e67c6ecdda4e1d240fe4b I get the following error: error: git diff header lacks filename information when removing 1 leading pathname component (line 5) Can someone else confirm that it is working on their repo? Maybe it's my setup that's broken somehow. Cheers, Silvan
[hackers] [PATCH] [dwm] Make unset property fallback strings configurable
Since the default rule matching does substring comparisons, using the fixed string "broken" as a fallback value can complicate or make unambiguous matching impossible, so this change makes various fallback strings for unset properties configurable via config.h. --- config.def.h | 5 + dwm.c| 7 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git config.def.h config.def.h index a9ac303..8dfc8b1 100644 --- config.def.h +++ config.def.h @@ -43,6 +43,11 @@ static const Layout layouts[] = { { "[M]", monocle }, }; +/* Fallback strings for unset window properties. */ +static const char unset_instance_fallback[] = "broken"; +static const char unset_class_fallback[] = "broken"; +static const char unset_name_fallback[] = "broken"; + /* key definitions */ #define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ diff --git dwm.c dwm.c index c98678d..9735e32 100644 --- dwm.c +++ dwm.c @@ -235,7 +235,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); /* variables */ -static const char broken[] = "broken"; static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ @@ -288,8 +287,8 @@ applyrules(Client *c) c->isfloating = 0; c->tags = 0; XGetClassHint(dpy, c->win, &ch); - class= ch.res_class ? ch.res_class : broken; - instance = ch.res_name ? ch.res_name : broken; + class= ch.res_class ? ch.res_class : unset_class_fallback; + instance = ch.res_name ? ch.res_name : unset_instance_fallback; for (i = 0; i < LENGTH(rules); i++) { r = &rules[i]; @@ -1998,7 +1997,7 @@ updatetitle(Client *c) if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name); if (c->name[0] == '\0') /* hack to mark broken clients */ - strcpy(c->name, broken); + strcpy(c->name, unset_name_fallback); } void