Skip to content

Commit 609e9b8

Browse files
committed
Sync
- Touchup dialogs a bit - Icons for diff/history windows, util func for it - Fix context management issues with VC++6, remove refcount - Implement GetCommandOptions, used only for push after commit rn - Enable push after commit - Enable init from SccOpenProject - Fix crash from HTTP auth dialog
1 parent 43042d2 commit 609e9b8

17 files changed

Lines changed: 509 additions & 56 deletions

LGit.aps

3.94 KB
Binary file not shown.

LGit.cpp

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ SCCRTN SccInitialize (LPVOID * context, // SCC provider contex
100100
LPLONG checkoutCommentLen, // Check out comment max length
101101
LPLONG commentLen) // Other comments max length
102102
{
103-
int init_count;
104-
105-
init_count = git_libgit2_init();
103+
LGitLog("**SccInitialize**\n");
104+
LGitLog(" Caller = %s\n", callerName);
105+
int init_count = git_libgit2_init();
106106
if (init_count < 0) {
107107
LGitLibraryError(hWnd, "Error initializing LGit");
108108
return SCC_E_INITIALIZEFAILED;
109109
}
110-
LGitLog("**SccInitialize** initialization count: %d (by %s)\n", init_count, callerName);
110+
LGitLog(" InitCount = %d\n", init_count);
111111

112112
/* Should this be only on the first init count? */
113113
LGitInitOpts();
@@ -125,8 +125,11 @@ SCCRTN SccInitialize (LPVOID * context, // SCC provider contex
125125

126126
LGitLog(" LPVOID* Context=%p\n", context);
127127
LGitLog(" *Context=%p\n", *context);
128-
// It appears VS reuses
129-
if (context && *context == NULL) {
128+
/*
129+
* VC++ 6 will provide the last handle we initialized. Other IDEs don't do
130+
* this. It's not some reuse scheme - don't get confused!
131+
*/
132+
if (context != NULL) {
130133
*context = malloc(sizeof(LGitContext));
131134
LGitContext *ctx = (LGitContext*)*context;
132135
if (*context == NULL) {
@@ -136,14 +139,8 @@ SCCRTN SccInitialize (LPVOID * context, // SCC provider contex
136139
ZeroMemory(*context, sizeof(LGitContext));
137140
strlcpy(ctx->appName, callerName, SCC_NAME_LEN);
138141
ctx->dllInst = dllInstance;
139-
ctx->refcount = 1;
140-
} else if (context) {
141-
LGitContext *ctx = (LGitContext*)*context;
142-
LGitLog(" Recycling context\n");
143-
LGitLog(" ProjPath =%s\n", ctx->path);
144-
LGitLog(" WorkPath =%s\n", ctx->workdir_path);
145-
LGitLog("(Old)Refcount =%d\n", ctx->refcount);
146-
LGitLog("(New)Refcount =%d\n", ++ctx->refcount);
142+
} else {
143+
return SCC_E_INITIALIZEFAILED;
147144
}
148145

149146
return SCC_OK;
@@ -160,20 +157,9 @@ SCCRTN SccUninitialize (LPVOID context)
160157
if (uninit_count < 0) {
161158
LGitLibraryError(NULL, "Error ending LGit");
162159
}
163-
/*
164-
* HACK: It seems Visual C++ 6, when switching workspaces, will call
165-
* close, uninit... then open project, which frees this. Then it keeps
166-
* the handle. Then devenv98 will keep multiple contexts around, so we
167-
* should keep a reference count instead.
168-
*/
169-
if (context) {
170-
ctx->refcount--;
171-
LGitLog(" Refcount now %d\n", ctx->refcount);
172-
}
173-
if (context && ctx->refcount == 0) {
174-
LGitLog(" Freed context\n");
175-
free(context);
176-
}
160+
161+
LGitLog(" Freed context\n");
162+
free(context);
177163
return SCC_OK;
178164
}
179165

@@ -192,16 +178,6 @@ SCCRTN SccRunScc(LPVOID context,
192178
return SCC_E_OPNOTSUPPORTED;
193179
}
194180

195-
SCCRTN SccGetCommandOptions (LPVOID context,
196-
HWND hWnd,
197-
enum SCCCOMMAND nCommand,
198-
LPCMDOPTS * ppvOptions)
199-
{
200-
LGitLog("**SccGetCommandOptions** Context=%p\n", context);
201-
LGitLog(" command %s\n", LGitCommandName(nCommand));
202-
return SCC_E_OPNOTSUPPORTED;
203-
}
204-
205181
const char* LGitCommandName(enum SCCCOMMAND command)
206182
{
207183
switch (command) {

LGit.dsp

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LGit.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
/* XXX: Use a case-insensitive comparator */
1515
typedef std::set<std::string> CheckoutQueue;
1616

17+
/* Defining here so they can be defined in ctx; used in cmdopts.cpp */
18+
typedef struct _LGitCommitOpts {
19+
BOOL push;
20+
} LGitCommitOpts;
21+
1722
typedef struct _LGitContext {
1823
/* housekeeping */
1924
BOOL active;
20-
int refcount;
2125
HINSTANCE dllInst;
2226
/* With shared SCC subproject, so we don't free IDE provided dir string */
2327
BOOL addSccSuccess;
@@ -37,6 +41,8 @@ typedef struct _LGitContext {
3741
char appName[SCC_NAME_SIZE];
3842
/* SCC provided username, used for some remote contexts */
3943
char username[SCC_USER_SIZE];
44+
/* Command options */
45+
LGitCommitOpts commitOpts;
4046
} LGitContext;
4147

4248
/* LGit.cpp */
@@ -64,6 +70,10 @@ void LGitPushCheckout(LGitContext *ctx, const char *fileName);
6470
BOOL LGitPopCheckout(LGitContext *ctx, const char *fileName);
6571
BOOL LGitIsCheckout(LGitContext *ctx, const char *fileName);
6672

73+
/* pushpull.cpp */
74+
SCCRTN LGitPush(LGitContext *ctx, HWND hwnd, git_remote *remote, git_reference *refname);
75+
SCCRTN LGitPushDialog(LGitContext *ctx, HWND hwnd);
76+
6777
/* clone.cpp */
6878
SCCRTN LGitClone(LGitContext *ctx, HWND hWnd, LPSTR lpProjName, LPSTR lpLocalPath, LPBOOL pbNew);
6979

@@ -109,3 +119,6 @@ BOOL LGitCertificatePrompt(LGitContext *ctx, HWND parent, git_cert *cert, const
109119
char *strcasestr(const char *s, const char *find);
110120
size_t strlcat(char *dst, const char *src, size_t siz);
111121
size_t strlcpy(char *dst, const char *src, size_t siz);
122+
123+
/* winutil.cpp */
124+
void LGitSetWindowIcon(HWND hwnd, HINSTANCE inst, LPCSTR name);

LGit.rc

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ END
110110
IDD_DIFF DIALOG DISCARDABLE 0, 0, 402, 245
111111
STYLE WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
112112
CAPTION "Diff"
113+
MENU IDR_DIFF_MENU
113114
FONT 8, "MS Sans Serif"
114115
BEGIN
115116
CONTROL "List1",IDC_DIFFTEXT,"SysListView32",LVS_REPORT |
@@ -169,7 +170,7 @@ BEGIN
169170
END
170171

171172
IDD_CLONE DIALOG DISCARDABLE 0, 0, 254, 99
172-
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
173+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
173174
CAPTION "Clone Git Repository"
174175
FONT 8, "MS Sans Serif"
175176
BEGIN
@@ -187,7 +188,7 @@ BEGIN
187188
END
188189

189190
IDD_AUTH_USERPASS DIALOG DISCARDABLE 0, 0, 254, 81
190-
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
191+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
191192
CAPTION "Authenticate for Repository"
192193
FONT 8, "MS Sans Serif"
193194
BEGIN
@@ -215,7 +216,7 @@ BEGIN
215216
END
216217

217218
IDD_NEW_SIGNATURE DIALOG DISCARDABLE 0, 0, 254, 81
218-
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
219+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
219220
CAPTION "Enter Signature"
220221
FONT 8, "MS Sans Serif"
221222
BEGIN
@@ -249,6 +250,34 @@ BEGIN
249250
WS_VSCROLL | WS_HSCROLL
250251
END
251252

253+
IDD_OPTIONS_COMMIT DIALOG DISCARDABLE 0, 0, 162, 74
254+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
255+
CAPTION "Commit Options"
256+
FONT 8, "MS Sans Serif"
257+
BEGIN
258+
DEFPUSHBUTTON "OK",IDOK,50,53,50,14
259+
PUSHBUTTON "Cancel",IDCANCEL,105,53,50,14
260+
CONTROL "&Push after commit",IDC_OPTIONS_COMMIT_PUSH,"Button",
261+
BS_AUTOCHECKBOX | WS_TABSTOP,7,7,148,10
262+
LTEXT "When this option is checked, you will get a prompt after commit to push your changes to an available remote.",
263+
IDC_STATIC,7,22,148,26
264+
END
265+
266+
IDD_PUSH_UPSTAIRS DIALOG DISCARDABLE 0, 0, 254, 81
267+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
268+
CAPTION "Push"
269+
FONT 8, "MS Sans Serif"
270+
BEGIN
271+
DEFPUSHBUTTON "OK",IDOK,141,60,50,14
272+
PUSHBUTTON "Cancel",IDCANCEL,197,60,50,14
273+
CTEXT "&Remote",IDC_STATIC,7,7,40,14,SS_CENTERIMAGE
274+
CTEXT "Re&ference",IDC_STATIC,7,26,40,14,SS_CENTERIMAGE
275+
COMBOBOX IDC_PUSH_REMOTE,47,7,200,30,CBS_DROPDOWNLIST | CBS_SORT |
276+
WS_VSCROLL | WS_TABSTOP
277+
COMBOBOX IDC_PUSH_REF,47,26,200,56,CBS_DROPDOWN | CBS_SORT |
278+
WS_VSCROLL | WS_TABSTOP
279+
END
280+
252281

253282
/////////////////////////////////////////////////////////////////////////////
254283
//
@@ -383,6 +412,33 @@ BEGIN
383412
HORZGUIDE, 156
384413
HORZGUIDE, 161
385414
END
415+
416+
IDD_OPTIONS_COMMIT, DIALOG
417+
BEGIN
418+
LEFTMARGIN, 7
419+
RIGHTMARGIN, 155
420+
VERTGUIDE, 100
421+
VERTGUIDE, 105
422+
TOPMARGIN, 7
423+
BOTTOMMARGIN, 67
424+
HORZGUIDE, 17
425+
HORZGUIDE, 22
426+
HORZGUIDE, 48
427+
HORZGUIDE, 53
428+
END
429+
430+
IDD_PUSH_UPSTAIRS, DIALOG
431+
BEGIN
432+
LEFTMARGIN, 7
433+
RIGHTMARGIN, 247
434+
VERTGUIDE, 47
435+
VERTGUIDE, 191
436+
VERTGUIDE, 197
437+
TOPMARGIN, 7
438+
BOTTOMMARGIN, 74
439+
HORZGUIDE, 54
440+
HORZGUIDE, 60
441+
END
386442
END
387443
#endif // APSTUDIO_INVOKED
388444

@@ -401,6 +457,8 @@ IDI_DIFF_HUNK ICON DISCARDABLE "diffhunk.ico"
401457
IDI_DIFF_ADD ICON DISCARDABLE "diffadd.ico"
402458
IDI_DIFF_DEL ICON DISCARDABLE "diffdel.ico"
403459
IDI_DIFF_FILE_B ICON DISCARDABLE "difffilb.ico"
460+
IDI_HISTORY ICON DISCARDABLE "history.ico"
461+
IDI_DIFF ICON DISCARDABLE "diff.ico"
404462

405463
/////////////////////////////////////////////////////////////////////////////
406464
//

caps.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
LONG LGitGetCaps(void)
99
{
1010
/* XXX: We could do IDE-specific hacks eventually. */
11-
return /* all as of 1.3 listed */
11+
LONG caps = /* all as of 1.3 listed */
1212
/* SccRemove */
1313
SCC_CAP_REMOVE
1414
/* SccRename */
@@ -21,9 +21,10 @@ LONG LGitGetCaps(void)
2121
| SCC_CAP_PROPERTIES
2222
/* SccRunScc */
2323
| SCC_CAP_RUNSCC
24-
/* SccGetCommandOptions; Not supported yet, will eventually */
25-
/* | SCC_GETCOMMANDOPTIONS */
26-
| SCC_CAP_QUERYINFO /* SccQueryInfo */
24+
/* SccGetCommandOptions */
25+
| SCC_CAP_GETCOMMANDOPTIONS
26+
/* SccQueryInfo */
27+
| SCC_CAP_QUERYINFO
2728
/* SccGetEvents; Not support, may not make sense */
2829
/* | SCC_CAP_GETEVENTS */
2930
/* SccGetProjPath */
@@ -72,6 +73,8 @@ LONG LGitGetCaps(void)
7273
| SCC_CAP_REENTRANT
7374
/* Creates MSSCCPRJ.SCC; we don't right now (but supports func) */
7475
| SCC_CAP_SCCFILE;
76+
LGitLog(" ! Caps %x\n", caps);
77+
return caps;
7578
}
7679

7780
SCCEXTERNC SCCRTN EXTFUN __cdecl SccGetExtendedCapabilities (LPVOID pContext,

0 commit comments

Comments
 (0)