mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Change sidebar to consistently use realpath for context and buffy comparison.

The original sidebar patch contained a half-implemented attempt to use
realpath() mailbox paths for comparison. (Presumably so the open mailbox
remains highlighted despite symlink issues).

Add realpath to the Context, and set it when opening a mailbox.
Remove sidebar ifdef for the buffy member, and always set it there too.

Change the sidebar to use the realpath for comparison everywhere.

mutt_buffy_check() is using stat device and inode for comparison.
Perhaps this can be changed to use realpath instead, but that's beyond
the scope of this patch.

+30 -52
+2 -15
buffy.c
··· 201 201 static BUFFY *buffy_new (const char *path) 202 202 { 203 203 BUFFY* buffy; 204 - #ifdef USE_SIDEBAR 205 204 char rp[PATH_MAX] = ""; 206 205 char *r = NULL; 207 - #endif 208 206 209 207 buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY)); 210 208 strfcpy (buffy->path, path, sizeof (buffy->path)); 211 - #ifdef USE_SIDEBAR 212 209 r = realpath (path, rp); 213 210 strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath)); 214 - #endif 215 211 buffy->next = NULL; 216 212 buffy->magic = 0; 217 213 ··· 229 225 char buf[_POSIX_PATH_MAX]; 230 226 struct stat sb; 231 227 char f1[PATH_MAX]; 232 - #ifndef USE_SIDEBAR 233 - char f2[PATH_MAX]; 234 - #endif 235 - char *p, *q; 228 + char *p; 236 229 237 230 while (MoreArgs (s)) 238 231 { ··· 262 255 p = realpath (buf, f1); 263 256 for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) 264 257 { 265 - #ifdef USE_SIDEBAR 266 - q = (*tmp)->realpath; 267 - if (mutt_strcmp (p ? p : buf, q) == 0) 268 - #else 269 - q = realpath ((*tmp)->path, f2); 270 - if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0) 271 - #endif 258 + if (mutt_strcmp (p ? p : buf, (*tmp)->realpath) == 0) 272 259 { 273 260 dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path)); 274 261 break;
+2 -3
buffy.h
··· 26 26 typedef struct buffy_t 27 27 { 28 28 char path[_POSIX_PATH_MAX]; 29 - #ifdef USE_SIDEBAR 30 - char realpath[_POSIX_PATH_MAX]; 31 - #endif 29 + char realpath[_POSIX_PATH_MAX]; /* used for duplicate detection, context comparison, 30 + and the sidebar */ 32 31 off_t size; 33 32 struct buffy_t *next; 34 33 #ifdef USE_SIDEBAR
+4 -3
curs_main.c
··· 1226 1226 } 1227 1227 1228 1228 mutt_expand_path (buf, sizeof (buf)); 1229 - #ifdef USE_SIDEBAR 1230 - mutt_sb_set_open_buffy (buf); 1231 - #endif 1232 1229 if (mx_get_magic (buf) <= 0) 1233 1230 { 1234 1231 mutt_error (_("%s is not a mailbox."), buf); ··· 1277 1274 } 1278 1275 else 1279 1276 menu->current = 0; 1277 + 1278 + #ifdef USE_SIDEBAR 1279 + mutt_sb_set_open_buffy (); 1280 + #endif 1280 1281 1281 1282 mutt_clear_error (); 1282 1283 mutt_buffy_check(1); /* force the buffy check after we have changed
+2
imap/imap.c
··· 588 588 imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox); 589 589 590 590 FREE (&(ctx->path)); 591 + FREE (&(ctx->realpath)); 591 592 ctx->path = safe_strdup (buf); 593 + ctx->realpath = safe_strdup (ctx->path); 592 594 593 595 idata->ctx = ctx; 594 596
+1 -14
main.c
··· 567 567 568 568 int main (int argc, char **argv) 569 569 { 570 - #ifdef USE_SIDEBAR 571 - char folder[PATH_MAX] = ""; 572 - #else 573 570 char folder[_POSIX_PATH_MAX] = ""; 574 - #endif 575 571 char *subject = NULL; 576 572 char *includeFile = NULL; 577 573 char *draftFile = NULL; ··· 1202 1198 strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); 1203 1199 mutt_expand_path (folder, sizeof (folder)); 1204 1200 1205 - #ifdef USE_SIDEBAR 1206 - { 1207 - char tmpfolder[PATH_MAX] = ""; 1208 - strfcpy (tmpfolder, folder, sizeof (tmpfolder)); 1209 - if (!realpath (tmpfolder, folder)) 1210 - strfcpy (folder, tmpfolder, sizeof (tmpfolder)); 1211 - } 1212 - #endif 1213 - 1214 1201 mutt_str_replace (&CurrentFolder, folder); 1215 1202 mutt_str_replace (&LastFolder, folder); 1216 1203 ··· 1234 1221 || !explicit_folder) 1235 1222 { 1236 1223 #ifdef USE_SIDEBAR 1237 - mutt_sb_set_open_buffy (folder); 1224 + mutt_sb_set_open_buffy (); 1238 1225 #endif 1239 1226 mutt_index_menu (); 1240 1227 if (Context)
+1
mutt.h
··· 903 903 typedef struct _context 904 904 { 905 905 char *path; 906 + char *realpath; /* used for buffy comparison and the sidebar */ 906 907 FILE *fp; 907 908 time_t atime; 908 909 time_t mtime;
+3
mx.c
··· 628 628 ctx = safe_malloc (sizeof (CONTEXT)); 629 629 memset (ctx, 0, sizeof (CONTEXT)); 630 630 ctx->path = safe_strdup (path); 631 + if (! (ctx->realpath = realpath (ctx->path, NULL)) ) 632 + ctx->realpath = safe_strdup (ctx->path); 631 633 632 634 ctx->msgnotreadyet = -1; 633 635 ctx->collapsed = 0; ··· 740 742 FREE (&ctx->hdrs); 741 743 FREE (&ctx->v2r); 742 744 FREE (&ctx->path); 745 + FREE (&ctx->realpath); 743 746 FREE (&ctx->pattern); 744 747 if (ctx->limit_pattern) 745 748 mutt_pattern_free (&ctx->limit_pattern);
+2
pop.c
··· 421 421 return -1; 422 422 423 423 FREE (&ctx->path); 424 + FREE (&ctx->realpath); 424 425 ctx->path = safe_strdup (buf); 426 + ctx->realpath = safe_strdup (ctx->path); 425 427 426 428 pop_data = safe_calloc (1, sizeof (POP_DATA)); 427 429 pop_data->conn = conn;
+12 -16
sidebar.c
··· 148 148 if (!b) 149 149 return src; 150 150 151 - int c = Context && (mutt_strcmp (Context->path, b->path) == 0); 151 + int c = Context && (mutt_strcmp (Context->realpath, b->realpath) == 0); 152 152 153 153 optional = flags & MUTT_FORMAT_OPTIONAL; 154 154 ··· 407 407 (b == HilBuffy) || (b->msg_flagged > 0)) 408 408 continue; 409 409 410 - if (Context && (strcmp (b->path, Context->path) == 0)) 410 + if (Context && (mutt_strcmp (b->realpath, Context->realpath) == 0)) 411 411 /* Spool directory */ 412 412 continue; 413 413 ··· 648 648 SETCOLOR(MT_COLOR_NORMAL); 649 649 650 650 mutt_window_move (MuttSidebarWindow, row, 0); 651 - if (Context && Context->path && 652 - (!strcmp (b->path, Context->path)|| 653 - !strcmp (b->realpath, Context->path))) 651 + if (Context && Context->realpath && 652 + !mutt_strcmp (b->realpath, Context->realpath)) 654 653 { 655 654 b->msg_unread = Context->unread; 656 655 b->msg_count = Context->msgcount; ··· 844 843 845 844 for (; b; b = b->next) 846 845 { 847 - if (!strcmp (b->path, ctx->path) || 848 - !strcmp (b->realpath, ctx->path)) 846 + if (!mutt_strcmp (b->realpath, ctx->realpath)) 849 847 { 850 848 b->msg_unread = ctx->unread; 851 849 b->msg_count = ctx->msgcount; ··· 875 873 } 876 874 877 875 /** 878 - * mutt_sb_set_open_buffy - Set the OpnBuffy based on a mailbox path 879 - * @path: Mailbox path 876 + * mutt_sb_set_open_buffy - Set the OpnBuffy based on a the global Context 880 877 * 881 878 * Search through the list of mailboxes. If a BUFFY has a matching path, set 882 879 * OpnBuffy to it. 883 880 */ 884 - BUFFY *mutt_sb_set_open_buffy (const char *path) 881 + BUFFY *mutt_sb_set_open_buffy (void) 885 882 { 886 883 /* Even if the sidebar is hidden */ 887 884 888 885 BUFFY *b = Incoming; 889 - 890 - if (!path || !b) 891 - return NULL; 892 886 893 887 OpnBuffy = NULL; 894 888 889 + if (!Context || !b) 890 + return NULL; 891 + 895 892 for (; b; b = b->next) 896 893 { 897 - if (!strcmp (b->path, path) || 898 - !strcmp (b->realpath, path)) 894 + if (!mutt_strcmp (b->realpath, Context->realpath)) 899 895 { 900 896 OpnBuffy = b; 901 897 HilBuffy = b; ··· 937 933 { 938 934 /* This might happen if the user "unmailboxes *", then 939 935 * "mailboxes" our current mailbox back again */ 940 - if (mutt_strcmp (b->path, Context->path) == 0) 936 + if (mutt_strcmp (b->realpath, Context->realpath) == 0) 941 937 OpnBuffy = b; 942 938 } 943 939 }
+1 -1
sidebar.h
··· 28 28 const char * mutt_sb_get_highlight (void); 29 29 void mutt_sb_notify_mailbox (BUFFY *b, int created); 30 30 void mutt_sb_set_buffystats (const CONTEXT *ctx); 31 - BUFFY * mutt_sb_set_open_buffy (const char *path); 31 + BUFFY * mutt_sb_set_open_buffy (void); 32 32 33 33 #endif /* SIDEBAR_H */